Files
life-echo/api/app/ports/tts.py

16 lines
479 B
Python
Raw Permalink Normal View History

"""TTSProvider port — 文字转语音能力契约。"""
from typing import Protocol, runtime_checkable
@runtime_checkable
class TTSProvider(Protocol):
async def synthesize(
self, text: str, voice: str = "alloy", *, language: str = "zh"
) -> bytes:
"""Convert text to speech audio bytes.
language: 'zh' or 'en' 调用方应使用用户语言偏好与正文语种无关 adapter 按自身能力解释
"""
...