...

View Full Version : Playing Certain Audio Files using Javascript (Or Possibly PHP)



rjromero
06-10-2010, 08:15 AM
I want to use HTML5's audio coding similar to the one below:



var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'horse.ogg');
audioElement.play();


In order to play sound files depending on the input. What I'm working on is a text-to-speech webapplication.

What I'd need to happen is for there to be an input and then allow the user to type anything into the input, so if they type in:

Hello, how are you doing?

Javascript or PHP will recognize each character and translate it into an audio sequence.

In example:

It'd detect the "H" in hello and play sound file "H.ogg"
It'd then detect the "E" in hello and play sound file "E.ogg"

I know there must be an easy way to do this.

Dormilich
06-10-2010, 02:27 PM
something simple like audioElement.setAttribute('src', input.value + '.ogg'); ?

rjromero
06-10-2010, 07:51 PM
something simple like audioElement.setAttribute('src', input.value + '.ogg'); ?

Yep, something similar to that, I just need the input to be dissected, if you will, into characters that it can recognize, so that:

Bob can be read by the Javascript as B-o-b

Dormilich
06-10-2010, 07:54 PM
that should be possible, but you’ll run into another problem, that’s far more complicated.

consider the following words:

cut
cute
chute
quit
quite
quiet



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum