diff --git a/handlers.go b/handlers.go index 33bf9d9..9e8db8e 100644 --- a/handlers.go +++ b/handlers.go @@ -259,9 +259,7 @@ func tts(c *gin.Context) { response, err := chatgpt.POSTconversation(translated_request, &secret, deviceId, chat_require.Token, arkoseToken, proofToken, proxy_url) if err != nil { - c.JSON(500, gin.H{ - "error": "error sending request", - }) + c.JSON(500, gin.H{"error": "error sending request"}) return } defer response.Body.Close() @@ -281,6 +279,8 @@ func tts(c *gin.Context) { data := chatgpt.GetTTS(&secret, deviceId, apiUrl, proxy_url) if data != nil { c.Data(200, ttsTypeMap[format], data) + } else { + c.JSON(500, gin.H{"error": "synthesize error"}) } chatgpt.RemoveConversation(&secret, deviceId, convId, proxy_url) } diff --git a/internal/chatgpt/request.go b/internal/chatgpt/request.go index a16b5c4..bea7b8e 100644 --- a/internal/chatgpt/request.go +++ b/internal/chatgpt/request.go @@ -593,6 +593,9 @@ func GetTTS(secret *tokens.Secret, deviceId string, url string, proxy string) [] return nil } defer response.Body.Close() + if response.StatusCode != http.StatusOK { + return nil + } blob, err := io.ReadAll(response.Body) if err != nil { return nil