feat(parse): implement Whisper ASR integration for audio parser#805
Merged
MaojiaSheng merged 2 commits intovolcengine:mainfrom Mar 20, 2026
Merged
Conversation
Completes the audio parser stub by wiring up OpenAI Whisper API for speech-to-text transcription: - _asr_transcribe(): calls Whisper API via OpenAI SDK, returns text - _asr_transcribe_with_timestamps(): uses verbose_json format with segment-level timestamps, formatted as **[MM:SS - MM:SS]** markdown - parse_content(): decodes base64 audio and delegates to parse() Follows the existing OpenAI SDK pattern from openai_embedders.py. Uses asyncio executor wrapping for sync API calls. Temp file cleanup in finally blocks. Graceful error handling with logger fallbacks.
MaojiaSheng
approved these changes
Mar 20, 2026
zeattacker
pushed a commit
to zeattacker/OpenViking
that referenced
this pull request
Mar 20, 2026
…engine#805) * feat(parse): implement Whisper ASR integration for audio parser Completes the audio parser stub by wiring up OpenAI Whisper API for speech-to-text transcription: - _asr_transcribe(): calls Whisper API via OpenAI SDK, returns text - _asr_transcribe_with_timestamps(): uses verbose_json format with segment-level timestamps, formatted as **[MM:SS - MM:SS]** markdown - parse_content(): decodes base64 audio and delegates to parse() Follows the existing OpenAI SDK pattern from openai_embedders.py. Uses asyncio executor wrapping for sync API calls. Temp file cleanup in finally blocks. Graceful error handling with logger fallbacks. * style: auto-format audio.py with ruff --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Contributor
Author
|
Thanks for the reviews across these three PRs, @qin-ctx. The feedback on the audio parser especially helped tighten the implementation. |
mvanhorn
added a commit
to mvanhorn/OpenViking
that referenced
this pull request
Mar 25, 2026
Replace the _ocr_extract() stub with a working Tesseract integration via pytesseract. Uses asyncio.run_in_executor() for the synchronous pytesseract call, matching the pattern from _asr_transcribe() in the audio parser (PR volcengine#805). Gracefully degrades when pytesseract is not installed by returning None with a warning. Added as optional dependency: pip install openviking[ocr] Relates to volcengine#372
This was referenced Mar 25, 2026
MaojiaSheng
pushed a commit
that referenced
this pull request
Mar 27, 2026
Replace the _ocr_extract() stub with a working Tesseract integration via pytesseract. Uses asyncio.run_in_executor() for the synchronous pytesseract call, matching the pattern from _asr_transcribe() in the audio parser (PR #805). Gracefully degrades when pytesseract is not installed by returning None with a warning. Added as optional dependency: pip install openviking[ocr] Relates to #372 Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the audio parser stub by implementing the TODO items at
audio.py:172andaudio.py:190, wiring up OpenAI Whisper API for speech-to-text transcription.Changes
In
openviking/parse/parsers/media/audio.py:_asr_transcribe(): Callsclient.audio.transcriptions.create()with the model fromAudioConfig.transcription_model(default:whisper-large-v3). Usesasyncio.get_event_loop().run_in_executor()for async wrapping of the sync OpenAI SDK call._asr_transcribe_with_timestamps(): Usesresponse_format="verbose_json"withtimestamp_granularities=["segment"]. Formats segments as**[MM:SS - MM:SS]** textmarkdown.parse_content(): Decodes base64 content and delegates to the existingparse()method instead of raisingNotImplementedError.Why this matters
The
AudioParserclass, config, metadata extraction, and output format were already defined (audio.py). The two ASR methods were placeholder stubs with explicit TODOs. This PR wires up the actual API calls to complete the implementation.Related: #372 (multimodal resource parsing), #695 (multimodal embedding - audio parser is a prerequisite).
Patterns followed
openai_embedders.pyfinallyblocksopenviking_cli.utils.loggerThis contribution was developed with AI assistance (Claude Code).