fix: pipeline.go TTS 输出格式/采样率从配置读取
- New() 改为接收 *config.Config 参数 - OutputFmt/SampleRate 从 config.AI.TTS 读取
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/hhs/camtalk/internal/ai/llm"
|
"github.com/hhs/camtalk/internal/ai/llm"
|
||||||
"github.com/hhs/camtalk/internal/ai/stt"
|
"github.com/hhs/camtalk/internal/ai/stt"
|
||||||
"github.com/hhs/camtalk/internal/ai/tts"
|
"github.com/hhs/camtalk/internal/ai/tts"
|
||||||
|
"github.com/hhs/camtalk/internal/config"
|
||||||
"github.com/hhs/camtalk/internal/logger"
|
"github.com/hhs/camtalk/internal/logger"
|
||||||
"github.com/hhs/camtalk/internal/models"
|
"github.com/hhs/camtalk/internal/models"
|
||||||
"github.com/hhs/camtalk/internal/session"
|
"github.com/hhs/camtalk/internal/session"
|
||||||
@@ -18,13 +19,15 @@ import (
|
|||||||
|
|
||||||
// Pipeline 实现 Orchestrator 接口,管理 STT → LLM → TTS 流式管道。
|
// Pipeline 实现 Orchestrator 接口,管理 STT → LLM → TTS 流式管道。
|
||||||
type Pipeline struct {
|
type Pipeline struct {
|
||||||
sttService stt.Service
|
sttService stt.Service
|
||||||
llmService llm.Service
|
llmService llm.Service
|
||||||
ttsService tts.Service
|
ttsService tts.Service
|
||||||
sessionMgr session.Manager
|
sessionMgr session.Manager
|
||||||
model string // LLM 模型名,用于 llm_done 上报
|
model string // LLM 模型名,用于 llm_done 上报
|
||||||
ttsVoice string // TTS 音色
|
ttsVoice string // TTS 音色
|
||||||
ttsSpeed float64 // TTS 语速
|
ttsSpeed float64 // TTS 语速
|
||||||
|
ttsOutputFmt string // TTS 输出格式
|
||||||
|
ttsSampleRate int // TTS 输出采样率
|
||||||
}
|
}
|
||||||
|
|
||||||
// New 创建 Pipeline 实例。
|
// New 创建 Pipeline 实例。
|
||||||
@@ -33,18 +36,18 @@ func New(
|
|||||||
llmService llm.Service,
|
llmService llm.Service,
|
||||||
ttsService tts.Service,
|
ttsService tts.Service,
|
||||||
sessionMgr session.Manager,
|
sessionMgr session.Manager,
|
||||||
model string,
|
cfg *config.Config,
|
||||||
ttsVoice string,
|
|
||||||
ttsSpeed float64,
|
|
||||||
) *Pipeline {
|
) *Pipeline {
|
||||||
return &Pipeline{
|
return &Pipeline{
|
||||||
sttService: sttService,
|
sttService: sttService,
|
||||||
llmService: llmService,
|
llmService: llmService,
|
||||||
ttsService: ttsService,
|
ttsService: ttsService,
|
||||||
sessionMgr: sessionMgr,
|
sessionMgr: sessionMgr,
|
||||||
model: model,
|
model: cfg.AI.LLM.Model,
|
||||||
ttsVoice: ttsVoice,
|
ttsVoice: cfg.AI.TTS.Voice,
|
||||||
ttsSpeed: ttsSpeed,
|
ttsSpeed: cfg.AI.TTS.Speed,
|
||||||
|
ttsOutputFmt: cfg.AI.TTS.OutputFormat,
|
||||||
|
ttsSampleRate: cfg.AI.TTS.SampleRate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,8 +317,8 @@ func (p *Pipeline) synthesizeTTS(
|
|||||||
ttsStream, err := p.ttsService.SynthesizeStream(ctx, sentenceCh, tts.Options{
|
ttsStream, err := p.ttsService.SynthesizeStream(ctx, sentenceCh, tts.Options{
|
||||||
Voice: p.ttsVoice,
|
Voice: p.ttsVoice,
|
||||||
Speed: p.ttsSpeed,
|
Speed: p.ttsSpeed,
|
||||||
OutputFmt: "mp3",
|
OutputFmt: p.ttsOutputFmt,
|
||||||
SampleRate: 24000,
|
SampleRate: p.ttsSampleRate,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorw("TTS 合成启动失败", "error", err)
|
log.Errorw("TTS 合成启动失败", "error", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user