Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions examples/audio-transcriptions/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bytes"
"context"
"os"

Expand All @@ -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)
}