package tts import "context" // Service 语音合成服务契约。 type Service interface { // SynthesizeStream 流式合成。 // textStream 接收句子级文本(由 Orchestrator 的句子切分器产出), // 返回的 channel 持续输出 MP3 音频 chunk。 SynthesizeStream(ctx context.Context, textStream <-chan string, opts Options) (<-chan Chunk, error) } // Options 合成参数。 type Options struct { Voice string // "alloy" | "nova" | "shimmer" 等 Speed float64 // 1.0 为正常语速 OutputFmt string // "mp3" — 固定使用 MP3 SampleRate int // 24000 } // Chunk 一个音频片段。 type Chunk struct { Audio []byte // MP3 音频数据(未 Base64 编码) IsLast bool // 当前句子是否为最后一片(每句结束时为 true) Final bool // 整轮 TTS 是否结束(所有句子合成完毕后为 true,此时 Audio 为 nil) }