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

Fix exception when generating the subtitles for an audio with no speech #1396

Merged
merged 3 commits into from
Oct 10, 2023

Conversation

jordimas
Copy link
Contributor

@jordimas jordimas commented May 27, 2023

When generating the subtitles for an audio with no speech, an exception is thrown because the code assumes that there will be always a segment at index 0 which is not the case.

  File "/lib/python3.11/site-packages/whisper/transcribe.py", line 453, in cli
    writer(result, audio_path, writer_args)
  File "/lib/python3.11/site-packages/whisper/utils.py", line 255, in write_all
    writer(result, file, options)
  File "/lib/python3.11/site-packages/whisper/utils.py", line 85, in __call__
    self.write_result(result, file=f, options=options)
  File "/lib/python3.11/site-packages/whisper/utils.py", line 195, in write_result
    for start, end, text in self.iterate_result(result, options):
  File "/lib/python3.11/site-packages/whisper/utils.py", line 148, in iterate_result
    if "words" in result["segments"][0]:
                  ~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

@gmat
Copy link

gmat commented Oct 10, 2023

this change should be approved it fixes crashes on srt and vtt outputs when no speech identified in audio. Tested with last release and python 3.9. Will works with all python versions

@jongwook jongwook merged commit b38a1f2 into openai:main Oct 10, 2023
8 checks passed
abyesilyurt pushed a commit to abyesilyurt/whisper that referenced this pull request Nov 13, 2023
yaomingamd pushed a commit to ROCm/whisper that referenced this pull request Nov 27, 2023
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

Successfully merging this pull request may close these issues.

4 participants