Transcribe Videos wit Python, OpenAI Whisper, & ffmpeg

preview_player
Показать описание
Transcribe Videos wit Python, OpenAI Whisper, & ffmpeg

Рекомендации по теме
Комментарии
Автор

👏👏🥳 This stuff is so cool!

In my experiments I got better results (lower WER) without first generating an audio file from the video file.
Not 100% sure why, probably because of the conversion and loss in audio quality in some cases.
Also, for the Dutch language the 'large' data model tends to produce better results.

Below is the basic code I use:

import whisper
from whisper.utils import get_writer

file = "video/inputfile.mp4"
output_directory = "subs/"

model = whisper.load_model("large")
result = model.transcribe(file)

# Save transcription as a TXT file
txt_writer = get_writer("txt", output_directory)
txt_writer(result, file)

# Save subtitles as an SRT file
srt_writer = get_writer("srt", output_directory)
srt_writer(result, file)

silkogelman
Автор

I use windows and cant install brew, everytime I run, it gives me an error on subprocess"ffmpeg" that file not found. I placed video file correctly

mohdalim
Автор

Is it mandatory to convert to mp3? Can't we use the mp4 directly?

saulotarsobc