jianfch / stable-ts

Transcription, forced alignment, and audio indexing with OpenAI's Whisper
MIT License
1.59k stars 177 forks source link

Updated alignment errors #293

Closed kanjieater closed 10 months ago

kanjieater commented 10 months ago

After updating to the latest as mentioned here https://github.com/jianfch/stable-ts/issues/292, I can get a few more texts aligned. Thank you! In my testing I did find more errors

def align_text(model, working_folder, script_file, final):
    file_content = Path(script_file).read_text()
    audio_file = prep_audio(working_folder)
    result = model.align(audio_file, file_content,
                         language="ja",
                         original_split=True,
                         prepend_punctuations='''「"'“¿([{-)''',
                         append_punctuations='''.。,,!!??::”)]}、)」''')
    result.to_srt_vtt(final, word_level=False)
    return result
  result = model.align(audio_file, file_content,
('Traceback (most recent call last):\n'
 '  File "/home/ke/code/subgen/run.py", line 294, in <module>\n'
 '    align_transcript(working_folder, get_content_name(working_folder))\n'
 '  File "/home/ke/code/subgen/run.py", line 253, in align_transcript\n'
 '    align_text(model, working_folder, split_script[0], final)\n'
 '  File "/home/ke/code/subgen/run.py", line 44, in align_text\n'
 '    result = model.align(audio_file, file_content,\n'
 '  File '
 '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/alignment.py", '
 'line 505, in align\n'
 '    result = WhisperResult([result[i:j] for i, j in '
 'zip([0]+split_indices[:-1], split_indices)])\n'
 '  File '
 '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/result.py", '
 'line 633, in __init__\n'
 '    result, self.path = self._standardize_result(result)\n'
 '  File '
 '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/result.py", '
 'line 665, in _standardize_result\n'
 '    segments=[\n'
 '  File '
 '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/result.py", '
 'line 667, in <listcomp>\n'
 "    start=words[0]['start'],\n"
 'IndexError: list index out of range\n')
kanjieater commented 10 months ago

test file Test file is up, will delete when we resolve

jianfch commented 10 months ago

It should be fixed in 6d0746cd79ece5aea0e08488da1687ef4fe65935.

kanjieater commented 10 months ago

I got a similar error after updating: /home/ke/code/subgen/run.py:44: UserWarning: Failed to align the last 497/233896 words after 19:06:51.620. result = model.align(audio_file, file_content, ('Traceback (most recent call last):\n' ' File "/home/ke/code/subgen/run.py", line 294, in \n' ' align_transcript(working_folder, get_content_name(working_folder))\n' ' File "/home/ke/code/subgen/run.py", line 253, in align_transcript\n' ' align_text(model, working_folder, split_script[0], final)\n' ' File "/home/ke/code/subgen/run.py", line 44, in align_text\n' ' result = model.align(audio_file, file_content,\n' ' File ' '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/alignment.py", ' 'line 505, in align\n' ' result = WhisperResult([result[i:j] for i, j in ' 'zip([0]+split_indices[:-1], split_indices)])\n' ' File ' '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/result.py", ' 'line 633, in init\n' ' result, self.path = self._standardize_result(result)\n' ' File ' '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/result.py", ' 'line 665, in _standardize_result\n' ' segments=[\n' ' File ' '"/home/ke/.pyenv/versions/ats/lib/python3.9/site-packages/stable_whisper/result.py", ' 'line 667, in \n' " start=words[0]['start'],\n" 'IndexError: list index out of range\n')

jianfch commented 10 months ago

line 505, in align

It seems you haven't updated to the latest commit. That line should be 509, it was 505 before the update. The update was not pushed to PyPI if that was how you updated.

kanjieater commented 10 months ago

Oh - my mistake. Yes, I have been updating by using

git+https://github.com/jianfch/stable-ts.git@6d0746c in requirement.txt

Update: had to uninstall via pip first, then it worked. Not sure why this was (probably should up used --upgrade instead of just install command ?), but it was an issue on my end - my apologies. I'm testing again. And will let you know.

kanjieater commented 10 months ago

it's working now