refactor(tts): 简化火山TTS实现,移除可配置格式采样率等参数
重构了火山TTS的适配器与配置逻辑,移除了格式、采样率、model等可配置项,固定使用wav/24000Hz参数,简化请求流程并删除冗余的格式转换、WAV头拼装逻辑,同时更新文档与环境变量配置。
This commit is contained in:
+2
-8
@@ -115,14 +115,8 @@ func OpenaiTTSHandler(w http.ResponseWriter, r *http.Request) {
|
||||
speed = common.MaxSpeed
|
||||
}
|
||||
|
||||
// 将 OpenAI response_format 映射为火山 API 支持的格式
|
||||
var requestFormat string
|
||||
if req.ResponseFormat != "" {
|
||||
requestFormat = volcano.MapOpenAIFormat(req.ResponseFormat)
|
||||
}
|
||||
|
||||
ttsStart := time.Now()
|
||||
result, err := volcano.Synthesis(&setting.TTSConfig, volcanoClient, req.Input, speed, req.Voice, requestFormat)
|
||||
result, err := volcano.Synthesis(&setting.TTSConfig, volcanoClient, req.Input, speed)
|
||||
duration := time.Since(ttsStart)
|
||||
|
||||
if err != nil {
|
||||
@@ -135,7 +129,7 @@ func OpenaiTTSHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
service.GlobalStats.AddRequest(true, duration, "")
|
||||
|
||||
w.Header().Set("Content-Type", volcano.FormatContentType(result.Format))
|
||||
w.Header().Set("Content-Type", "audio/wav")
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(result.AudioData)))
|
||||
w.Header().Set("X-Request-Id", result.ReqID)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user