- Introduced Volcengine as a new provider for both TTS and ASR services. - Updated configuration files to include Volcengine-specific parameters such as app_id, resource_id, and uid. - Enhanced the ASR service to support streaming mode with Volcengine's API. - Modified existing tests to validate the integration of Volcengine services. - Updated documentation to reflect the addition of Volcengine as a supported provider for TTS and ASR. - Refactored service factory to accommodate Volcengine alongside existing providers.
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""TTS extension port contracts."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import AsyncIterator, Optional, Protocol
|
|
|
|
from providers.common.base import TTSChunk
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class TTSServiceSpec:
|
|
"""Resolved runtime configuration for TTS service creation."""
|
|
|
|
provider: str
|
|
voice: str
|
|
sample_rate: int
|
|
speed: float = 1.0
|
|
api_key: Optional[str] = None
|
|
api_url: Optional[str] = None
|
|
model: Optional[str] = None
|
|
app_id: Optional[str] = None
|
|
resource_id: Optional[str] = None
|
|
cluster: Optional[str] = None
|
|
uid: Optional[str] = None
|
|
mode: str = "commit"
|
|
|
|
|
|
class TTSPort(Protocol):
|
|
"""Port for speech synthesis providers."""
|
|
|
|
async def connect(self) -> None:
|
|
"""Establish connection to TTS provider."""
|
|
|
|
async def disconnect(self) -> None:
|
|
"""Release TTS resources."""
|
|
|
|
async def synthesize(self, text: str) -> bytes:
|
|
"""Synthesize complete PCM payload for text."""
|
|
|
|
async def synthesize_stream(self, text: str) -> AsyncIterator[TTSChunk]:
|
|
"""Stream synthesized PCM chunks for text."""
|
|
|
|
async def cancel(self) -> None:
|
|
"""Cancel an in-flight synthesis request."""
|