Set the output audio format
output_audio_codec sets the format of the generated audio. It affects file size, quality and which players or telephony stacks can read the output.
The default depends on the API:
opus only works at sample rates 8000, 16000, 24000 (and 48000 on REST). At the default 22050 Hz the request fails, so set speech_sample_rate when you use it.
Example
For HTTP streaming, send the same field to /text-to-speech/stream and write the response body directly (no base64 decoding). For WebSocket, put it in the config message; see the WebSocket TTS page.
What changes in the output
- The file contents and
content_typefollow the codec. Use a matching file extension when saving. mulawandalaware typically used with"speech_sample_rate": 8000for telephony.- On HTTP streaming and WebSocket,
output_audio_bitratesets the bitrate, see bitrate.