{"record":{"id":"c45aa99489fc12f0","repo":"xtekky/gpt4free","slug":"speech-transcription-requires-installing-markitdow","errorCode":null,"errorMessage":"Speech transcription requires installing MarkItdown with the [audio-transcription] optional dependencies. E.g., `pip install markitdown[audio-transcription]` or `pip install markitdown[all]`","messagePattern":"Speech transcription requires installing MarkItdown with the \\[audio-transcription\\] optional dependencies\\. E\\.g\\., `pip install markitdown\\[audio-transcription\\]` or `pip install markitdown\\[all\\]`","errorType":"exception","errorClass":"MissingDependencyException","httpStatus":null,"severity":"error","filePath":"g4f/integration/markitdown/_transcribe_audio.py","lineNumber":28,"sourceCode":"    # Suppress some warnings on library import\n    import warnings\n\n    with warnings.catch_warnings():\n        warnings.filterwarnings(\"ignore\", category=DeprecationWarning)\n        warnings.filterwarnings(\"ignore\", category=SyntaxWarning)\n        import speech_recognition as sr\n        import pydub\nexcept ImportError:\n    # Preserve the error and stack trace for later\n    _dependency_exc_info = sys.exc_info()\n\n\ndef transcribe_audio(\n    file_stream: BinaryIO, *, audio_format: str = \"wav\", language: str = None\n) -> str:\n    # Check for installed dependencies\n    if _dependency_exc_info is not None:\n        raise MissingDependencyException(\n            \"Speech transcription requires installing MarkItdown with the [audio-transcription] optional dependencies. E.g., `pip install markitdown[audio-transcription]` or `pip install markitdown[all]`\"\n        ) from _dependency_exc_info[\n            1\n        ].with_traceback(  # type: ignore[union-attr]\n            _dependency_exc_info[2]\n        )\n\n    if audio_format in [\"wav\", \"aiff\", \"flac\"]:\n        audio_source = file_stream\n    elif audio_format in [\"mp3\", \"mp4\", \"webm\"]:\n        audio_segment = pydub.AudioSegment.from_file(file_stream, format=audio_format)\n\n        audio_source = io.BytesIO()\n        audio_segment.export(audio_source, format=\"wav\")\n        audio_source.seek(0)\n    else:\n        raise ValueError(f\"Unsupported audio format: {audio_format}\")\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/integration/markitdown/_transcribe_audio.py#L10-L46","documentation":"Thrown by g4f's vendored markitdown transcribe_audio() as MissingDependencyException when the import of speech_recognition or pydub failed at module load; the original ImportError is captured in _dependency_exc_info and re-raised with a pip hint chained to it. It means the [audio-transcription] optional extras are absent in the current environment.","triggerScenarios":"md.convert('note.mp3') or any audio conversion when SpeechRecognition or pydub is not installed. The check fires before any audio processing, so even valid wav files raise immediately.","commonSituations":"Installing g4f/markitdown without extras (pip install markitdown instead of markitdown[audio-transcription]); slim Docker images that strip optional deps; a venv activated after installing into another interpreter.","solutions":["pip install 'markitdown[audio-transcription]' (or 'markitdown[all]') into the same interpreter that runs the code.","Verify with python -c 'import speech_recognition, pydub' — exit code 0 means the error will not fire.","In Dockerfiles add the extra to the RUN pip install line.","Note ffmpeg must also be on PATH for pydub to decode mp3/mp4/webm."],"exampleFix":"// before\n# deps missing, transcribe_audio raises MissingDependencyException\nresult = md.convert(\"meeting.mp3\")\n\n// after\n# pip install 'markitdown[audio-transcription]'\nresult = md.convert(\"meeting.mp3\")","handlingStrategy":"validation","validationCode":"def audio_transcription_available() -> bool:\n    try:\n        import speech_recognition  # noqa\n        import pydub  # noqa\n        return True\n    except ImportError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    result = md.convert(\"note.mp3\")\nexcept Exception as e:\n    if \"audio-transcription\" in str(e):\n        raise RuntimeError(\"install markitdown[audio-transcription] to handle audio\") from e\n    raise","preventionTips":["Declare 'markitdown[audio-transcription]' in requirements for audio flows.","Feature-detect the imports and disable audio upload paths when missing.","Ensure ffmpeg is installed for non-wav input."],"tags":["markitdown","audio","missing-dependency","environment"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}