6

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

Eugenio
  • 3,195
  • 5
  • 33
  • 49
  • I'm trying to answer to my question: can that API be used just via a chrome app and not via a web page? Is this the reason? If yes, which is the best solution to get the same result, is a call to http://translate.google.com/translate_tts?... ? Has this solution any limit? Thanks – Eugenio May 23 '13 at 17:55

4 Answers4

10

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

Don McCurdy
  • 10,975
  • 2
  • 37
  • 75
  • 2
    Thanks for the answer; even in this case, however, the quality is not comparable with the google translate's one. Maybe it needs some tuning, I don't know. – Eugenio Jun 16 '14 at 12:39
  • is it possible to save the output from the chrome extension or Javascript as a file.. like mp3 or wav? – supersan Jun 27 '15 at 06:40
  • I have no sound output in google chrome for Windows. It only works on Android. – user2284570 Jan 27 '17 at 22:36
  • Works for me on windows: ([JSFIDDLE](https://jsfiddle.net/jgoemat/pqvr60sL/1/)). You can change the voice too, the default one didn't sound great to me. – Jason Goemaat May 10 '17 at 03:07
1

. . 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.

diego nunes
  • 2,750
  • 1
  • 14
  • 16
  • Thanks for the answer, that's what I thought; client-side synthesizer like speak.js, however, provide a quality which is not even comparable with the google translate's one. – Eugenio Aug 29 '13 at 09:15
  • I did some tests and found out exactly the same: they are currently in completely different quality categories, specially in other languages (I am a native-Brazilian Portuguese speaker and it's below "usable"). – diego nunes Sep 08 '13 at 20:01
1

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);
Limon Monte
  • 52,539
  • 45
  • 182
  • 213
1

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.

Avatar
  • 14,622
  • 9
  • 119
  • 198