EtienneAb3d / WhisperHallu

Experimental code: sound file preprocessing to optimize Whisper transcriptions without hallucinated texts
274 stars 22 forks source link

KeyError: 'word_timestamps' #26

Open RobbedColek opened 9 months ago

RobbedColek commented 9 months ago
Traceback (most recent call last):
  File "C:\Apps\WhisperHallu\transcribeHallu.py", line 404, in transcribeMARK
    if(transcribe_options["word_timestamps"]):

Can't get the application to work properly with addSRT=True set - otherwise I get no output other than the console output.

EtienneAb3d commented 9 months ago

@RobbedColek

I will test addSRT=True. But, your error message seems to be truncated. Can you provide with the full output?

In the code example, the output is in the "result" variable. You should print it to the console to see it.

RobbedColek commented 9 months ago

Here's full output from the example script + print(result) added at the end.

Python >= 3.10                                                                                                                          
Using cache found in C:\Users\robbe/.cache\torch\hub\snakers4_silero-vad_master                                                         
Using Demucs                                                                                                                            
Using standard Whisper                                                                                                                  
Using Faster Whisper                                                                                                                    
LOADING: whisper-large-ct2/ GPU: 0 BS: 2                                                                                                
LOADED                                                                                                                                  
=====transcribePrompt                                                                                                                   
PATH=C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3                                                                                   
LNGINPUT=en                                                                                                                             
LNG=en                                                                                                                                  
PROMPT=Whisper, Ok. A pertinent sentence for your purpose in your language. Ok, Whisper. Whisper, Ok. Ok, Whisper. Whisper, Ok. Please f
ind here, an unlikely ordinary sentence. This is to avoid a repetition to be deleted. Ok, Whisper.                                      
CMD: ffmpeg -y -i "C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3" -t 1200 -c:a pcm_s16le -ar 16000 "C:\Apps\WhisperHallu\data\KatyPer
ry-Firework.mp3.WAV.wav" > "C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav.log" 2>&1                                          
T= 0.7584187984466553                                                                                                                   
DURATION=232 trunc 1200                                                                                                                 
PATH=C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav                                                                           
CMD: ffmpeg -y -i "C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav"  -f null - > "C:\Apps\WhisperHallu\data\KatyPerry-Firework.
mp3.WAV.wav.dur" 2>&1                                                                                                                   
T= 0.4261810779571533                                                                                                                   
DURATION=231 max 1200                                                                                                                   
Demucs using device: cuda:0                                                                                                             
Source: drums                                                                                                                           
Source: bass                                                                                                                            
Source: other                                                                                                                           
Source: vocals                                                                                                                          
T= 9.165295600891113                                                                                                                    
PATH=C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav.vocals.wav                                                                
CMD: ffmpeg -y -i "C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav.vocals.wav" -af "silenceremove=start_periods=1:stop_periods=
-1:start_threshold=-50dB:stop_threshold=-50dB:start_silence=0.2:stop_silence=0.2, loudnorm"  -c:a pcm_s16le -ar 16000 "C:\Apps\WhisperHa
llu\data\KatyPerry-Firework.mp3.WAV.wav.vocals.wav.SILCUT.wav" > "C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav.vocals.wav.SI
LCUT.wav.log" 2>&1                                                                                                                      
T= 3.9495115280151367                                                                                                                   
PATH=C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav.vocals.wav.SILCUT.wav                                                     
NOT USING MARKS FOR DURATION > 30s                                                                                                      
transcribeMARK(): C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav.vocals.wav.SILCUT.wav                                        
[0] PATH=C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav.vocals.wav.SILCUT.wav                                                 
T= 16.7706241607666                                                                                                                     
TRANS= Do you ever feel, like a plastic bag, drifting through the wind, wanting to start again. Do you ever feel, feel so paper thin, li
ke a house of cards, one blow from caving in. Do you ever feel, already buried deep, six feet under screams, but no one seems to hear a 
thing. Do you know that there's still a chance for you, cause there's a spark in you. You just gotta ignite the light, and let it shine,
 just own the night, like the fourth of July. Cause baby you're a firework, come on show em what you're worth. Make em go ah, ah, ah, as
 you shoot across the sky. Baby you're a firework, come on let your colors burn, make em go ah, ah, ah, you're gonna leave em all in awe
. You don't have to feel, like a wasted space, you're original, cannot be replaced, if you only knew, what the future holds. After a hur
ricane, comes a rainbow, maybe a reason why, all the doors are closed. So you could open one that leads you to the perfect road, like a 
lightning bolt, your heart will glow, and when it's time you know. You just gotta ignite the light, and let it shine, just own the night
, like the fourth of July. Cause baby you're a firework, come on show em what you're worth. Make em go ah, ah, ah, as you shoot across t
he sky. Baby you're a firework, come on let your colors burn, make em go ah, ah, ah, you're gonna leave em all in awe. Boom, boom, boom,
 even brighter than the moon, moon, moon, it's always been inside of you, you, you, and now it's time to let it through. Cause baby you'
re a firework, come on show em what you're worth. Make em go ah, ah, ah, as you shoot across the sky. Baby you're a firework, come on le
t your colors burn, make em go ah, ah, ah, you're gonna leave em all in awe. Boom, boom, boom, even brighter than the moon, moon, moon. 
Boom, boom, boom, even brighter than the moon, moon, moon.                                                                              
transcribeMARK(): C:\Apps\WhisperHallu\data\KatyPerry-Firework.mp3.WAV.wav                                                              
'word_timestamps'                                                                                                                       
Traceback (most recent call last):                                                                                                      
  File "C:\Apps\WhisperHallu\transcribeHallu.py", line 404, in transcribeMARK                                                           
    if(transcribe_options["word_timestamps"]):                                                                                          
       ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^                                                                                            
KeyError: 'word_timestamps'                                                                                                             
T= 32.61158537864685                                                                                                                    
s/c= 0.017918729913103712                                                                                                               
c/s= 55.807526808510815                                                                                                                 
 Do you ever feel, like a plastic bag, drifting through the wind, wanting to start again. Do you ever feel, feel so paper thin, like a h
ouse of cards, one blow from caving in. Do you ever feel, already buried deep, six feet under screams, but no one seems to hear a thing.
 Do you know that there's still a chance for you, cause there's a spark in you. You just gotta ignite the light, and let it shine, just 
own the night, like the fourth of July. Cause baby you're a firework, come on show em what you're worth. Make em go ah, ah, ah, as you s
hoot across the sky. Baby you're a firework, come on let your colors burn, make em go ah, ah, ah, you're gonna leave em all in awe. You 
don't have to feel, like a wasted space, you're original, cannot be replaced, if you only knew, what the future holds. After a hurricane
, comes a rainbow, maybe a reason why, all the doors are closed. So you could open one that leads you to the perfect road, like a lightn
ing bolt, your heart will glow, and when it's time you know. You just gotta ignite the light, and let it shine, just own the night, like
 the fourth of July. Cause baby you're a firework, come on show em what you're worth. Make em go ah, ah, ah, as you shoot across the sky
. Baby you're a firework, come on let your colors burn, make em go ah, ah, ah, you're gonna leave em all in awe. Boom, boom, boom, even 
brighter than the moon, moon, moon, it's always been inside of you, you, you, and now it's time to let it through. Cause baby you're a f
irework, come on show em what you're worth. Make em go ah, ah, ah, as you shoot across the sky. Baby you're a firework, come on let your
 colors burn, make em go ah, ah, ah, you're gonna leave em all in awe. Boom, boom, boom, even brighter than the moon, moon, moon. Boom, 
boom, boom, even brighter than the moon, moon, moon.                                                                                    
EtienneAb3d commented 9 months ago

@RobbedColek Should be fixed in the latest release. ;-)