Marti Umbert commited on
Commit
b58a787
·
1 Parent(s): b329b92

whisperlivekit/audio_processor.py: bugfix when lines array is empty

Browse files
Files changed (1) hide show
  1. whisperlivekit/audio_processor.py +5 -2
whisperlivekit/audio_processor.py CHANGED
@@ -384,8 +384,11 @@ class AudioProcessor:
384
  lines[-1]["translation"] = ""
385
  #lines[-1]["translation"] += " " + await self.translate_text(text = token.text)
386
 
387
- text_to_translate = lines[-1]["text"]
388
- lines[-1]["translation"] = await self.translate_text(text=text_to_translate) if len(lines) > 0 else ""
 
 
 
389
  # Handle undiarized text
390
  if undiarized_text:
391
  combined = sep.join(undiarized_text)
 
384
  lines[-1]["translation"] = ""
385
  #lines[-1]["translation"] += " " + await self.translate_text(text = token.text)
386
 
387
+ text_to_translate = ""
388
+ if lines:
389
+ text_to_translate = lines[-1]["text"]
390
+ lines[-1]["translation"] = await self.translate_text(text=text_to_translate) if len(lines) > 0 else ""
391
+
392
  # Handle undiarized text
393
  if undiarized_text:
394
  combined = sep.join(undiarized_text)