Pergunta

I'm trying the chrome text-to-speech API but even the demo provided by google https://developer.chrome.com/trunk/extensions/examples/extensions/ttsdemo/ttsdemo.html doesn't work for me, I can't hear any sound, do you?

I don't think it is a problem of my browser because google.translate.com (which I guess is based on the same technology) works for me if I try the listening mode.

Any idea?

Thanks

Foi útil?

Solução 2

. . Hi, Eugenio.

. . This API is only available for extensions. You can port your logic to inside an extension (people would have to install it to use, of course), create an extension that exposes the functions to the "outside world" (people would still need to install the extension to use your app correctly) or simply use a client-side synthesizer (speak.js, for example).

. . You can use WebAudio API (or event tags) and calls to the Google Translate TTS endpoint, but that's not a Public API and it has no guarantees. It can simply stop working because of some limitation from Google, they can change the API or endpoints and yadda yadda. If it's only for testing, that'll probably do, but if it's a bigger project (or a comercial one), I strongly advise against that option.

. . Good luck.

Outras dicas

As of Chrome 33, Chrome's speech synthesis API is available in JavaScript.

Quick example:

window.speechSynthesis.speak(
   new SpeechSynthesisUtterance('Oh why hello there.')
);

Details:

HTML5 Rocks: Introduction to the Speech Synthesis API

Today (October 2015) there's 55% devices that have Speech Synthesis API support: http://caniuse.com/#feat=speech-synthesis

Here's the example:

// Create the utterance object
var utterance = new SpeechSynthesisUtterance();
utterance.text = 'Hello, World!';

// optional parameters
utterance.lang = 'en-GB'; // language, default is 'en-US'
utterance.volume = 0.5;   // volume, from 0 to 1, default is 1
utterance.rate = 0.8;     // speaking rate, default is 1 

// speak it!
window.speechSynthesis.speak(utterance);

Just to add some links because I also was lost finding the right information.

You can use the so called "speech synthesis api" of Chrome, see demo: https://www.audero.it/demo/speech-synthesis-api-demo.html

Further info:

Hope that helps, and hope the links will survive the future.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top