Skip to content

Commit ee9424e

Browse files
authored
Add speech to text example in docs (#124)
1 parent 8be4dfe commit ee9424e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,34 @@ func main() {
134134
}
135135
```
136136
</details>
137+
138+
<details>
139+
<summary>Audio Speech-To-Text</summary>
140+
141+
```go
142+
package main
143+
144+
import (
145+
"context"
146+
"fmt"
147+
148+
openai "github.com/sashabaranov/go-openai"
149+
)
150+
151+
func main() {
152+
c := openai.NewClient("your token")
153+
ctx := context.Background()
154+
155+
req := openai.AudioRequest{
156+
Model: openai.Whisper1,
157+
FilePath: "recording.mp3",
158+
}
159+
resp, err := c.CreateTranscription(ctx, req)
160+
if err != nil {
161+
fmt.Printf("Transcription error: %v\n", err)
162+
return
163+
}
164+
fmt.Println(resp.Text)
165+
}
166+
```
167+
</details>

0 commit comments

Comments
 (0)