• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
        • Audio Statement
        • Audio.load Function
        • Audio.save Function
        • Audio.play Function
        • Audio.recordInteractive Function
        • Audio.record Function
        • Audio.stop Function
        • Audio.concat Function
        • Audio.length Function
        • Audio.clear Function
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Audio.recordInteractive Function

Format
d = audio_name.recordInteractive(ʃmessageʅ);
Description
The Audio.recordInteractive function launches an interactive audio recorder that stores a recording to an Audio object. When the function is called, the audio recorder screen is displayed. It contains record, save, and clear buttons that control the audio recording. If the optional string argument message is specified, the message will be displayed at the top of the recorder screen. The Audio.recordInteractive function does not return until the user has finished recording and taps the save button. This is useful for synchronous recording, for example to have the interviewer record the response to a single question. To record the audio in the background while the user continues to interact with the survey, use the function Audio.record.
The recorded audio is stored in the Audio object and can be played back using Audio.play or saved to a file using Audio.save. If the Audio object already contains an audio recording, the recorded audio will be appended to the existing recording. To replace the existing recording rather than adding to it, call the Audio.clear function before calling Audio.recordInteractive.
Recorded audio is stored in m4a format (AAC encoded in an MPEG-4 container). Files should be saved with the extension .m4a so that they will be recognized by media players.
Audio recording is only supported on Android. This function will do nothing on Windows.
Return Value
The function returns the length of the recorded audio in seconds (and fractional seconds) or default if there was an error during recording.
Example
PROC AUDIO_QUESTION

onfocus

   
// Variable to store the recording
    Audio recording;

   
// Save recording to a file that includes case id-items to differentiate it from
    // audio saved in other cases
    string nameOfAudioFile = maketext("%v%v%vAUDIO_QUESTION.m4a", PROVINCE, DISTRICT, EA);

   
// If no audio is recorded for this question then the only option is to record,
    // otherwise allow user to re-record, play or clear recording before continuing
    ValueSet vs;
   
if fileexist(nameOfAudioFile) and recording.load(nameOfAudioFile) then
        vs.
add("Re-record", 1);
        vs.
add("Play recording", 2);
        vs.
add("Clear recording", 3);
        vs.
add("Next question", 4);
   
else
        vs.
add("Record", 1);
   
endif;

   
setvalueset($, vs);

postproc

   
if $ = 1 then
       
// Record/re-record
        recording.clear();
       
string message = "Record the respondent's answer to this question";
       
numeric seconds = recording.recordInteractive(message);
       
if seconds > 0 then
            recording.
save(nameOfAudioFile);
       
else
           
errmsg("No audio recorded. Please try again");
       
endif;
       
reenter;
   
elseif $ = 2 then
       
// Play back recording
        recording.play();
       
reenter;
   
elseif $ = 3 then
       
// Clear the recording
        filedelete(nameOfAudioFile);
       
reenter;
   
elseif $ = 4 then
       
// Continue to next question
    endif;
See also: Audio Object, Audio.record Function