Skip to content

Commit f0770cf

Browse files
romazuRoman Zubov
and
Roman Zubov
authored
audio: add items to AudioResponseFormat enum (#382)
* audio: add items to AudioResponseFormat enum * audio: expand AudioResponse struct to accommodate verbose json response --------- Co-authored-by: Roman Zubov <[email protected]>
1 parent ac25f31 commit f0770cf

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

audio.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ const (
2020
type AudioResponseFormat string
2121

2222
const (
23-
AudioResponseFormatJSON AudioResponseFormat = "json"
24-
AudioResponseFormatSRT AudioResponseFormat = "srt"
25-
AudioResponseFormatVTT AudioResponseFormat = "vtt"
23+
AudioResponseFormatJSON AudioResponseFormat = "json"
24+
AudioResponseFormatText AudioResponseFormat = "text"
25+
AudioResponseFormatSRT AudioResponseFormat = "srt"
26+
AudioResponseFormatVerboseJSON AudioResponseFormat = "verbose_json"
27+
AudioResponseFormatVTT AudioResponseFormat = "vtt"
2628
)
2729

2830
// AudioRequest represents a request structure for audio API.
@@ -44,6 +46,22 @@ type AudioRequest struct {
4446

4547
// AudioResponse represents a response structure for audio API.
4648
type AudioResponse struct {
49+
Task string `json:"task"`
50+
Language string `json:"language"`
51+
Duration float64 `json:"duration"`
52+
Segments []struct {
53+
ID int `json:"id"`
54+
Seek int `json:"seek"`
55+
Start float64 `json:"start"`
56+
End float64 `json:"end"`
57+
Text string `json:"text"`
58+
Tokens []int `json:"tokens"`
59+
Temperature float64 `json:"temperature"`
60+
AvgLogprob float64 `json:"avg_logprob"`
61+
CompressionRatio float64 `json:"compression_ratio"`
62+
NoSpeechProb float64 `json:"no_speech_prob"`
63+
Transient bool `json:"transient"`
64+
} `json:"segments"`
4765
Text string `json:"text"`
4866
}
4967

@@ -96,7 +114,7 @@ func (c *Client) callAudioAPI(
96114

97115
// HasJSONResponse returns true if the response format is JSON.
98116
func (r AudioRequest) HasJSONResponse() bool {
99-
return r.Format == "" || r.Format == AudioResponseFormatJSON
117+
return r.Format == "" || r.Format == AudioResponseFormatJSON || r.Format == AudioResponseFormatVerboseJSON
100118
}
101119

102120
// audioMultipartForm creates a form with audio file contents and the name of the model to use for

0 commit comments

Comments
 (0)