Reference documentation and code samples for the Cloud Text-to-Speech V1 API module Google::Cloud::TextToSpeech::V1::AudioEncoding.
Configuration to set up audio encoder. The encoding determines the output
audio format that we'd like.
Constants
AUDIO_ENCODING_UNSPECIFIED
value: 0 Not specified. Only used by GenerateVoiceCloningKey. Otherwise, will return
result
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
LINEAR16
value: 1 Uncompressed 16-bit signed little-endian samples (Linear PCM).
Audio content returned as LINEAR16 also contains a WAV header.
MP3
value: 2 MP3 audio at 32kbps.
OGG_OPUS
value: 3 Opus encoded audio wrapped in an ogg container. The result is a
file which can be played natively on Android, and in browsers (at least
Chrome and Firefox). The quality of the encoding is considerably higher
than MP3 while using approximately the same bitrate.
MULAW
value: 5 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
Audio content returned as MULAW also contains a WAV header.
ALAW
value: 6 8-bit samples that compand 14-bit audio samples using G.711 PCMU/A-law.
Audio content returned as ALAW also contains a WAV header.
PCM
value: 7 Uncompressed 16-bit signed little-endian samples (Linear PCM).
Note that as opposed to LINEAR16, audio won't be wrapped in a WAV (or
any other) header.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Cloud Text-to-Speech V1 API - Module Google::Cloud::TextToSpeech::V1::AudioEncoding (v1.9.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.9.0 (latest)](/ruby/docs/reference/google-cloud-text_to_speech-v1/latest/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.8.1](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.8.1/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.7.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.7.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.6.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.6.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.5.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.5.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.4.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.4.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.3.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.3.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.2.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.2.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.1.1](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.1.1/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [1.0.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/1.0.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.13.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.13.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.12.2](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.12.2/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.11.1](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.11.1/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.10.1](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.10.1/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.9.1](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.9.1/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.8.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.8.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.7.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.7.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.6.0](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.6.0/Google-Cloud-TextToSpeech-V1-AudioEncoding)\n- [0.5.2](/ruby/docs/reference/google-cloud-text_to_speech-v1/0.5.2/Google-Cloud-TextToSpeech-V1-AudioEncoding) \nReference documentation and code samples for the Cloud Text-to-Speech V1 API module Google::Cloud::TextToSpeech::V1::AudioEncoding.\n\nConfiguration to set up audio encoder. The encoding determines the output\naudio format that we'd like.\n\nConstants\n---------\n\n### AUDIO_ENCODING_UNSPECIFIED\n\n**value:** 0 \nNot specified. Will return result\n\\[google.rpc.Code.INVALID_ARGUMENT\\]\\[google.rpc.Code.INVALID_ARGUMENT\\].\n\n### LINEAR16\n\n**value:** 1 \nUncompressed 16-bit signed little-endian samples (Linear PCM).\nAudio content returned as LINEAR16 also contains a WAV header.\n\n### MP3\n\n**value:** 2 \nMP3 audio at 32kbps.\n\n### OGG_OPUS\n\n**value:** 3 \nOpus encoded audio wrapped in an ogg container. The result is a\nfile which can be played natively on Android, and in browsers (at least\nChrome and Firefox). The quality of the encoding is considerably higher\nthan MP3 while using approximately the same bitrate.\n\n### MULAW\n\n**value:** 5 \n8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.\nAudio content returned as MULAW also contains a WAV header.\n\n### ALAW\n\n**value:** 6 \n8-bit samples that compand 14-bit audio samples using G.711 PCMU/A-law.\nAudio content returned as ALAW also contains a WAV header.\n\n### PCM\n\n**value:** 7 \nUncompressed 16-bit signed little-endian samples (Linear PCM).\nNote that as opposed to LINEAR16, audio won't be wrapped in a WAV (or\nany other) header."]]