-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtranscriptions.go
33 lines (27 loc) · 949 Bytes
/
transcriptions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package goopenai
import (
"context"
"encoding/json"
)
type CreateTranscriptionsRequest struct {
File string `json:"file,omitempty"`
Model string `json:"model,omitempty"`
Prompt string `json:"prompt,omitempty"`
ResponseFormat string `json:"response_format,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Language string `json:"language,omitempty"`
}
type CreateTranscriptionsResponse struct {
Text string `json:"text,omitempty"`
}
func (c *Client) CreateTranscriptionsRaw(ctx context.Context, r *CreateTranscriptionsRequest) ([]byte, error) {
return c.Post(ctx, transcriptionsUrl, r)
}
func (c *Client) CreateTranscriptions(ctx context.Context, r *CreateTranscriptionsRequest) (response *CreateTranscriptionsResponse, err error) {
raw, err := c.CreateTranscriptionsRaw(ctx, r)
if err != nil {
return nil, err
}
err = json.Unmarshal(raw, &response)
return response, err
}