Skip to content

Instantly share code, notes, and snippets.

@gialloporpora
Created September 25, 2008 12:55
Show Gist options
  • Save gialloporpora/12811 to your computer and use it in GitHub Desktop.
Save gialloporpora/12811 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "speak-it",
takes: {"text to speech": noun_arb_text},
icon: "http://text-to-speech.imtranslator.net/favicon.ico",
homepage: "http://www.gialloporpora.netsons.org/ubiquity",
author: { name: "Sandro Della Giustina", email: "sandrodll@yahoo.it"},
license: "MPL,GPL",
description: "Speak the selected text with a very goo voice",
help: "Speak correctly the selected text in correct language source.",
_detectlanguage: function(text){
var params={v: "1.0",q: text,langpair: "|en"};
var api_url = "http://ajax.googleapis.com/ajax/services/language/translate";
jQuery.ajax({
type: "GET",
url: api_url,
data: params,
datatype: "string",
error: function(){lang=null;},
success: function(data){
data = Utils.decodeJson(data);
lang=data.responseData.detectedSourceLanguage;
}
});
return lang;
},
preview: function(previewBlock,directObject){
lang=this._detectlanguage(directObject.text);
html="Read this text using the correct voice" ;
previewBlock.innerHTML=CmdUtils.renderTemplate(html);
},
execute: function(directObject){
lang=this._detectlanguage(directObject.text);
url="http://text-to-speech.imtranslator.net/speech.asp";
url+=Utils.paramsToString({
"url": "WMfl",
"dir": lang,
"text": directObject.text
});
Utils.openUrlInBrowser(url);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment