Using a previous SO answer I've integrated TTS into a website here: http://access.mwjt.co.uk/feedback/tts.php
Works fine in Chrome, but not in any other browser - can anyone shed any light on why please?
I've put the code into a fiddle here: http://jsfiddle.net/Mje3n/ however, this isn't working on any b开发者_如何学Gorowser...???
Many thanks
Clicking on the button in the page gives me a 404 error (file not found) coming back from the Google service in Firefox and Safari, so the main reason you're not hearing anything is that you're not getting a response. Interesting thing, though, is if I put your URL to the Google service in a we browser the audio file does come back. I then went over to Chrome to see what its network response looked like and saw that it was also returning a 404 error, but would make a second attempt to load the file. This is why it is working in Chrome and not in other web browsers.
I tried a very, very basic example linking directly like it was an audio file but this also fails in most web browsers since the 404 response comes back as the first reply and the browser gives up loading the file.
Google returned this jQuery plugin example but, too, has crossbrowser issues playing the audio even though it uses Flash to load the MP3s from the Google service. If you want to do this, you may need to employ an additional service or Flash intermediary to get the MP3/audio file to work.
The other thing to consider there is that this may not work in all web browsers just because different browsers behave differently. Not all browsers support HTML5 and need different
Though this doesn't help answer the question, there is some additional info you should probably consider. You may want to consider using the Microsoft translator service instead of the Google one. From the jquery-translate page on Google Code:
Since the Google Translate API will be shut off completely on December 1, 2011 this plugin will use the Microsoft Translator service
Also, from the Google Translate v2 Homepage:
Important: Google Translate API v2 is now available as a paid service. The courtesy limit for existing Translate API v2 projects created prior to August 24, 2011 will be reduced to zero on Dec 1, 2011. In addition, the number of requests your application can make per day will be limited. For website translations, we encourage you to use the Google Website Translator gadget.
I can't be 100% sure this effects the Text to Speech (TTS) services but it does strongly suggest this. And it may get a reprieve, but if the deadlines are stated I wouldn't build an application or a website that relied upon the service knowing it is probably going away.
In the documentation for the Microsoft Translator there is an example for linking to a .wav file from the Speech portion of the service.
I hope that all this info is helpful in making a decision on how to go forward, and good luck with your project.
精彩评论