auto-subtitle icon indicating copy to clipboard operation
auto-subtitle copied to clipboard

Fix audio out of sync

Open RapDoodle opened this issue 2 years ago • 4 comments

I encountered a similar issue described in #28, but my videos are in English. I suspect it is related to the variable framerates of the video's recording device.

After some debugging, it turns out the output .wav audio file is out of sync with the original video. Thus, I added the -async 1 option to ffmpeg and it fixed the issue.

Also, becauseasync is a reversed keyword in Python, I replaced the call to ffmpeg with subprocess.run.

RapDoodle avatar Feb 18 '23 13:02 RapDoodle

  • The ffmpeg module was replaced with the subprocess module due to conflicting argument name "async"
  • A new function get_audio() is added which extracts audio from a video file and returns its path
  • In main(), if --extract-audio flag is set, then extract audio using get_audio() instead of calling transcribe().

what-the-diff[bot] avatar Feb 18 '23 13:02 what-the-diff[bot]

@RapDoodle Can you update this to use the newer aresample option instead? I believe this will also let us keep using ffmpeg directly

m1guelpf avatar Nov 16 '23 01:11 m1guelpf

  • The ffmpeg module was replaced with the subprocess module due to conflicting argument name "async"
  • A new function get_audio() is added which extracts audio from a video file and returns its path
  • In main(), if --extract-audio flag is set, then extract audio using get_audio() instead of calling transcribe().

[what-the-diff] what a lovely but completely useless chap you are 😉. Your contribution made no sense to this thread. Anyway, @RapDoodle I'm afraid the de-synchronization still happens despite the changes!

francogrex avatar May 14 '24 15:05 francogrex

Following the discussion here https://github.com/openai/whisper/discussions/1888 I was able to greatly improve accuracy by adding the --word_timestamps True flag to the transcribe call.

GitHub
Hail I'm trying to translate this German movie into English or at least transcribing. I see that the translation or transcribing are truly impressive, nothing to complain. And somehow somewhat, the...

davejab avatar Jun 07 '24 18:06 davejab