From ee9424e6b9e6824538d9029e49ba55a3aedb68e2 Mon Sep 17 00:00:00 2001 From: Hoani Bryson Date: Sun, 5 Mar 2023 19:49:49 +1300 Subject: [PATCH] Add speech to text example in docs (#124) --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index c5ece9d..3a26a3d 100644 --- a/README.md +++ b/README.md @@ -134,3 +134,34 @@ func main() { } ``` + +
+Audio Speech-To-Text + +```go +package main + +import ( + "context" + "fmt" + + openai "github.com/sashabaranov/go-openai" +) + +func main() { + c := openai.NewClient("your token") + ctx := context.Background() + + req := openai.AudioRequest{ + Model: openai.Whisper1, + FilePath: "recording.mp3", + } + resp, err := c.CreateTranscription(ctx, req) + if err != nil { + fmt.Printf("Transcription error: %v\n", err) + return + } + fmt.Println(resp.Text) +} +``` +