Add speech to text example in docs (#124)

This commit is contained in:
Hoani Bryson
2023-03-05 19:49:49 +13:00
committed by GitHub
parent 8be4dfe746
commit ee9424e6b9

View File

@@ -134,3 +134,34 @@ func main() {
}
```
</details>
<details>
<summary>Audio Speech-To-Text</summary>
```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)
}
```
</details>