Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2010
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Playing Certain Audio Files using Javascript (Or Possibly PHP)

    I want to use HTML5's audio coding similar to the one below:

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

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,281
    Thanks
    12
    Thanked 343 Times in 339 Posts
    something simple like audioElement.setAttribute('src', input.value + '.ogg'); ?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New Coder
    Join Date
    May 2010
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    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

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,281
    Thanks
    12
    Thanked 343 Times in 339 Posts
    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
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •