feat: 长文本语音合成
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"sundynix-go/global"
|
||||
@@ -160,7 +161,7 @@ func (t *TTSService) doSubmitTTSTask(req TTSTextToSpeechRequest) (string, error)
|
||||
// waitForResult 轮询查询任务结果,返回音频下载URL
|
||||
func (t *TTSService) waitForResult(taskId string) (string, error) {
|
||||
maxRetries := 30
|
||||
interval := 5 * time.Second
|
||||
interval := 15 * time.Second
|
||||
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
time.Sleep(interval)
|
||||
@@ -256,8 +257,9 @@ func (t *TTSService) uploadToOSS(audioData []byte, programId string) (string, er
|
||||
if !ok {
|
||||
return "", fmt.Errorf("获取MinIO客户端失败")
|
||||
}
|
||||
|
||||
key := fmt.Sprintf("audio/%s/%s.mp3", time.Now().Format("2006-01-02"), programId)
|
||||
timestamp := time.Now().UnixMicro()
|
||||
timestr := strconv.FormatInt(timestamp, 10)
|
||||
key := fmt.Sprintf("audio/%s/%s.mp3", time.Now().Format("2006-01-02"), programId+"-"+timestr)
|
||||
filename := fmt.Sprintf("program-%s.mp3", programId)
|
||||
|
||||
fileURL, err := minioClient.UploadBytes(audioData, key, "audio/mpeg")
|
||||
|
||||
Reference in New Issue
Block a user