From a13b9544159db5c30342c8592256c5c22e678c83 Mon Sep 17 00:00:00 2001 From: Ashot Date: Sat, 26 Jul 2025 09:39:50 +0400 Subject: [PATCH] formatting/cleanup: address Copilot PR review comments --- .../07aa-interruptible-asyncai-http.py | 6 ++++++ src/pipecat/services/asyncai/tts.py | 18 +++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/foundational/07aa-interruptible-asyncai-http.py b/examples/foundational/07aa-interruptible-asyncai-http.py index 03ad158e5..415976d61 100644 --- a/examples/foundational/07aa-interruptible-asyncai-http.py +++ b/examples/foundational/07aa-interruptible-asyncai-http.py @@ -1,3 +1,9 @@ +# +# Copyright (c) 2024–2025, Daily +# +# SPDX-License-Identifier: BSD 2-Clause License +# + import argparse import os diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index 7d2ace265..aa90280ca 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -119,7 +119,7 @@ class AsyncAITTSService(AudioContextWordTTSService): # # We also don't want to automatically push LLM response text frames, # because the context aggregators will add them to the LLM context even - # if we're interrupted. + # if we're interrupted. super().__init__( aggregate_sentences=aggregate_sentences, push_text_frames=False, @@ -142,7 +142,7 @@ class AsyncAITTSService(AudioContextWordTTSService): "language": self.language_to_service_language(params.language) if params.language else "en", - } + }, self.set_model_name(model) self.set_voice(voice_id) @@ -160,7 +160,6 @@ class AsyncAITTSService(AudioContextWordTTSService): """ return True - def language_to_service_language(self, language: Language) -> Optional[str]: """Convert a Language enum to Async language format. @@ -173,8 +172,8 @@ class AsyncAITTSService(AudioContextWordTTSService): return language_to_async_language(language) def _build_msg( - self, text: str = "", force: bool = False - ): + self, text: str = "", force: bool = False + ) -> str: msg = { "transcript": text, "force": force @@ -240,7 +239,7 @@ class AsyncAITTSService(AudioContextWordTTSService): "model_id": self._model_name, "voice": {"mode": "id", "id": self._voice_id}, "output_format": self._settings["output_format"], - "language": self._settings["language"] + "language": self._settings["language"], } await self._get_websocket().send(json.dumps(init_msg)) @@ -302,7 +301,6 @@ class AsyncAITTSService(AudioContextWordTTSService): num_channels=1, ) await self.append_to_audio_context(context_id, frame) - elif msg.get("error_code"): logger.error(f"{self} error: {msg}") await self.push_frame(TTSStoppedFrame()) @@ -364,12 +362,10 @@ class AsyncAITTSService(AudioContextWordTTSService): except Exception as e: logger.error(f"{self} exception: {e}") - - class AsyncAIHttpTTSService(TTSService): """HTTP-based Async TTS service. - Provides text-to-speech using Asyncs' HTTP streaming API for simpler, + Provides text-to-speech using Async's HTTP streaming API for simpler, non-WebSocket integration. Suitable for use cases where streaming WebSocket connection is not required or desired. """ @@ -462,7 +458,7 @@ class AsyncAIHttpTTSService(TTSService): @traced_tts async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]: - """Generate speech from text using Asyncs' HTTP streaming API. + """Generate speech from text using Async's HTTP streaming API. Args: text: The text to synthesize into speech.