import sys
import stable_whisper
# Check if the MP4 file name is provided as an argumentiflen(sys.argv) < 2:
print("Please provide the MP4 file name as an argument.")
sys.exit(1)
# Get the MP4 file name from the command-line argument
mp4_file = sys.argv[1]
# Load the Whisper model
model = stable_whisper.load_model('large-v2', device='cpu')
# Transcribe the MP4 file
results = model.transcribe(mp4_file, language='en')
# Specify the fixed SRT file name
srt_file = "temp.srt"# Convert the transcription results to SRT format
stable_whisper.result_to_srt_vtt(results, srt_file, word_level=False)
# Specify the name of the test.py script
$testScript = "test.py"
# Get all MP4 files in the current directory
$inputMP4Files = Get-ChildItem -Filter "*.mp4"
# Process each MP4 file
foreach ($inputMP4 in $inputMP4Files) {
# Get the base name of the input MP4 file (without extension)
$baseName = $inputMP4.BaseName
# Specify the name of the exported SRT file
$exportedSRT = "temp.srt"
# Specify the name of the output MP4 file with the muxed SRT
$outputMP4 = "$baseName`_muxed.mp4"
# Run the test.py script with the input MP4 file
python $testScript $inputMP4
# Check if the exported SRT file exists
if (Test-Path $exportedSRT) {
# Mux the input MP4 file with the exported SRT file using FFmpeg
ffmpeg -i $inputMP4 -i $exportedSRT -c copy -c:s mov_text $outputMP4
Write-Host "Muxing completed for $inputMP4. Output file: $outputMP4"
# Delete the temporary SRT file
Remove-Item $exportedSRT
} else {
Write-Host "Exported SRT file not found for $inputMP4."
}
}
"No one in the audience realizes that the shadow is really my shadow. My older brother, sitting next to me, doesn't notice either. If he had, he wouldn't miss the opportunity to box my ears. He's that kind of brother."