1

I have a code that generates a captcha image from random characters in Java and returns to the HTML form where it is displayed. But I want to add sound clip as well to the image for the people who are visually impaired.

Can anyone help me with any tutorial or example or something they have themselves come up with?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Nick Div
  • 5,338
  • 12
  • 65
  • 127

1 Answers1

1

For the server-side, you might have a servlet that generates the sound using javax.sound.sampled (for concatenating pre-recorded parts for the letters and numbers). See Concatenating or mixing audio files for working source.

Unless you explicitly intend to use an applet (which I do not advise) then the client-side of this is not really related to Java.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • like suppose i have a random string generated "abcd" so i want the audio to say "a","b","c" and den "d" individually. I dont want the string to be recognized as a word and then converted to audio. I hope i am able to explain myself. And I dont want to use FreeTTS because that is something I wont understand with regards to code. – Nick Div Nov 11 '12 at 08:57
  • *"I dont want the string to be recognized as a word and then converted to audio."* I think by that you simply mean you want "cat" 'spelled out' like "see-ay-tee" rather than 'spoken' like 'cat'. OK - that would be pretty simple using pre-recorded sounds for the letters and digits, and JavaSound. – Andrew Thompson Nov 11 '12 at 09:03
  • Yes exactly! But is there any tutorial for that or a sample code that I can use. – Nick Div Nov 11 '12 at 09:23
  • Glad you got it sorted. :) I just then added a link to an example. – Andrew Thompson Nov 11 '12 at 09:28
  • Is there a link where I can learn how to get those pre-recorded sounds using java.sound. I mean respective sounds of the characters my code generates and then their concatenation? And thanks for the help. – Nick Div Nov 11 '12 at 09:33
  • I would record the letters using JavaSound. Look around that same site for examples of how to record. – Andrew Thompson Nov 11 '12 at 09:37
  • Oh okie, I will go through it. Thanks a lot. :) – Nick Div Nov 11 '12 at 09:39
  • Hi Andrew I tried to use the code given on the link that you gave me. And it compiles without any errors but the output audio file generated after the concatenation doesn't work. I mean it doesn't play at all. No player is able to play it. There is something wrong with the way of concatenation. This is the code that I have written http://stackoverflow.com/questions/13381862/concatenation-of-two-wav-files-failed I just hope that you will be able to crack the solution. – Nick Div Nov 14 '12 at 19:04