How to get subtitles with timestamps when invoking transcribe() in python? #2513
Unanswered
Bearmancer
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Not sure what from whisper.utils import get_writer
# transcribe with word timestamps
result = model.transcribe(str(file), fp16=False, verbose=False, language=language, word_timestamps=True)
# Get a writer and configure it with your preferred subtitle formatting
writer = get_writer("srt", ".")
writer(result, str(file), {"max_line_width":55, "max_line_count":2, "highlight_words":False} ) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Whisper video.mp4 is what I would write in the terminal to get it transcribed, yes? That's what I want
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Glenn Langford ***@***.***>
Sent: Wednesday, January 29, 2025 7:28:13 AM
To: openai/whisper ***@***.***>
Cc: Bearmancer ***@***.***>; Author ***@***.***>
Subject: Re: [openai/whisper] How to get subtitles with timestamps when invoking transcribe() in python? (Discussion #2513)
I want the output to be the same as whisper video.mp4 would be, i.e. srt (and other) file with timestamps.
Not sure what whisper video.mp4 is, but I think you are looking for something like this:
from whisper.utils import get_writer
# transcribe with word timestamps
model.transcribe(str(file), fp16=False, verbose=False, language=language, word_timestamps=True)
# Get a writer and configure it with your preferred subtitle formatting
writer = get_writer("srt", ".")
writer(result, str(file), {"max_line_width":55, "max_line_count":2, "highlight_words":False} )
—
Reply to this email directly, view it on GitHub<#2513 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AQWHKKTUISYGUXSPZEHRWE32NAYTLAVCNFSM6AAAAABWBU72JOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJZGA3DOMA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have imported whisper and this is my code:
I want the output to be the same as
whisper video.mp4
would be, i.e. srt (and other) file with timestamps.Beta Was this translation helpful? Give feedback.
All reactions