Warning: Declaration of ThemeSwitcherWidget::update($new_instance) should be compatible with WP_Widget::update($new_instance, $old_instance) in /home/kingston/hitormiss/wp-content/plugins/theme-switcher/theme-switcher.php on line 0
Voice Blogging with 1-800-555-TELL

Hit or Miss

Voice Blogging with 1-800-555-TELL

$filen”; $x = 1; foreach ($array as $line) { $linenum = str_pad($x, 3, “0”, STR_PAD_LEFT); $line = htmlentities($line); $line = eregi_replace(“t”, ”  “, $line); print “$linenum: $line”; $x++; } print “

nn”;
}
?>
If you’re looking for info on how to code Voice-XML applications using TellMe Studio, check out their tutorials.

I whipped this thing up in a hurry, so please let me know if you see any errors or don’t understand parts of the tutorial.

  • Part 1: Introduction
  • Part 2: File – menu.php
  • Part 3: File – record_entry.php
  • Part 4: File – upload_entry.php
  • Part 5: File – record_comment.php
  • Part 6: File – upload_comment.php
  • Part 7: Sign up for a developer account with TellMe.com
  • Part 8: Troubleshooting / Further work to be done / Conclusion

Part 1: Introduction

Inspired by the advent of telephone blogging made possible by the commercial tool Audblog, I cooked up the following tutorial to show how you can use free tools to enable posting sound entries to your weblog via phone (and allowing your readers to leave voice comments on your weblog).

What makes this setup different from Audblog is that the sound files are saved to your own webserver. TellMe will save the audio in a small u-law .wav file (I’m currently working on a way to turn these into even smaller .mp3 files).

Requirements:
An account on a webserver running PHP or a comparable scripting language. Using the scripts below will require a little bit of customization to your specific server environment. My scripts, written in PHP, are based on sample code from TellMe’s website; but the page also has examples in Perl and ASP, so competent programmers should be able to easily adapt my code to other languages.

Additionally, you will probably need shell access to your account on the server so you can set file permissions for directories, etc.

What this tutorial does not provide:
I have not included specific code for the actual posting of entries / comments to weblogs — there are too many different systems out there and I myself use a completely proprietary homegrown CMS. However, many weblog tools allow for entries to be posted via the MetaWeblog XML-RPC API — if anybody adapts these scripts to use that API, I’d be happy to link them or include them below.

If these scripts are too complicated for you, check out PhoneBlogger — the code (written in Python) hasn’t been released yet, but you may find that it would be a better match with your server environment.

Part 2: File – menu.php

Note: to copy each script without the line numbers, click on the link at the top of each code section.

First of all, you’ll want to create a subdirectory to hold all these scripts. Since the file below will include your “secret word” for creating voice entries, you’ll want to make this a subdirectory that no one will accidentally stumble upon…

The purpose of menu.php is to provide a menu to your telephone blog portal (I actually have a welcome.php that is played before my menu.php which welcomes people to my audio weblog). It is relatively easy to add other items to this menu pointing to other scripts — on my menu, for example, I allow people to listen to the last 5 entries in my weblog or what is playing on my TiVo

If you don’t want to allow listeners to record comments for your weblog, you’ll want to remove the “comments” menu choice on line 18 (and take out the mentions of “comments”).

On line 19 is the menu choice for recording a weblog entry. You want to choose your own “secret word” (which is not offered up as a spoken menu choice so no one can record an entry except those who know the secret word). The TellMe voice recognition system is not perfect, so you might want to spell your secret word out phonetically.

To customize what is spoken by the TellMe computer, edit the text between the <audio></audio> tags.

If you have a web browser capable of displaying XML, you can point your browser to the URL of this script and see the output.

Part 3: File – record_entry.php

This script is called by menu.php when the phone caller says the “secret word.”

The only thing you’ll really need to change in this script is the URL of upload_entry.php in line 97. You can also set the maximum length of the audio entry (in seconds) in line 18.

Basically the script prompts the listener to record an entry at the tone (and # when finished). Then, it gives the listener the opportunity to post the entry, save the sound file without posting to the weblog, rerecord the entry, or cancel and return to the menu.

Part 4: File – upload_entry.php

This is where the real heavy lifting of the voice blogging system is done.

You will want to create a subdirectory to hold your Voice entry .wav files. Since this will be a directory accessed by your weblog readers, do not make this a subdirectory of the directory holding these scripts. Make sure to set the file permissions on the voice entry subdirectory so that .wav files can be written to it.

In line 20, you’ll want to see $wavpath to point to the subdirectory where your .wav files will go.

Around line 31 is where you’ll want to add code to post an entry to your weblog pointing to the .wav file.

If you want an email announcement each time a voice entry is created, set the email address in line 40 (otherwise, you can remove lines 38-40.

The previous 3 scripts are all that are required to enable to posting voice entries to your weblog. If you don’t want to enable readers to post voice comments, you can skip ahead to Part 7.

Part 5: File – record_comment.php

If you would like your readers to be able to post voice comments to your weblog, use the following two scripts. Given the variety of different weblog commenting systems, you may or may not be able to implement this. If you can’t set up commenting on specific weblog entries, you can also just set up general commenting so your readers can leave you messages like on a voice mail system (tweak the code below and remove lines 21-45).

After this script is called by menu.php, it prompts the listener to enter 0 (to leave a general comment) or enter a specific weblog entry number to attach the comment to (check out my comments section to see an example of language explaining to a reader how to leave a voice comment on my weblog).

Again, like in record_entry.php, you want to specific the URL of upload_comment.php in line 97. You can edit the maximum length of a recorded comment in line 50.

Part 6: File – upload_comment.php

You will want to create a subdirectory to hold your Voice comment .wav files. Since this will be a directory accessed by your weblog readers, do not make this a subdirectory of the directory holding these scripts. Make sure to set the file permissions on the voice comment subdirectory so that .wav files can be written to it.

In line 32, you’ll want to see $wavpath to point to the subdirectory where your .wav files will go.

Around line 43 is where you’ll want to add code to post an entry to your weblog pointing to the .wav file.

If you want an email announcement each time a voice entry is created, set the email address in line 52 (otherwise, you can remove lines 50-52.

Part 7: Sign for a developer account with TellMe.com

The next step is to register for a “TellMe Studio” developer account at studio.tellme.com. You must choose a 5 digit number (one not already being used) to be your extension number — I recommend trying your zip code to help you remember the number.

After you get the scripts above up and running on your server, you will want to log into TellMe Studio and go to “My Extensions.” Enter “Extension URL” to the URL of the menu.php file (or to welcome.php if you use one). Make sure that “Enable my Extension” is checked.

Then you should be in business. You will be able to call 1-800-555-Tell, say “Extensions,” enter your extension number, and then hear your weblog menu read to you.

You can check that each of the scripts above validate as VXML 2.0 by pasting each script’s URL in “My Studio” and then clicking on “check syntax.”

Part 8: Troubleshooting / Further work to be done / Conclusion

Troubleshooting:
The only real problem I ran into when writing these scripts was dealing with the directory permissions on my server for writing the .wav files (and it was difficult to tell that without looking at my webserver’s error logs). If you get errors while running the scripts, directory permissions are the likely culprit.

Further work to be done:
As I said before, I would like to a) come up with a way to convert the .wav files into .mp3 files and b) come up with code to post entries to the weblog using the Meta Weblog XML-RPX API. Suggestions for these two tasks are welcome.

Conclusion:
This may not be the most elegant solution to posting voice entries (and comments) to your weblog, but the level of customization available and the price — free! — is hard to beat.

4 responses so far (Respond)

Gravatar

very nice
I would like to create a web app, where the user enters a report, the details are guided by a menu, and save the entries as audio but also as text entries in databases – has this been done ?
I would like to look into this

Eckhart

eckhart | 30 Mar 2005
Gravatar

Extensions seems to have been disabled.

Jonathan | 5 Apr 2005
Gravatar

Hi there,
just want to know whether it is possible to record any comment using the micophone, through PHP?? Is there code available for that?

Sincerely,
shiva

shiva | 6 May 2005
Gravatar

Extensions seems to have been disabled.

Jonathan | 4 Nov 2009