Join us in Phaze Demesnes or follow us:

Home   Show All
Category: Contributor: Creator
Chat-To-Speech Chat-To-Speech-MOAP  

Chat-To-Speech-MOAP

Put on a prim, enable shared media, click the prim face, and type something. // requires the Media on a prim be enabled. // immediately speaks "Hello, chat to speech is ready!" - if this does not work, you have issued with MOAP, flash, or other issues. // Check the Ctrl-P settings to be sure Media on a prim is enabled. // It assumes that the language spoken is the same as that detected in the viewer of the chatter.

Category: Chat-To-Speech
By : John Jamison
Created: 2013-09-25 Edited: 2013-09-25
Worlds: Second Life + OpenSim

the Zip file

Download all files for Chat-To-Speech-MOAP
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl
1
2 // Original script by John Jamison john at imagilearning.com
3 // Mods by Ferd Frederix for various speakers
4 // resets when rezzed to establish listener.
5 // checks for > 100 chars, which Google ignores
6
7 string getLang (key id)
8 {
10
11 if (lang != "zh-CN" && lang != "zh-TW")
12 {
13 lang = llGetSubString(lang,0,1);
14 }
15 return lang;
16 }
17
18 default
19 {
20 state_entry() {
21
22 llListen(PUBLIC_CHANNEL,"","","");
23 llSetText("Text 2 Voice",<1,1,1>,1.0);
24 string URL = "http://translate.google.com/translate_tts?ie=utf-8&tl=en&q=" + llEscapeURL("Hello, chat to speech is ready!");
25 //URL = "http://www.free-lsl-scripts.com";
26 llSetPrimMediaParams(1,[PRIM_MEDIA_CONTROLS,PRIM_MEDIA_CONTROLS_STANDARD,PRIM_MEDIA_HOME_URL,URL,PRIM_MEDIA_AUTO_PLAY,TRUE]);
27 }
28
29 listen(integer chan, string name, key id, string message)
30 {
31 if (llStringLength(message) < 100) {
32 llSetText("Text 2 Voice",<1,1,1>,1.0);
33 string URL = "http://translate.google.com/translate_tts?ie=utf-8&tl=" + getLang(id) + "&q="+llEscapeURL(message);
34 //llOwnerSay(URL);
35 llSetPrimMediaParams(1,[PRIM_MEDIA_CONTROLS,PRIM_MEDIA_CONTROLS_STANDARD,PRIM_MEDIA_CURRENT_URL,URL,PRIM_MEDIA_AUTO_PLAY,TRUE]);
36 } else {
37 llSetText("Text 2 Long",<1,0,0>,1.0);
38 }
39 }
40
41 on_rez(integer start_param) {
42 // Restarts the script every time the object is rezzed
44 }
45
46 }