-
Currently, I am using "whisper audio-1.wav audio-2.wav audio-3.wav ... --model medium" to transcribe my audio files. Is there a more elegant way of transcribing each file? It gets very stuffed in the prompt with around 900 audio file names. Also I've been noticing that within the anaconda prompt whisper transcribes up to around 900 audio snippets at a time. Can I increase the number of audio files to transcribe? Or how can I automate the anaconda prompt to start a new transcription job when the last one is done? |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 17 replies
-
As it is currently implemented, OR if your question is not about speed and about automating the transcription of 900+ audio files, you could create a script like: whisper audio-1.wav audio-2.wav audio-3.wav ... --model medium
whisper audio-11.wav audio-12.wav audio-13.wav ... --model medium
... and run it by |
Beta Was this translation helpful? Give feedback.
-
Why not use something like this from your shell
|
Beta Was this translation helpful? Give feedback.
-
I plan to program a software to batch process video files with Whisper by command prompt execution programmatically. You can subscribe and stay tuned for it : https://www.youtube.com/c/SECourses |
Beta Was this translation helpful? Give feedback.
-
I just generate the list of files in bash and dump them all into the command line. If you have problems with argument length you could maybe do 10 or 100 at a time. This does all the files in the current folder, but you can obviously change that. I'm sure you could also move the whisper command into the loop and run it after the array is a certain length then reset the array. args=()
for FILE in *.mp4
do
if [ -f "$FILE".txt ]; then
# skip files that are already generated
true
else
args+=("$FILE")
fi
done
whisper --model medium.en --language en ${args[@]} |
Beta Was this translation helpful? Give feedback.
-
I have programmed a batch processing software and it is freely available on github The software also supports multi-threading as well |
Beta Was this translation helpful? Give feedback.
-
Just do a for loop, import whisper Get a list of all the audio files in the "data" folderaudio_files = [f for f in os.listdir("data") if f.endswith('.wav')] Initialize an empty list to store the transcriptionstranscriptions = [] Loop over all the audio files in the "data" folderfor audio_file in audio_files: |
Beta Was this translation helpful? Give feedback.
-
In PowerShell, you can do like below:
Here,the |
Beta Was this translation helpful? Give feedback.
-
There are few examples for batch processing of multiple files [for Windows]: Purfview/whisper-standalone-win#29 Or better use standalone Faster-Whiper which supports batching out of the box, few usage examples:
|
Beta Was this translation helpful? Give feedback.
-
Certainly! Here's the script that meets your requirements: # This script searches for .mp3 files in the current directory,
# excludes those already processed, and performs batch processing.
# Get the list of .mp3 files in the current directory
$mp3Files = Get-ChildItem -Filter *.mp3
# Create an empty list to store the files to be processed
$filesToProcess = @()
# Iterate through each .mp3 file
foreach ($file in $mp3Files) {
# Check if a corresponding .txt file exists
$txtFile = $file.FullName -replace '\.mp3$', '.txt'
if (-not (Test-Path $txtFile)) {
# If .txt file doesn't exist, add the .mp3 file to the list
$filesToProcess += $file
}
}
# Check if there are any files to process
if ($filesToProcess.Count -eq 0) {
Write-Host "All files already processed."
return
}
# Print the number of items found and start the process
Write-Host "$($filesToProcess.Count) items found, starting process..."
# Process each .mp3 file
foreach ($fileToProcess in $filesToProcess) {
$mp3FileName = $fileToProcess.Name
Write-Host "Processing $mp3FileName..."
# Execute the process using the whisper command
$processResult = whisper --model base.en "$mp3FileName"
# Check if the process was successful by searching for the corresponding .txt file
$txtFile = $fileToProcess.FullName -replace '\.mp3$', '.txt'
if (-not (Test-Path $txtFile)) {
Write-Host "Something went wrong while processing $mp3FileName."
}
}
# Check if all files were successfully processed
$processedFiles = Get-ChildItem -Filter *.txt
if ($processedFiles.Count -eq $mp3Files.Count) {
Write-Host "All $($mp3Files.Count) files successfully processed."
} else {
$unprocessedCount = $mp3Files.Count - $processedFiles.Count
Write-Host "Only $($processedFiles.Count) successfully processed, but $unprocessedCount items not processed, something went wrong."
} To use this script: Open a text editor and paste the script into a new file. Save the file with a .ps1 extension, for example, batch_process.ps1. |
Beta Was this translation helpful? Give feedback.
-
This worked for me well forfiles -c "cmd /c whisper @file --model medium" |
Beta Was this translation helpful? Give feedback.
-
The following is a CMD (DOS/Windows) batch file to process 16 (you can adjust based on file name length) files at a time. Using this to eliminate whisper startup costs running on CPU (no video card) the batch saved 12% of the time. (319 files, 293 minutes instead of 333 minutes). DOS command line limit (total length) does limit how many files you can put on a single call. I did 16 to test with long file names. Limit might be 8191 characters. I later ran with 100 files per whisper call and that worked. Larger number of files will save more time. Original was a batch file like this (one whisper call per file, 333 minutes): for %%f in (*.wav) do ( whisper --language en %%f ) Groups of 16 were run using this batch file (one whisper startup with 16 audio files, 293 minutes):
|
Beta Was this translation helpful? Give feedback.
-
Doing this in a shell loop is a terrible idea if you have lots of short files. Most of the work will be spent loading the model repeatedly. You really want to persist the model in memory by writing you own python script with
|
Beta Was this translation helpful? Give feedback.
Why not use something like this from your shell