-
-
Save gialloporpora/12811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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