makaveli10 commited on
Commit
79ce63a
2 Parent(s): 3a0cae9 8566a8b

Merge branch 'main' of https://github.com/collabora/WhisperBot

Browse files
Files changed (1) hide show
  1. tts_service.py +9 -3
tts_service.py CHANGED
@@ -43,12 +43,18 @@ class WhisperSpeechTTS:
43
  llm_output = llm_response["llm_output"][0]
44
  self.eos = llm_response["eos"]
45
 
 
 
 
46
  # only process if the output updated
47
  if self.last_llm_response != llm_output.strip():
48
  logging.INFO("[WhisperSpeech INFO:] Tunning TTS inference ...")
49
- audio = self.pipe.vocoder.decode(self.pipe.generate_atoks(llm_output.strip()))
50
- self.output_audio = audio.cpu().numpy()
51
- self.last_llm_response = llm_output.strip()
 
 
 
52
 
53
  if self.eos and self.output_audio is not None:
54
  try:
 
43
  llm_output = llm_response["llm_output"][0]
44
  self.eos = llm_response["eos"]
45
 
46
+ def should_abort():
47
+ if not audio_queue.empty(): raise TimeoutError()
48
+
49
  # only process if the output updated
50
  if self.last_llm_response != llm_output.strip():
51
  logging.INFO("[WhisperSpeech INFO:] Tunning TTS inference ...")
52
+ try:
53
+ audio = self.pipe.generate(llm_output.strip(), step_callback=should_abort)
54
+ self.output_audio = audio.cpu().numpy()
55
+ self.last_llm_response = llm_output.strip()
56
+ except TimeoutError:
57
+ pass
58
 
59
  if self.eos and self.output_audio is not None:
60
  try: