fix lint
This commit is contained in:
parent
c180590799
commit
f087d8358b
1 changed files with 5 additions and 5 deletions
|
|
@ -139,7 +139,7 @@ func (t *OpenAITTSProvider) Synthesize(ctx context.Context, text string) (io.Rea
|
||||||
logger.DebugCF("voice-tts", "Starting TTS synthesis", map[string]any{"text_len": len(text)})
|
logger.DebugCF("voice-tts", "Starting TTS synthesis", map[string]any{"text_len": len(text)})
|
||||||
|
|
||||||
responseFormat := t.responseFormat
|
responseFormat := t.responseFormat
|
||||||
resp, err := t.doSpeechRequest(ctx, text, responseFormat)
|
stream, err := t.doSpeechRequest(ctx, text, responseFormat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var apiErr *openAITTSAPIError
|
var apiErr *openAITTSAPIError
|
||||||
if errors.As(err, &apiErr) && shouldRetryWithoutResponseFormat(apiErr.body) {
|
if errors.As(err, &apiErr) && shouldRetryWithoutResponseFormat(apiErr.body) {
|
||||||
|
|
@ -147,7 +147,7 @@ func (t *OpenAITTSProvider) Synthesize(ctx context.Context, text string) (io.Rea
|
||||||
"model": t.model,
|
"model": t.model,
|
||||||
})
|
})
|
||||||
responseFormat = ""
|
responseFormat = ""
|
||||||
resp, err = t.doSpeechRequest(ctx, text, responseFormat)
|
stream, err = t.doSpeechRequest(ctx, text, responseFormat)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -156,7 +156,7 @@ func (t *OpenAITTSProvider) Synthesize(ctx context.Context, text string) (io.Rea
|
||||||
|
|
||||||
fileExt, contentType := audioFileMetaForResponseFormat(responseFormat)
|
fileExt, contentType := audioFileMetaForResponseFormat(responseFormat)
|
||||||
return &openAITTSAudioStream{
|
return &openAITTSAudioStream{
|
||||||
ReadCloser: resp.Body,
|
ReadCloser: stream,
|
||||||
fileExt: fileExt,
|
fileExt: fileExt,
|
||||||
contentType: contentType,
|
contentType: contentType,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
@ -166,7 +166,7 @@ func (t *OpenAITTSProvider) doSpeechRequest(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
text string,
|
text string,
|
||||||
responseFormat string,
|
responseFormat string,
|
||||||
) (*http.Response, error) {
|
) (io.ReadCloser, error) {
|
||||||
reqBody := map[string]any{
|
reqBody := map[string]any{
|
||||||
"model": t.model,
|
"model": t.model,
|
||||||
"input": text,
|
"input": text,
|
||||||
|
|
@ -203,7 +203,7 @@ func (t *OpenAITTSProvider) doSpeechRequest(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp.Body, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldRetryWithoutResponseFormat(body string) bool {
|
func shouldRetryWithoutResponseFormat(body string) bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue