Channels ▼

Web Development

Implementing Audio CAPTCHA

Source Code Accompanies This Article. Download It Now.

Sound Advice

People who are sight challenged would naturally be an audience for an audio CAPTCHA. With this in mind, any audio CAPTCHA implementation should be constructed such that it's easy to use by people who use a screen reader.

You can test how well your audio CAPTCHA works for someone who is using a screen reader by using the "Microsoft Narrator" that comes with Windows. You turn this feature on in Windows XP by selecting Start|All Programs|Accessories|Accessibility|Narrator.

Any instructions that go with your CAPTCHA should be concise. Someone using a screen reader isn't going to want to have it reread some overly verbose instructions.

The implementation I present here can be used without employing the mouse at all. This feature is especially handy for someone using screen readers. I ask users to type a particular key to start the audio. Then once the audio has started, I move the focus to the proper text box and submit for validation upon getting the Enter key.

When implementing an audio CAPTCHA, it is still necessary to disguise the challenge in some way from robots. However, there are ways to deceive these machines that are much less intrusive and easier for a human to deal with than using pictures of distorted letters.

Some audio CAPTCHAs currently in use attempt to foil audio deciphering robots by obscuring the audio. To me, this defeats some of the purpose. Like the aforementioned swirling syllables, when you obscure audio, you make it harder for humans to understand as well as any mechanical facsimiles.

Instead of adding background noises or any similar muddiness to the sound, try adding some simple aural logic that a machine would find difficult to parse. In my implementation, I ask for four numbers. The challenge starts with a simple instruction "Please enter these four numbers...," then speaks the four random numbers (Figure 2). Available at is a series of MP3 audio files for the numbers 0-9.

Figure 2: The Simple UI.

A nice addition, that should help to obscure the challenge from robots, would be to randomly include a phrase between two of the numbers like, "not 7, but instead a." So, for example, instead of hearing, "Please enter these four numbers—4,3,6,2," the user hears "Please enter these four numbers—4,3,6, not 7 but instead 2".

Naturally, in this example you would have to add logic to ensure that the fourth number asked for was not a 7. Other methods might include simply adding phrases like "and a," "then press Enter," and so on. The idea here is to add just enough audio to fool the robots without confusing or frustrating users.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.