Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update A2T audio conversion #389

Merged
merged 3 commits into from
Jan 10, 2025
Merged

Conversation

ad-astra-video
Copy link
Collaborator

PR improves file handling of audio-to-text pipeline by removing call to ffmpeg to process the audio and uses pyav to convert to raw audio.

Cloud SPE test file fails in my testing sometimes with current conversion implementation using "mp3" container and format. The processing error was coming from the internal conversion to raw audio in transformers (links below). Switching to processing the audio file using pyav allows the Cloud SPE file to process correctly.

Transformers calling ffmpeg binary from preprocess function.
https://github.com/huggingface/transformers/blob/47c29ccfaf56947d845971a439cbe75a764b63d7/src/transformers/pipelines/automatic_speech_recognition.py#L353
https://github.com/huggingface/transformers/blob/47c29ccfaf56947d845971a439cbe75a764b63d7/src/transformers/pipelines/audio_utils.py#L10

Some marginal speed improvements:
Cloud SPE test file (3s clip)
965ms - bytes of container sent to model
895ms - np ndarray sent to model

Another test file (3m 22s)
5.6s - bytes of container sent to model
5.5s - np ndarray sent to model

@ad-astra-video ad-astra-video changed the title update(ai): update A2T audio conversion feat: update A2T audio conversion Jan 3, 2025
Copy link
Collaborator

@eliteprox eliteprox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Tested with MP4 and regression MP3 and FLAC. Left a few nits for cleanup

runner/app/pipelines/audio_to_text.py Outdated Show resolved Hide resolved
runner/app/pipelines/utils/audio.py Show resolved Hide resolved
@ad-astra-video
Copy link
Collaborator Author

ad-astra-video commented Jan 10, 2025

I made updates for small clean up and removed import not needed. Rebuilt docker container and tested to confirm both test files work (one test file is clouds test audio file).

@ad-astra-video ad-astra-video merged commit 84924f7 into main Jan 10, 2025
11 of 12 checks passed
@ad-astra-video ad-astra-video deleted the a2t-audio-conversion-update branch January 10, 2025 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants