Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight and Max line width #13

Open
Linch1 opened this issue Oct 4, 2023 · 1 comment
Open

Highlight and Max line width #13

Linch1 opened this issue Oct 4, 2023 · 1 comment

Comments

@Linch1
Copy link

Linch1 commented Oct 4, 2023

Hello,
Is it possible to highlight the text and give a maximum width to the output? i'm taking as exaple this command from whisper

whisper path/text.wav --word_timestamps True --max_line_width 22 --max_line_count 1 --highlight_words True --output_format srt 

Thanks in advance, and great tool!

@EtienneAb3d
Copy link
Owner

EtienneAb3d commented Oct 4, 2023

Hi @Linch1
I may add some parameters.
Waiting for that, you can change this file:
https://github.com/EtienneAb3d/WhisperHallu/blob/main/transcribeHallu.py
Line 431: adjust the options at your need

                if(transcribe_options["word_timestamps"]):
                    srtOpts = { "max_line_width" : 30, "max_line_count" : 1, "highlight_words" : transcribe_options["word_timestamps"]}

Line 441: remove this filtering

                if(transcribe_options["word_timestamps"]):
                    result["text"] = re.sub("(\n[^<\n]*<u>|</u>[^<\n]*\n)"#Remove lines without highlighted words
                                            ,"\n",re.sub(r"\n[^<\n]*\n\n","\n\n"#Keep only highlighted words
                                                         ,result["text"]))

PS: only works with standard Whisper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants