Wavefile
This module can be used either to play or record wave files.
Contents |
Play a wave file
From a routing module you can play a wave file like this:
^1$=wave/play//path/to/file/audiotoplay.slin
If you want to play a wave file without answering a call, add parameter autoprogress to the message like this:
^1$=wave/play//path/to/file/audiotoplay.slin;autoprogress=yes
Record a wave file
To record a wave file you can use this:
^1$=wave/record//path/to/file/audiorecorded.slin
Audio formats supported
The extension is important to both the play and record commands.
If the audio is being played, the extension indicates what format the file is in.
If audio is being recorded, the module will record in the specified format.
Currently the supported formats are:
- .slin (raw 16-bit signed linear)
- .alaw or .A (raw G.711a)
- .mulaw or .u (raw G.711u)
- .2slin .2alaw .2mulaw (stereo versions of the above, interlaced, left channel first)
- .gsm (raw GSM 06.10)
- .ilbc20 or .ilbc30 (raw ILBC with 20ms or 30ms sampling)
- .g729 (raw G.729)
- .au (G.711x or 16 bit signed linear with header)
- .lbc (iLBC 20 or 30 with specific header)
Configuration file
This module has no configuration file. All parameters are taken from the call message.
This module can also be attached to existing channels as described in the Dumbchan documentation.
Getting files into the right format
As noted above, this module plays a number of formats. ConvertingAudio has some examples which make help you get you source audio in a suitable format.
How to play the recorded files
You can use the "play" wrapper that is part of the SoX package. Command line parameters are required to provide data format information.
- .slin: play -t raw -r 8000 -s w -f s FILENAME
- .alaw or .al or .A: play -t raw -r 8000 -A -b 8 -c 1 FILENAME
- .mulaw or .ul or .u: play -t raw -r 8000 -s b -f U FILENAME
- .gsm: play -f g FILENAME
Examples
To record to a wave file from an external module do this:
%%>message:<id>:<time>:chan.attach::consumer=wave/record//sounds/test.al:notify=myid42:single=true:id=myid42
To stop the recording specified in the example above above do this:
%%>message:<id>:<time>:chan.attach::recordstop=true:consumer=wave/record/-:notify=myid42:single=true:id=myid42
To play the wave file recorded above do this:
%%>message:<id>:<time>:chan.attach::notify=myid42:single=true:id=myid42:source=wave/play//sounds/test.al
See also