feat: 弃用腾讯tts,该用火山引擎tts
This commit is contained in:
@@ -114,7 +114,7 @@ func (s *ProgramService) IncrementPlayCount(id string) error {
|
||||
}
|
||||
|
||||
// GenerateTTS 生成TTS语音并更新节目 (异步)
|
||||
func (s *ProgramService) GenerateTTS(programId string) error {
|
||||
func (s *ProgramService) GenerateTTS(programId string, speaker string) error {
|
||||
// 1. 获取节目内容
|
||||
var program radio.RadioProgram
|
||||
if err := global.DB.Where("id = ?", programId).First(&program).Error; err != nil {
|
||||
@@ -125,17 +125,22 @@ func (s *ProgramService) GenerateTTS(programId string) error {
|
||||
return fmt.Errorf("节目内容为空")
|
||||
}
|
||||
|
||||
// 提前将状态标记为: 1正在生成音频
|
||||
if err := global.DB.Model(&radio.RadioProgram{}).Where("id = ?", programId).Update("audio_status", 1).Error; err != nil {
|
||||
global.Logger.Error(fmt.Sprintf("更新节目[%s]音频状态为正在生成失败", programId))
|
||||
// 容错处理: 虽然状态更新失败,但可以继续生成流程
|
||||
}
|
||||
|
||||
// 2. 调用TTS提交任务 (异步,后台处理)
|
||||
ttsReq := TTSTextToSpeechRequest{
|
||||
Text: program.Content,
|
||||
//VoiceType: 101001, // 智瑜 情感女声
|
||||
VoiceType: 101013, // 智辉 新闻男声
|
||||
Speed: 0, // 正常语速
|
||||
Volume: 0, // 正常音量
|
||||
ttsReq := TTSRequest{
|
||||
Text: program.Content,
|
||||
Speaker: speaker, // 如果为空,底层接口会默认赋予 zh_male_dayi_uranus_bigtts
|
||||
ProgramId: programId,
|
||||
}
|
||||
_, err := TTSServiceApp.SubmitTTSTask(ttsReq)
|
||||
if err != nil {
|
||||
// 提交失败,恢复原本状态 0:无音频
|
||||
global.DB.Model(&radio.RadioProgram{}).Where("id = ?", programId).Update("audio_status", 0)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user