feat: 定义 TTS Service 接口(SynthesizeStream + Options/Chunk)
This commit is contained in:
25
backend/internal/ai/tts/tts.go
Normal file
25
backend/internal/ai/tts/tts.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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 // 是否为最后一片
|
||||
}
|
||||
Reference in New Issue
Block a user