Decode base64-encoded audio content
Stay organized with collections
Save and categorize content based on your preferences.
Audio data is binary data. You can read the binary data directly from a gRPC
response; however, JSON is used when responding to a REST request. Because JSON
is a text format that does not directly support binary data,
Text-to-Speech returns a response string encoded in
Base64. You must convert the base64-encoded
text data from the response to binary before you can play it on a device.
JSON responses from the Text-to-Speech include base64-encoded audio
content in the audioContent
field. For example:
{
"audioContent": "//NExAARqoIIAAhEuWAAAGNmBGMY4EBcxvABAXBPmPIAF//yAuh9Tn5CEap3/o..."
}
To decode base64 into an audio file:
Linux
Copy only the base-64 encoded content into a text file.
Decode the source text file using the base64 command line tool
by using the -d
flag:
$ base64 SOURCE_BASE64_TEXT_FILE -d > DESTINATION_AUDIO_FILE
Mac OSX
Copy only the base-64 encoded content into a text file.
Decode the source text file using the base64 command line tool:
$ base64 --decode -i SOURCE_BASE64_TEXT_FILE > DESTINATION_AUDIO_FILE
Windows
Copy only the base-64 encoded content into a text file.
Decode the source text file using the
certutil
command.
certutil -decode SOURCE_BASE64_TEXT_FILE DESTINATION_AUDIO_FILE
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[[["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,["# Decode base64-encoded audio content\n\nAudio data is binary data. You can read the binary data directly from a gRPC\nresponse; however, JSON is used when responding to a REST request. Because JSON\nis a text format that does not directly support binary data,\nText-to-Speech returns a response string encoded in\n[Base64](https://en.wikipedia.org/wiki/Base64). You must convert the base64-encoded\ntext data from the response to binary before you can play it on a device.\n\nJSON responses from the Text-to-Speech include base64-encoded audio\ncontent in the `audioContent` field. For example: \n\n```json\n{\n \"audioContent\": \"//NExAARqoIIAAhEuWAAAGNmBGMY4EBcxvABAXBPmPIAF//yAuh9Tn5CEap3/o...\"\n}\n```\n\nTo decode base64 into an audio file: \n\n### Linux\n\n1. Copy only the base-64 encoded content into a text file.\n\n2. Decode the source text file using the base64 command line tool\n by using the `-d` flag:\n\n```bash\n $ base64 SOURCE_BASE64_TEXT_FILE -d \u003e DESTINATION_AUDIO_FILE\n```\n\n### Mac OSX\n\n1. Copy only the base-64 encoded content into a text file.\n\n2. Decode the source text file using the base64 command line tool:\n\n```bash\n $ base64 --decode -i SOURCE_BASE64_TEXT_FILE \u003e DESTINATION_AUDIO_FILE\n```\n\n### Windows\n\n1. Copy only the base-64 encoded content into a text file.\n\n2. Decode the source text file using the\n [`certutil`](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/certutil) command.\n\n```bash\n certutil -decode SOURCE_BASE64_TEXT_FILE DESTINATION_AUDIO_FILE\n```"]]