ConvertTextToSpeech: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
'''
{{Useful Function}}
== * convertWordsToSound ==
<lowercasetitle/>
'''
__NOTOC__


*only Server Side
*only Server Side
*Author: Has[S]oN
*Author: Has[S]oN


Syntax:
This function converts any word to sound
----
==Syntax:==
<syntaxhighlight lang="lua">convertWordsToSound(string text)</syntaxhighlight>
<syntaxhighlight lang="lua">convertWordsToSound(string text)</syntaxhighlight>
'''
== Required Arguments: ==
== Required Arguments: ==
'''
* text: the Text you want to convert it from word to sound
* text: the Text you want to convert it from word to sound
'''


== Code: ==
== Code: ==
'''
<section name="Server" class="server" show="true">
 
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">--Server Side
function convertWordsToSound(str)
function convertWordsToSound(str)
local str2 = ""
local str2 = ""
Line 28: Line 20:
triggerClientEvent(source,"VoiceClient",source,str2)
triggerClientEvent(source,"VoiceClient",source,str2)
end
end
</syntaxhighlight>
</section>
<section name="Client" class="client" show="true">
--Client Side
<syntaxhighlight lang="lua">
function sayVoice(str)
function sayVoice(str)
currentVoice = playSound(str)
currentVoice = playSound(str)
Line 39: Line 30:
addEventHandler("VoiceClient",localPlayer,sayVoice)
addEventHandler("VoiceClient",localPlayer,sayVoice)
</syntaxhighlight>
</syntaxhighlight>
</section>


'''
== Example: ==
== Example: ==
'''
<section name="Server" class="server" show="true">
 
 
'''Server Side:'''
 
<syntaxhighlight lang="lua">function convertWordsToSound(str)
<syntaxhighlight lang="lua">function convertWordsToSound(str)
local str2 = ""
local str2 = ""
Line 58: Line 45:
function (messag)
function (messag)
convertWordsToSound(messag)
convertWordsToSound(messag)
end)</syntaxhighlight>
end)</syntaxhighlight></section>
 
<section name="Client" class="client" show="true">
Client Side:
 
 
<syntaxhighlight lang="lua">function sayVoice(str)
<syntaxhighlight lang="lua">function sayVoice(str)
currentVoice = playSound(str)
currentVoice = playSound(str)
Line 68: Line 52:
addEvent("VoiceClient",true)
addEvent("VoiceClient",true)
addEventHandler("VoiceClient",localPlayer,sayVoice)</syntaxhighlight>
addEventHandler("VoiceClient",localPlayer,sayVoice)</syntaxhighlight>
 
</section>
----
==More Info==
 
Of course the function Very clear from his name
convert any word to sound
 
 
For do the function work with arabic please replace
For do the function work with arabic please replace



Revision as of 19:22, 25 August 2014


  • only Server Side
  • Author: Has[S]oN

This function converts any word to sound

Syntax:

convertWordsToSound(string text)

Required Arguments:

  • text: the Text you want to convert it from word to sound

Code:

Click to collapse [-]
Server
function convertWordsToSound(str)
local str2 = ""
str2 = "http://translate.google.com/translate_tts?tl=en&q="..str..""
triggerClientEvent(source,"VoiceClient",source,str2)
end
Click to collapse [-]
Client
function sayVoice(str)
currentVoice = playSound(str)
end
addEvent("VoiceClient",true)
addEventHandler("VoiceClient",localPlayer,sayVoice)

Example:

Click to collapse [-]
Server
function convertWordsToSound(str)
local str2 = ""
str2 = "http://translate.google.com/translate_tts?tl=en&q="..str..""
triggerClientEvent(source,"VoiceClient",source,str2)
end
 
 
 
addEventHandler("onPlayerChat",root,
function (messag)
convertWordsToSound(messag)
end)
Click to collapse [-]
Client
function sayVoice(str)
currentVoice = playSound(str)
end
addEvent("VoiceClient",true)
addEventHandler("VoiceClient",localPlayer,sayVoice)

More Info

For do the function work with arabic please replace

str2 = "http://translate.google.com/translate_tts?tl=en&q="..str..""

to

str2 = "http://translate.google.com/translate_tts?tl=ar&q="..str..""

thx and sorry for bad english :)