8 kHz
Use L16 or μ-law for inbound audio. Use L16 or μ-law for outbound playback.
16 kHz
Use L16 for inbound audio or outbound playback.
24 kHz
Use L16 for outbound playback only. Do not configure 24 kHz as the inbound Stream format.
Understand the two audio directions
Choose a sample rate
- Use μ-law at 8 kHz when your telephony or agent integration already works with G.711 μ-law.
- Use L16 at 8 kHz when your pipeline expects raw linear PCM at a telephony-oriented rate.
- Use L16 at 16 kHz when your STT or TTS service expects 16 kHz linear PCM.
- Use L16 at 24 kHz only for outbound playback when your TTS service produces genuine 24 kHz linear PCM.
A 24 kHz outbound payload does not guarantee 24 kHz audio at the handset. The carrier, SIP, or PSTN leg may use a lower-rate codec.
Configure inbound audio
Set the inbound format on the<Stream> element or the Audio Streams REST request.
The following XML requests inbound L16/16 kHz audio and enables outbound playback:
start.mediaFormat:
streamId for commands that you send to Vobiz. Decode every inbound media.payload using start.mediaFormat instead of assuming a rate in your application.
Send outbound audio
Setbidirectional="true" on <Stream>, then send a playAudio event. The event must describe the actual encoding and sample rate of its payload.
- L16 at 8 kHz
- L16 at 16 kHz
- L16 at 24 kHz
- μ-law at 8 kHz
Prepare the payload
Before you Base64 encode audio forplayAudio:
- Use raw mono audio.
- Remove WAV, MP3, and other file-container headers.
- For L16, use signed 16-bit samples.
- Generate or resample the audio at the rate declared in
media.sampleRate. - Do not change only the JSON sample rate. That does not resample the payload.
After the final
playAudio chunk for an utterance, send a checkpoint. Vobiz sends playedStream when playback reaches that checkpoint. Use clearAudio to discard queued playback when the caller interrupts.