Tidying up the Hume example and service

This commit is contained in:
Mark Backman
2025-10-02 17:34:40 -04:00
parent ad2adb0c58
commit 60604a9449
3 changed files with 29 additions and 9 deletions

View File

@@ -201,12 +201,20 @@ class HumeTTSService(TTSService):
if len(self._audio_bytes) < self.chunk_size:
continue
yield TTSAudioRawFrame(self._audio_bytes, self.sample_rate, 1)
frame = TTSAudioRawFrame(
audio=self._audio_bytes,
sample_rate=self.sample_rate,
num_channels=1,
)
yield frame
self._audio_bytes = b""
except Exception as e:
logger.exception(f"{self} error generating TTS: {e}")
yield ErrorFrame(error=str(e))
await self.push_error(ErrorFrame(f"Error generating TTS: {e}"))
finally:
# Ensure TTFB timer is stopped even on early failures
await self.stop_ttfb_metrics()
yield TTSStoppedFrame()