langgenius/dify · error · UnsupportedAudioTypeError
unsupported_audio_type
unsupported_audio_type
Error message
Audio type not allowed.
What it means
Raised by _transcribe_audio_to_text when AudioService raises UnsupportedAudioTypeServiceError — the uploaded audio's MIME type or extension is not in the allowed set for speech-to-text. Translated to UnsupportedAudioTypeError (HTTP 415, error_code 'unsupported_audio_type').
Source
Thrown at api/controllers/console/app/audio.py:159
)
else:
response = AudioService.transcript_agent_asr(
app_model=app_model,
agent_soul=agent_soul,
file=file,
session=session,
end_user=None,
)
return dump_response(AudioTranscriptResponse, response)
except services.errors.app_model_config.AppModelConfigBrokenError:
logger.exception("App model config broken.")
raise AppUnavailableError()
except NoAudioUploadedServiceError:
raise NoAudioUploadedError()
except AudioTooLargeServiceError as e:
raise AudioTooLargeError(str(e))
except UnsupportedAudioTypeServiceError:
raise UnsupportedAudioTypeError()
except ProviderNotSupportSpeechToTextServiceError:
raise ProviderNotSupportSpeechToTextError()
except SpeechToTextDisabledServiceError:
raise SpeechToTextDisabledError()
except ProviderTokenNotInitError as ex:
raise ProviderNotInitializeError(ex.description)
except QuotaExceededError:
raise ProviderQuotaExceededError()
except ModelCurrentlyNotSupportError:
raise ProviderModelCurrentlyNotSupportError()
except InvokeError as e:
raise CompletionRequestError(e.description)
except HTTPException:
raise
except ValueError:
raise
except Exception as e:
logger.exception("Failed to transcribe audio to text")View on GitHub (pinned to ef8544b173)
Solutions
- Convert the audio to MP3 before uploading (ffmpeg -i in.wav out.mp3).
- Set the correct Content-Type and filename extension on the multipart part.
- Configure the recorder to output an accepted container/codec.
- Check the provider's supported formats in the model provider settings.
Example fix
// before
form.append('file', wavBlob, 'message.wav');
// after: convert to mp3 client-side or server-side first
form.append('file', mp3Blob, 'message.mp3'); Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = ['audio/mpeg', 'audio/mp3'];
function assertAllowedAudio(file) {
if (!ALLOWED.includes(file.type) && !/\.mp3$/i.test(file.name)) throw new Error('Only MP3 audio is supported');
return file;
} Type guard
const isAllowedAudio = (f) => ALLOWED.includes(f.type) || /\.mp3$/i.test(f.name);
Try / catch
try { await axios.post(`/apps/${id}/audio-to-text`, form); }
catch (e) { if (e.code === 'unsupported_audio_type') { /* convert to mp3 then retry */ } } Prevention
- Configure recorders to output MP3 or convert before upload.
- Set the correct filename extension and Content-Type on the part.
- Filter accepted types in the UI input.
When it happens
Trigger: Uploading a format the STT provider rejects: .wav, .m4a, .ogg, .flac when only .mp3 is supported (the OpenAPI doc describes the param as 'MP3 audio to transcribe'), or an unknown/ambiguous content type.
Common situations: Browser recorder producing webm/ogg; user attaching a voice memo in m4a; Content-Type header missing so the service cannot infer the format.
Related errors
- no_audio_uploaded
- app_unavailable
- provider_not_support_speech_to_text
- provider_quota_exceeded
- model_currently_not_support
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/0d85025c0dc1b354.
Report an issue: GitHub.