diff --git a/examples/audio-transcriptions/main.go b/examples/audio-transcriptions/main.go index b5c3b39a..69ee0411 100644 --- a/examples/audio-transcriptions/main.go +++ b/examples/audio-transcriptions/main.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "context" "os" @@ -25,4 +26,21 @@ func main() { } println(transcription.Text) + + // Or if you have speech bytes, you have to wrap reader: + var speechBytes []byte // Assume this is filled with audio data + + speechReader := openai.File( + bytes.NewReader(speechBytes), "speech.mp3", "audio/mp3", + ) + + transcription, err = client.Audio.Transcriptions.New(ctx, openai.AudioTranscriptionNewParams{ + Model: openai.AudioModelWhisper1, + File: speechReader, + }) + if err != nil { + panic(err) + } + + println(transcription.Text) }