Decoding base64-encoded audio content

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, the Cloud 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 Cloud 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

  1. Copy only the base-64 encoded content into a text file.

  2. Decode the source text file using the base64 command line tool by using the -d flag:

    $ base64 source_base64_text_file -d > dest_audio_file

Mac OSX

  1. Copy only the base-64 encoded content into a text file.

  2. Decode the source text file using the base64 command line tool:

    $ base64 --decode source_base64_text_file > dest_audio_file

Windows

  1. Copy only the base-64 encoded content into a text file.

  2. Decode the source text file using the Base64.exe tool:

    C:> Base64.exe -d source_base64_text_file > dest_audio_file
Bu sayfayı yararlı buldunuz mu? Lütfen görüşünüzü bildirin:

Şunun hakkında geri bildirim gönderin...

Cloud Text-to-Speech Documentation
Yardım mı gerekiyor? Destek sayfamızı ziyaret edin.