Processing
 

SimpleCaptcha and wav playback

01/08/2012 11:42#1

lucho

Member

Joined at: 7 months ago

Post: 2

Thank: 0

Thanked: 0

Our client is using SimpleCaptcha. My understanding is that SimpleCaptcha is able to produce audio captchas in WAVE format (.wav). Later these CAPTCHA-s are played back using the HTML5 audio tag, something like this:

<audio controls="controls" autoplay>     <source src="captcha.wav" /> </audio> 

Of course this is not cross browser compatible and one of the reasons is the WAVE format. This link suggests that IE9 supports only MP3 while most other browsers are fine with OGG and WAVE. Further MP3 is a patented to... to Fraunhofer?

Note: our back-end is Java based.

My question is what is the best fallback that we may offer to clients that do not support either the WAVE format (e.g. IE9) or the HTML5 audio tag at all? Due to patent issues I guess that dynamic conversion to mp3 on server side is not an option. Further I do not know any java library that may do this... I have seen nice solutions like jPlayer but they say that "For cross-browser support, a format must be supplied that works in both HTML5 and Flash.", i.e. mp3, mp4. I didn't find any reliable flash based WAVE players too.

01/08/2012 19:28Top#2

drew010

Member

Joined at: 10 months ago

Post: 18

Thank: 0

Thanked: 0

With help from others in the community, I have created a Flash button that can stream WAV files from the server to the client. It is distributed with Securimage PHP Captcha for streaming audio CAPTCHAs to the client.

You could simply take this Flash button, or download and modify the Flash source code to create your own custom one based on the same code.

You could use it as a fallback for when HTML5 audio isn't available.

Example usage would be:

<object type="application/x-shockwave-flash"         data="securimage_play.swf?audio_file=/PATH/TO/AUDIO.wav"         width="32" height="32">     <param name="movie" value="securimage_play.swf?audio_file=/PATH/TO/AUDIO.wav" /> </object> 

You can pass these additional options to securimage_play.swf:

  • bgcol: background-color of the Flash button
  • icon_file: URL to a png image to display as the icon on the Flash button

On a side note, I do find Microsoft's decision to not support WAV audio in the <audio> tag strange, especially since they pioneered WAV format with IBM. Yes WAV files are bigger than the other compressed audio formats they support, but bandwidth is also increasing to the point where it doesn't matter.

Hope that helps. Let me know if you try to implement it and have any questions. You can see a demo of the audio streaming here.

14/03/2013 17:50Top#3

Joined at: 6 months ago

Post: 1

Thank: 0

Thanked: 0

I think the help of @drew010 with their button was awesome!! Thank you.

To solve the same problem with rate frequency support between SimpleCaptcha (16000Hz) and supported audio for flash player (11025Hz) I've used an alternative solution instead change simplecaptcha source or try solve it at flash programming.

My captcha implementation has a custom audio captcha servlet (as supported by simplecaptcha), so I used the tip provided by @Claude in this post using tritonus lib to convert audio sample rate. The piece of code looks like that:

    AudioFormat outDataFormat = new AudioFormat((float) 11025.0, (int) 16, (int) 1, true, false);     AudioInputStream lowResAIS = AudioSystem.getAudioInputStream(outDataFormat, audioCapthca.getChallenge().getAudioInputStream()); 

My captcha servlet code below:

public class AudioCaptchaServlet extends HttpServlet {      @Override protected void doGet(HttpServletRequest req,             HttpServletResponse resp) throws ServletException, IOException {          Map<Integer, String[]> voicesMap = new HashMap<Integer, String[]>();         String[] fileLocs0 = {"/captcha/pt_BR/0.wav"};         String[] fileLocs9 = {"/captcha/pt_BR/1.wav"};         (...)          voicesMap.put(0, fileLocs0);         voicesMap.put(1, fileLocs1);         (...)          VoiceProducer voiceProducer = new RandomNumberVoiceProducer(voicesMap);          AudioCaptcha ac = new AudioCaptcha.Builder()             .addAnswer()             .addNoise()             .addVoice(voiceProducer)             .build();          req.getSession().setAttribute(AudioCaptcha.NAME, ac.getAnswer());          //Converte Sons com bitrate de 16000Hz (simplecaptcha) para 11025Hz (suportada pelo flash player)         AudioFormat outDataFormat = new AudioFormat((float) 11025.0, (int) 16, (int) 1, true, false);         AudioInputStream lowResAIS = AudioSystem.getAudioInputStream(outDataFormat, ac.getChallenge().getAudioInputStream());          CaptchaServletUtil.writeAudio(resp, new Sample(lowResAIS));     }      @Override protected void doPost(HttpServletRequest req,             HttpServletResponse resp) throws ServletException, IOException {         doGet(req, resp);     } } 
18/02/2016 10:16Top#4

Joined at: 6 months ago

Post: 1

Thank: 0

Thanked: 0

If any one still looking for It. Here is my code. It worked in all browsers for me.

<audio controls id="audioCaptcha">     <source src="audio.wav" type='audio/wav' height="50px" width="100px"/>     <embed src="audio.wav" type='audio/wav' autoplay="false" height="50px" width="100px"/> </audio> 
Similar articles

Open a folder in finder/explorer from a webpage?

5 years ago - Reply: 2 - Views: 80

How do I escape a reserved word in Actionscript?

5 years ago - Reply: 2 - Views: 198

Save PPS/PPT files as SWF using C#

5 years ago - Reply: 2 - Views: 171

Ways of making a graphic/visual novel in flash

6 years ago - Reply: 3 - Views: 114

Use PhoneGap + HTML5 and an Embedded Flash Movie

5 years ago - Reply: 2 - Views: 96

View word docs and PDF in browser?

5 years ago - Reply: 2 - Views: 52

ActionScript 3 Read JPEG quality

7 years ago - Reply: 2 - Views: 59

Export/Test Movie Issues

5 years ago - Reply: 3 - Views: 38

Flash always on top in Android browser workaround?

5 years ago - Reply: 2 - Views: 149

Sending Json Form from Flash AS3

5 years ago - Reply: 2 - Views: 29

parsing a swf/fla (using php?)

6 years ago - Reply: 2 - Views: 44

Getting high FPS on Flash/AIR games for mobile?

4 years ago - Reply: 2 - Views: 58

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re