Add speech to text example in docs (#124)
This commit is contained in:
31
README.md
31
README.md
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user