Speech Recognition input format FAQ
This topic describes the audio input requirements for speech recognition services, how to check and convert audio formats, and how to troubleshoot incompatible input formats.
Supported audio formats
The actual encoding, sample rate, and channel count must meet the requirements of the service you call. Changing a file extension does not convert its audio format.
Service | Audio input requirements |
|---|---|
Short Speech Recognition |
|
Real-time Speech Recognition |
|
Audio File Transcription | Supports mono and dual-channel WAV, MP3, M4A, WMA, AAC, OGG, AMR, and FLAC files. File size must not exceed 512 MiB. |
Audio File Transcription (Offline Edition) | Supports mono and dual-channel WAV, MP3, M4A, WMA, AAC, OGG, AMR, and FLAC files. File size must not exceed 512 MiB. |
Audio File Transcription Express Edition |
|
Check the audio format
Check the following audio properties. For definitions, see Key concepts.
Sample rate: 8000 Hz (8 kHz) means 8,000 samples per second; 16000 Hz (16 kHz) means 16,000 samples per second.
Bit depth: 16 bit means that each sample is stored using 16 bits (2 bytes).
Channels: mono has one channel; stereo has two channels.
Linux
Run the following command to check a WAV file:
file input.wav
Example output for a 16 kHz, 16-bit, mono PCM-encoded WAV file:
input.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz
For an 8 kHz file, the corresponding output is:
input.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 8000 Hz
Raw PCM has no file header that describes its sample rate, bit depth, or channel count. Check the recording or export configuration to determine these properties.
Windows
Right-click the audio file, select Properties, and check the audio properties on the Details tab. This method applies to both 8 kHz and 16 kHz PCM-encoded WAV files.
Estimate PCM data size
Calculate the size of uncompressed PCM data as follows:
PCM data size (MiB) = sample rate (Hz) × bit depth (bits) × channel count × duration (seconds) ÷ (8 × 1024 × 1024)
For example, 60 seconds of 16 kHz, 16-bit, mono PCM data contains 1,920,000 bytes, or approximately 1.83 MiB. A WAV file also contains a container header and other information. This formula does not calculate the file size of compressed audio such as MP3 or AAC.
Convert the audio format
If the sample rate, bit depth, channel count, or encoding does not meet the input requirements, convert the audio to a supported format before calling the recognition service.
Linux (FFmpeg)
Download FFmpeg from the FFmpeg website. Replace the input filenames in the following examples with your actual filenames.
Check audio properties
ffmpeg -i input.mp3
This command displays input information without creating an output file.
Convert to PCM-encoded WAV
The following command converts a WAV file to 16 kHz, 16-bit, mono WAV. For an MP3, AMR, or 44.1 kHz WAV input, replace the input filename. To produce 8 kHz audio, change -ar 16000 to -ar 8000.
ffmpeg -i input.wav -ar 16000 -ac 1 -c:a pcm_s16le output.wav
Convert between raw PCM and WAV
For raw PCM input, specify the source audio properties before -i. The following example assumes 16 kHz, 16-bit, little-endian, mono PCM input. The parameters must match the actual data.
ffmpeg -f s16le -ar 16000 -ac 1 -i input.pcm -ar 16000 -ac 1 -c:a pcm_s16le output.wav
To convert WAV to 16 kHz, 16-bit, little-endian, mono raw PCM:
ffmpeg -i input.wav -ar 16000 -ac 1 -c:a pcm_s16le -f s16le output.pcm
-f s16le specifies raw PCM output. Naming the output file .wav does not create a WAV container.
Convert A-law or μ-law audio
For 8 kHz, mono raw A-law or μ-law data, use the corresponding command to produce 8 kHz, 16-bit, mono WAV:
ffmpeg -f alaw -ar 8000 -ac 1 -i input.alaw -ar 8000 -ac 1 -c:a pcm_s16le output.wav
ffmpeg -f mulaw -ar 8000 -ac 1 -i input.mulaw -ar 8000 -ac 1 -c:a pcm_s16le output.wav
If the A-law or μ-law audio is already in a WAV container, read the container directly. Do not force raw decoding with -f alaw or -f mulaw:
ffmpeg -i input.wav -ar 8000 -ac 1 -c:a pcm_s16le output.wav
Windows (audio conversion tools)
You can use an audio conversion tool such as Adobe Audition or CoolEdit. Open the audio file, change the Export Settings, and export the audio.
For example, to export 16 kHz, 16-bit, mono audio, go to the Sample Type area of the Export Audio Mixdown dialog box. Set Sample Rate to 16000 Hz, Channel to Mono, and Bit Depth to 16 Bit. Select an export format supported by the service you call.
FAQ
Why does sample audio work but my audio returns no result?
First, make sure the audio contains speech. Check that its actual encoding, sample rate, and channel count meet the audio input requirements and that the request parameters match the audio.
You can convert the audio to 8 kHz or 16 kHz, 16-bit, mono PCM-encoded WAV. For instructions, see Convert the audio format.
How do I resolve UNSUPPORT_SAMPLE_RATE in Audio File Transcription or its Offline Edition?
For status: 41010101 and message: UNSUPPORT_SAMPLE_RATE, first check that the model selected in the project matches the audio sample rate: use 8 kHz audio with an 8 kHz model and 16 kHz audio with a 16 kHz model.
For audio with a sample rate higher than 16 kHz, Audio File Transcription can downsample it to 16 kHz when both version=4.0 and enable_sample_rate_adaptive=true are set. For parameter details, see the Audio File Transcription API reference. This parameter is not a general solution for every mismatch between an audio sample rate and a model.
Alternatively, convert the audio to a sample rate supported by the model before submitting it. See Convert the audio format.
Why does Real-time Speech Recognition return an empty result?
Check that the input contains speech and that its actual encoding, sample rate, and channel count meet the audio input requirements. The format and sample rate parameters in the request must match the audio.
Pre-recorded audio does not always need conversion to PCM or WAV. If the input does not meet the requirements, follow the format conversion instructions.
How do I resolve an MP3 input error in Short Speech Recognition?
Short Speech Recognition supports MP3. Check the actual encoding, sample rate, and channel count, and set format to mp3. Do not identify the encoding solely by the file extension or set format to pcm for MP3 input.
For supported formats, see the audio input requirements.
How do I resolve TOO_LONG_SPEECH in Short Speech Recognition?
Short Speech Recognition supports audio up to 60 seconds long. If the service returns status: 41010104 and message: TOO_LONG_SPEECH, check the audio duration. For audio longer than 60 seconds, use Real-time Speech Recognition , Audio File Transcription, or Audio File Transcription (Offline Edition). For service limits, see the audio input requirements.
What can I do if an uploaded file fails in the console demo?
You can convert the audio to 8 kHz or 16 kHz, 16-bit, mono PCM-encoded WAV before uploading it. For instructions, see Convert the audio format.
How do I resolve AUDIO_DURATION_TOO_LONG in Audio File Transcription or its Offline Edition?
For status: 41050103 and message: AUDIO_DURATION_TOO_LONG, check the audio duration. Audio File Transcription and its Offline Edition support a maximum duration of 12 hours, or 6 hours for dual-channel audio when both channels require transcription. You can split a longer file and transcribe the segments separately.
Download the tool from the FFmpeg website. The following command extracts the interval from 10 minutes to 5 hours and 10 minutes into the original audio:
ffmpeg -i input_audio.wav -ss 00:10:00 -to 5:10:00 -c copy output_audio.wav
-i input_audio.wav: Specifies the input file.-ss 00:10:00: Sets the start time to 10 minutes.-to 5:10:00: Sets the end time to 5 hours and 10 minutes.-c copy: Copies the audio data without re-encoding. The output duration is approximately 5 hours; the actual boundaries depend on audio packets.output_audio.wav: Specifies the output file.