From ff8815d78c5e114aacea1b9a736a69015667725b Mon Sep 17 00:00:00 2001 From: ChaseRensberger Date: Tue, 8 Apr 2025 20:09:23 -0400 Subject: [PATCH] update model and correctly place defer --- examples/audio-text-to-speech/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/audio-text-to-speech/main.go b/examples/audio-text-to-speech/main.go index e432ae99..4b63af57 100644 --- a/examples/audio-text-to-speech/main.go +++ b/examples/audio-text-to-speech/main.go @@ -13,16 +13,18 @@ func main() { ctx := context.Background() res, err := client.Audio.Speech.New(ctx, openai.AudioSpeechNewParams{ - Model: openai.SpeechModelTTS1, + Model: openai.SpeechModelGPT4oMiniTTS, Input: `Why did the chicken cross the road? To get to the other side.`, ResponseFormat: openai.AudioSpeechNewParamsResponseFormatPCM, Voice: openai.AudioSpeechNewParamsVoiceAlloy, }) - defer res.Body.Close() + if err != nil { panic(err) } + defer res.Body.Close() + op := &oto.NewContextOptions{} op.SampleRate = 24000 op.ChannelCount = 1