HAWHAW

PHP

Class HAW_voicerecorder

HAW_voicerecorder

public class HAW_voicerecorder

This class provides a voice recorder in a HAW_deck object.

Voice recording is feature for voice browsers only (VoiceXML). The recorded voice input will be sent encrypted as multipart/form-data to some other url, which normally will be another PHP/HAWHAW script. Here you can store the received data as .wav file on your server, play it to the user, or do whatever you want. Saving of the received voice data is similar to normal PHP file upload handling.

Voice recording is a very powerful feature which offers many oportunities to create high-sophisticated voice applications.

Examples:

$myRecorder = new HAW_voicerecorder("http://www.foo.com/script.php", "Please speak after the tone");

$myRecorder = new HAW_voicerecorder("http://www.foo.com/script.php", "You have 2 minutes from now");
$myRecorder->make_beep(false);
$myRecorder->set_maxtime(120);

// ... and in http://www.foo.com/script.php we store the received wav file like this:
move_uploaded_file($_FILES['haw_recording']['tmp_name'], "/voice/message.wav");

See Also:
HAW_deck

Constructor Summary
HAW_voicerecorder(var $url, var $label)
          Constructor
 
Method Summary
 void make_beep(var $beep_indicator)
          Activates/deactivates beep before recording starts.
 void set_finalsilence(var $finalsilence)
          Sets interval of silence that indicates end of speech.
 void set_maxtime(var $maxtime)
          Sets maximum duration of recording.
 void set_type(var $type)
          Sets media format of recording.
 void set_voice_noinput(var $text, var $audio_src, var $url)
          Sets noinput text for voice browsers.
 void set_voice_text(var $text, var $audio_src)
          Sets text to be spoken by voice browsers.
 

Constructor Detail

HAW_voicerecorder

public HAW_voicerecorder(var $url,
                         var $label)
Constructor
Parameters:
url - Address where the recorded file is sent to.
label - Some introducing words before the recording starts.
Method Detail

set_voice_text

public void set_voice_text(var $text,
                           var $audio_src)
Sets text to be spoken by voice browsers.
Parameters:
text - Some alternative text that replaces <label>.
audio_src - Some audio file (e.g. *.wav file) to play (optional).

set_voice_noinput

public void set_voice_noinput(var $text,
                              var $audio_src,
                              var $url)
Sets noinput text for voice browsers.
Parameters:
text - Some text to inform the user that no input has been received.
audio_src - Some audio file (e.g. *.wav file) to play (optional).
url - Some other voice deck to go to (optional).

make_beep

public void make_beep(var $beep_indicator)
Activates/deactivates beep before recording starts.
Parameters:
beep_indicator: - true (default) or false.

set_maxtime

public void set_maxtime(var $maxtime)
Sets maximum duration of recording.
Parameters:
maxtime - Duration of record in seconds

set_finalsilence

public void set_finalsilence(var $finalsilence)
Sets interval of silence that indicates end of speech.
Parameters:
finalsilence - Silence duration (in seconds)

set_type

public void set_type(var $type)
Sets media format of recording.
Parameters:
type - e.g. "audio/x-wav"

© Norbert Huffschmid
assembled from PHP source
using sed and javadoc