Change default voice and fix formatting
This commit is contained in:
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Added `GoogleHttpTTSService` which uses Google's HTTP TTS API.
|
||||||
|
|
||||||
- Added `PipelineTask.add_observer()` and `PipelineTask.remove_observer()` to
|
- Added `PipelineTask.add_observer()` and `PipelineTask.remove_observer()` to
|
||||||
allow mangaging observers at runtime. This is useful for cases where the task
|
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
|
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
|
### 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()`,
|
- `BaseTextFilter` methods `filter()`, `update_settings()`,
|
||||||
`handle_interruption()` and `reset_interruption()` are now async.
|
`handle_interruption()` and `reset_interruption()` are now async.
|
||||||
|
|
||||||
|
|||||||
@@ -210,9 +210,7 @@ class GoogleHttpTTSService(TTSService):
|
|||||||
emphasis: Optional[Literal["strong", "moderate", "reduced", "none"]] = None
|
emphasis: Optional[Literal["strong", "moderate", "reduced", "none"]] = None
|
||||||
language: Optional[Language] = Language.EN
|
language: Optional[Language] = Language.EN
|
||||||
gender: Optional[Literal["male", "female", "neutral"]] = None
|
gender: Optional[Literal["male", "female", "neutral"]] = None
|
||||||
google_style: Optional[
|
google_style: Optional[Literal["apologetic", "calm", "empathetic", "firm", "lively"]] = None
|
||||||
Literal["apologetic", "calm", "empathetic", "firm", "lively"]
|
|
||||||
] = None
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -255,14 +253,10 @@ class GoogleHttpTTSService(TTSService):
|
|||||||
if credentials:
|
if credentials:
|
||||||
# Use provided credentials JSON string
|
# Use provided credentials JSON string
|
||||||
json_account_info = json.loads(credentials)
|
json_account_info = json.loads(credentials)
|
||||||
creds = service_account.Credentials.from_service_account_info(
|
creds = service_account.Credentials.from_service_account_info(json_account_info)
|
||||||
json_account_info
|
|
||||||
)
|
|
||||||
elif credentials_path:
|
elif credentials_path:
|
||||||
# Use service account JSON file if provided
|
# Use service account JSON file if provided
|
||||||
creds = service_account.Credentials.from_service_account_file(
|
creds = service_account.Credentials.from_service_account_file(credentials_path)
|
||||||
credentials_path
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
creds, project_id = default(
|
creds, project_id = default(
|
||||||
@@ -424,7 +418,7 @@ class GoogleTTSService(TTSService):
|
|||||||
*,
|
*,
|
||||||
credentials: Optional[str] = None,
|
credentials: Optional[str] = None,
|
||||||
credentials_path: 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,
|
sample_rate: Optional[int] = None,
|
||||||
params: InputParams = InputParams(),
|
params: InputParams = InputParams(),
|
||||||
**kwargs,
|
**kwargs,
|
||||||
@@ -454,14 +448,10 @@ class GoogleTTSService(TTSService):
|
|||||||
if credentials:
|
if credentials:
|
||||||
# Use provided credentials JSON string
|
# Use provided credentials JSON string
|
||||||
json_account_info = json.loads(credentials)
|
json_account_info = json.loads(credentials)
|
||||||
creds = service_account.Credentials.from_service_account_info(
|
creds = service_account.Credentials.from_service_account_info(json_account_info)
|
||||||
json_account_info
|
|
||||||
)
|
|
||||||
elif credentials_path:
|
elif credentials_path:
|
||||||
# Use service account JSON file if provided
|
# Use service account JSON file if provided
|
||||||
creds = service_account.Credentials.from_service_account_file(
|
creds = service_account.Credentials.from_service_account_file(credentials_path)
|
||||||
credentials_path
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
creds, project_id = default(
|
creds, project_id = default(
|
||||||
@@ -509,9 +499,7 @@ class GoogleTTSService(TTSService):
|
|||||||
input=texttospeech_v1.StreamingSynthesisInput(text=text)
|
input=texttospeech_v1.StreamingSynthesisInput(text=text)
|
||||||
)
|
)
|
||||||
|
|
||||||
streaming_responses = await self._client.streaming_synthesize(
|
streaming_responses = await self._client.streaming_synthesize(request_generator())
|
||||||
request_generator()
|
|
||||||
)
|
|
||||||
await self.start_tts_usage_metrics(text)
|
await self.start_tts_usage_metrics(text)
|
||||||
|
|
||||||
yield TTSStartedFrame()
|
yield TTSStartedFrame()
|
||||||
|
|||||||
Reference in New Issue
Block a user