How to use the TTS audioContent Encoder tool
- Select Audio file and choose a file up to 20 MiB. The picker filters for audio types.
- Select Build JSON to encode the audio.
- Check the Result box, which shows an object with a single audioContent property.
- Copy the JSON, or use the Download link to keep it as payload.json for your tests.
Why build an audioContent response by hand
Code that calls a speech API has a path that is easy to get wrong and tedious to test live: read audioContent, decode Base64, write or play the audio. Every live test costs a request and may return slightly different data. A fixed response file removes both problems. Record or pick one audio clip, encode it here and return the JSON from a stub, a mock server or a unit test fixture.
The same file is useful for front-end work. A player component can be developed against a canned response long before credentials and quotas for the real service are sorted out.
How the TTS audioContent encoder builds the JSON
The tool reads the whole file into memory, encodes every byte as standard Base64 on a single line with padding, and places the string in an object under audioContent. The object is printed with two-space indentation. No data URL prefix is added and no other fields are written.
For a file containing only the 5 bytes of the word Hello, the output is the object below. A real clip produces the same shape with a much longer string.
{
"audioContent": "SGVsbG8="
}Input rules and limits
The encoder treats the file as opaque bytes, which keeps it simple and has a few consequences.
- The file dialog filters for audio types, but the content is not verified. Any bytes you manage to select are encoded.
- The limit is 20 MiB. Larger files, or running without a file, give Choose a file up to 20 MiB.
- Nothing is transcoded. An MP3 stays MP3 and a WAV keeps its header.
- The JSON does not record the format, sample rate or file name, because the response shape has no fields for them.
Matching the encoding your code expects
A realistic fixture uses the same container the live API would return for your request settings. If production asks for MP3, encode an MP3 file. If it asks for 16-bit linear PCM, use a WAV file, since services in this style include the WAV header in that mode. If your client expects headerless PCM from a different API, strip the header first with WAV to PCM Base64 and build the JSON around that string yourself.
Keep fixtures short. A one-second clip is enough to exercise decoding, and it keeps test files and diffs small.
Frequently asked questions
How large is the JSON compared with the audio file?
About one third larger. Base64 writes 4 characters for every 3 bytes, and the wrapper adds roughly 25 characters. A 300 KB MP3 becomes a payload of about 400 KB.
Can I encode a file that is not audio?
Technically yes, because the bytes are not inspected, but the result is only meaningful as a speech response if the content is audio. For general files, the Webhook Base64 File Encoder also records the file name and media type.
Does this tool generate speech from text?
No. It does not synthesize anything and does not contact a speech service. It packages an audio file you already have into the JSON shape such services return.
How do I check that the JSON is correct?
Paste it into the TTS audioContent Decoder, choose the matching Audio type and play the preview. If the clip sounds like your source file, the encoding is intact.
Is my audio file uploaded?
No. The file is read with the browser's File API and encoded on your device. The page sends neither the audio nor the resulting JSON anywhere.
Can I send this JSON as a speech recognition request?
Not as is. Recognition requests usually nest the audio under a different field together with a configuration object. You can copy the Base64 string out of audioContent and place it in the structure that API documents.