-
Need help playing sound on the client side
1) Script Title: Need help playing sound on the client side
2) Script URL (on DD): http://www.dynamicdrive.com/forums/n...=newthread&f=2
3) Describe problem: I'm designing a client to have a TTS (Text to Speech) feature. Once users input a string, the program will send that string to our TTS server and a stream of data will be returned. I know that javascript can play sound files, but I don't want to save the returned data into a file then play it. Can javascript play a stream or a byte array of pcm data?
Thanks for the help
Vin.
-
-
The "Dynamic Drive scripts help" section is for EXISTING scripts hosted in the Dynamic Drive library. I've moved this to the "Looking for a script or service" section because it fits here better.
This is not at all an easy question.
Javascript can *kinda* play sound files. It can in some browsers, it can't in others, and there is no good cross-browser way to play a single format. For example, you can just use html to include a "background sound" in internet explorer but that exists in no other browser.
I can't remember the details of what Javascript can do with sound, but it's only some browsers and very limited formats. midi and wav are likely.
You can use a plugin like a quicktime player or windows media player. This requires that the user have it installed AND that it actually exists/works for their browser/system. There is no fully compatible media plugin. For example, quicktime is probably the best but it doesn't work (due to lazy programming from apple, as far as I'm concerned) on windows 64bit processors-- the menu bar turns black and you can't see what you're doing. And all the rest are less compatible.
The ideal solution for this is to use Flash. It's a plugin, but a special one since it works in almost every browser (though: warning-- not on many mobile devices).
The big problem with flash though is that it must have mp3 audio and converting to mp3 dynamically is almost impossible (it's possible, but do anything you can to avoid going down that path-- it'll either be extremely expensive or very technically complex or both).
If you CAN get all of your files in mp3 then flash is wonderful and easy.
I don't know of any way that you can dynamically create a file and then play it back to the user. I'm working on this same problem and I've determined that the only (semi)sane way to do this is to use a flash media server and make things very complex.
Sorry I don't have more encouraging solutions for you.
You've found one of the big problems with web design: media [aside from images] is horribly supported in general.
One thing to consider is that if your goal is just to make this for some users, then you could target a browser such as Firefox or Internet Explorer (the two best choices-- they both have lots of sound options) and require your visitors to use it. This obviously only makes sense for a site that's not meant for the world to see, but rather for a local site or something for a special purpose. But if you can manage to restrict things like this, your job will be a lot easier.
Finally, if worst comes to worst, you can always just have the user download an audio clip and play it with the default player (which sometimes will even be a browser plugin for a player like quicktime or windows media player).
If you have a more specific direction you want to pursue ask and someone can probably give more advice.
Also search google for these various methods and you'll find lots of (confusing/mixed/vauge) information about the various options. You won't find a "good" option because there isn't one, but you may find one that works for your specific goals.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks