From d3e2a9e5c06938e30bdf077d4b7f88b502a04d4b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 May 2025 15:14:39 +0200 Subject: [PATCH] Change default voice and fix formatting --- CHANGELOG.md | 4 ++++ src/pipecat/services/google/tts.py | 26 +++++++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dde0bae5..8208329a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `GoogleHttpTTSService` which uses Google's HTTP TTS API. + - Added `PipelineTask.add_observer()` and `PipelineTask.remove_observer()` to allow mangaging observers at runtime. This is useful for cases where the task is passed around to other code components that might want to observe the @@ -73,6 +75,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Updated `GoogleTTSService` to use Google's streaming TTS API. The default voice also updated to `en-US-Chirp3-HD-Charon`. + - `BaseTextFilter` methods `filter()`, `update_settings()`, `handle_interruption()` and `reset_interruption()` are now async. diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index ce56913cd..e28f9fadb 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -210,9 +210,7 @@ class GoogleHttpTTSService(TTSService): emphasis: Optional[Literal["strong", "moderate", "reduced", "none"]] = None language: Optional[Language] = Language.EN gender: Optional[Literal["male", "female", "neutral"]] = None - google_style: Optional[ - Literal["apologetic", "calm", "empathetic", "firm", "lively"] - ] = None + google_style: Optional[Literal["apologetic", "calm", "empathetic", "firm", "lively"]] = None def __init__( self, @@ -255,14 +253,10 @@ class GoogleHttpTTSService(TTSService): if credentials: # Use provided credentials JSON string json_account_info = json.loads(credentials) - creds = service_account.Credentials.from_service_account_info( - json_account_info - ) + creds = service_account.Credentials.from_service_account_info(json_account_info) elif credentials_path: # Use service account JSON file if provided - creds = service_account.Credentials.from_service_account_file( - credentials_path - ) + creds = service_account.Credentials.from_service_account_file(credentials_path) else: try: creds, project_id = default( @@ -424,7 +418,7 @@ class GoogleTTSService(TTSService): *, credentials: Optional[str] = None, credentials_path: Optional[str] = None, - voice_id: str = "en-US-Neural2-A", + voice_id: str = "en-US-Chirp3-HD-Charon", sample_rate: Optional[int] = None, params: InputParams = InputParams(), **kwargs, @@ -454,14 +448,10 @@ class GoogleTTSService(TTSService): if credentials: # Use provided credentials JSON string json_account_info = json.loads(credentials) - creds = service_account.Credentials.from_service_account_info( - json_account_info - ) + creds = service_account.Credentials.from_service_account_info(json_account_info) elif credentials_path: # Use service account JSON file if provided - creds = service_account.Credentials.from_service_account_file( - credentials_path - ) + creds = service_account.Credentials.from_service_account_file(credentials_path) else: try: creds, project_id = default( @@ -509,9 +499,7 @@ class GoogleTTSService(TTSService): input=texttospeech_v1.StreamingSynthesisInput(text=text) ) - streaming_responses = await self._client.streaming_synthesize( - request_generator() - ) + streaming_responses = await self._client.streaming_synthesize(request_generator()) await self.start_tts_usage_metrics(text) yield TTSStartedFrame()