Skip to content

Instantly share code, notes, and snippets.

@janodev
Created February 20, 2023 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janodev/2cf8faa6663d3d07778be82c79a17778 to your computer and use it in GitHub Desktop.
Save janodev/2cf8faa6663d3d07778be82c79a17778 to your computer and use it in GitHub Desktop.
Generating Spanish subtitles for a bunch of mp4 files on a folder (works for any language)
# install mac whisper
brew install python3 ffmpeg
pip install setuptools-rust
pip install -U openai-whisper
# create a script to extract audio and translate
for f in *.mp4; do FILE=`basename -s '.mp4' "$f"`; echo ffmpeg -i "\"$f\"" -vn -acodec copy "\"$FILE.aac\"" >> script.sh; done
for f in *.mp4; do FILE=`basename -s '.mp4' "$f"`; echo whisper "\"$FILE.aac\"" --language Spanish --model medium --task transcribe >> script.sh; done
# run the script. on M1 max this is several times slower than the audio being translated
./script.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment