Skip to content
Discussion options

You must be logged in to vote

This is how I would do it expanding your code:

audio_file= open("audio.mp3", "rb")
model = whisper.load_model("small")
result = model.transcribe("audio.mp3",initial_prompt="prompt", word_timestamps=True)
print(result["text"])
word_options = {
        "highlight_words": False,
        "max_line_count": 50,
        "max_line_width": 3
    }
srt_writer = get_writer("srt", folder)
    srt_writer(result, 'audio.mp3', word_options)

Added word_options, that allow you to define all those additional options, then use get_writer to convert result to SRT. Hope that helps!

BTW You will need additional import

from whisper.utils import get_writer

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ryanheise
Comment options

Comment options

You must be logged in to vote
1 reply
@jravolio
Comment options

Answer selected by jravolio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants