Problem:
I'd like to transcribe all mp4 files in a folder on both Mac and Windows using Whisper.
I am familiar with scripting and command-line, and have already set up Whisper to work on my machine.
Windows example solution:
The following is an example solution for Windows. Save this in a .bat file and run it in the folder you'd like to process all mp4 files. Modify the script as you need to.
This example transcribes in English with Whisper set up to use CUDA. It skips over any already transcribed mp4 files. It is not recursive.
e.g. transcribe_all_mp4.bat:
for %%f in (*.mp4) do (
echo %%~nf
if not exist "%%~nf.txt" (
echo will process %%~nf.mp4
whisper "%%~nf.mp4" --language English --device cuda
) else (
echo will NOT process %%~nf.mp4
)
)
Mac example solution:
The following example is a single Terminal command you can use in MacOS with Whisper already set up.
Note that this example command does not check for existing transcriptions. It does however specify Whisper to use the medium model. It is not recursive. Modify the command as you need to.
In Terminal in the folder where you want to transcribe your .mp4 files:
for f in *.mp4 ; do whisper $f --model medium ; done
Notes:
The above solutions in Windows and Mac were verified to work between February 2023 to June 2023 (for real-life conference and film work). As of this time the good folks over at Whisper haven't yet implemented batch processing of files.
Hope these examples helped you start to get past where you too got stuck :)
References:
- https://www.digitalocean.com/community/tutorials/workflow-loop-through-files-in-a-directory
- https://github.com/openai/whisper/discussions/153
- https://stackoverflow.com/questions/39615/how-to-loop-through-files-matching-wildcard-in-batch-file
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490909(v=technet.10)?redirectedfrom=MSDN
- https://github.com/openai/whisper/blob/main/README.md
- https://stackoverflow.com/questions/23735282/if-not-exist-command-in-batch-file