Wavefile
(Created page with "This module can be used either to play or record wave files. From a routing module you can play a wave file like this: ^1$=wave/play//path/to/file/audiotoplay.slin If you...") |
Revision as of 10:49, 8 October 2012
This module can be used either to play or record wave files.
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
To record a wave file you can use this:
^1$=wave/record//path/to/file/audiorecorded.slin
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 (16-bit signed linear)
- .alaw (G.711a)
- .mulaw (G.711u)
- .gsm (GSM 06.10)
- .au
- .lbc .ilbc20 .ilbc30 (ILBC)
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