teachingAssistant / src /domain /interfaces /speech_synthesis.py
Michael Hu
Create domain service interfaces
55e29e2
raw
history blame
1.34 kB
"""Speech synthesis service interface."""
from abc import ABC, abstractmethod
from typing import Iterator, TYPE_CHECKING
if TYPE_CHECKING:
from ..models.speech_synthesis_request import SpeechSynthesisRequest
from ..models.audio_content import AudioContent
from ..models.audio_chunk import AudioChunk
class ISpeechSynthesisService(ABC):
"""Interface for speech synthesis services."""
@abstractmethod
def synthesize(self, request: 'SpeechSynthesisRequest') -> 'AudioContent':
"""
Synthesize speech from text.
Args:
request: The speech synthesis request containing text and voice settings
Returns:
AudioContent: The synthesized audio
Raises:
SpeechSynthesisException: If synthesis fails
"""
pass
@abstractmethod
def synthesize_stream(self, request: 'SpeechSynthesisRequest') -> Iterator['AudioChunk']:
"""
Synthesize speech from text as a stream.
Args:
request: The speech synthesis request containing text and voice settings
Returns:
Iterator[AudioChunk]: Stream of audio chunks
Raises:
SpeechSynthesisException: If synthesis fails
"""
pass