mlx-examples
mlx-examples copied to clipboard
mlx_whisper: add support for audio input from stdin
Problem
I wanted to pipe an audio file to mlx_whisper
, but found it only accepted file paths. This PR will allow mlx_whisper
to accept stdin and pass it to ffmpeg
accordingly then allow the rest of the workflow to go on as usual.
Changes
-
load_audio
helper adjustsffmpeg
flags based on file path vs. stdin mode - CLI parser will gracefully omit the otherwise-required positional
audio
arg if stdin is determined to be active - optionally,
--input-name
arg is supported to help users name the otherwise anonymous stdin content (cannot guess from file path) - added tests in macOS standard
zsh
file to drive and test the changes from the CLI
Process
- ran
black
andpre-commit
on changes prior to PR -
python test.py
shows 4 errors, some regarding floating point comparisons. Looks very far away from my change, may be known issues.