Py Session RecordFile

From FreeSWITCH Wiki
Jump to: navigation, search

Records audio data to a file.

Contents

Synopsis

recordFile(filename, <[max_len]>, <[silence_threshold]>, <[silence_secs]>)

arguments

  • filename - Full path to filename to write.
  • max_len - maximum length of the recording in seconds.
  • silence_threshold - energy level audio must fall below to be considered silence (500 is a good starting point).
  • silence_secs - seconds of silence to interrupt the record.

Returns

Will return anything returned by the callback function, or true/false if no callback is used.

Note: the file must contain an extension known to freeswitch so it can determine the filetype to write. Freeswitch will abort the script if the extension is not provided.

callback_function

A callback function can be used to process DTMF signals that are pressed during the recording. You can use them to abort the recording.

The callback function must be set by setDTMFCallback and should return "stop" in order to stop the recording.

Variables

NOTE: not tested with Python, though they should work.

You can specify a number of variables that will be used when saving the file. The variables must be set by using session.setVariable. The variables that can be set are:

  • RECORD_TITLE
  • RECORD_COPYRIGHT
  • RECORD_SOFTWARE
  • RECORD_ARTIST
  • RECORD_COMMENT
  • RECORD_DATE

Example

rtn = session.recordFile("\tmp\recording.wav", 240, 500, 3);