Last active
March 8, 2023 22:14
-
-
Save markshust/3a4d5f8e0337c8d4729441551d196c13 to your computer and use it in GitHub Desktop.
Python script to use Whisper to transcribe audio/video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import whisper | |
from whisper.utils import get_writer | |
input_dir = 'input/' | |
output_dir = 'output/' | |
for filename in sorted(os.listdir(input_dir)): | |
if filename.endswith('.mp4'): | |
input_file = input_dir + filename | |
print('Processing ' + input_file + '...') | |
model = whisper.load_model('large') | |
result = model.transcribe(input_file, fp16=False) | |
srt_writer = get_writer('srt', output_dir) | |
srt_writer(result, input_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment