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 <rzubov@aintsys.com>
This commit is contained in:
26
audio.go
26
audio.go
@@ -20,9 +20,11 @@ const (
|
|||||||
type AudioResponseFormat string
|
type AudioResponseFormat string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AudioResponseFormatJSON AudioResponseFormat = "json"
|
AudioResponseFormatJSON AudioResponseFormat = "json"
|
||||||
AudioResponseFormatSRT AudioResponseFormat = "srt"
|
AudioResponseFormatText AudioResponseFormat = "text"
|
||||||
AudioResponseFormatVTT AudioResponseFormat = "vtt"
|
AudioResponseFormatSRT AudioResponseFormat = "srt"
|
||||||
|
AudioResponseFormatVerboseJSON AudioResponseFormat = "verbose_json"
|
||||||
|
AudioResponseFormatVTT AudioResponseFormat = "vtt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AudioRequest represents a request structure for audio API.
|
// AudioRequest represents a request structure for audio API.
|
||||||
@@ -44,6 +46,22 @@ type AudioRequest struct {
|
|||||||
|
|
||||||
// AudioResponse represents a response structure for audio API.
|
// AudioResponse represents a response structure for audio API.
|
||||||
type AudioResponse struct {
|
type AudioResponse struct {
|
||||||
|
Task string `json:"task"`
|
||||||
|
Language string `json:"language"`
|
||||||
|
Duration float64 `json:"duration"`
|
||||||
|
Segments []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Seek int `json:"seek"`
|
||||||
|
Start float64 `json:"start"`
|
||||||
|
End float64 `json:"end"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
Tokens []int `json:"tokens"`
|
||||||
|
Temperature float64 `json:"temperature"`
|
||||||
|
AvgLogprob float64 `json:"avg_logprob"`
|
||||||
|
CompressionRatio float64 `json:"compression_ratio"`
|
||||||
|
NoSpeechProb float64 `json:"no_speech_prob"`
|
||||||
|
Transient bool `json:"transient"`
|
||||||
|
} `json:"segments"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +114,7 @@ func (c *Client) callAudioAPI(
|
|||||||
|
|
||||||
// HasJSONResponse returns true if the response format is JSON.
|
// HasJSONResponse returns true if the response format is JSON.
|
||||||
func (r AudioRequest) HasJSONResponse() bool {
|
func (r AudioRequest) HasJSONResponse() bool {
|
||||||
return r.Format == "" || r.Format == AudioResponseFormatJSON
|
return r.Format == "" || r.Format == AudioResponseFormatJSON || r.Format == AudioResponseFormatVerboseJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// audioMultipartForm creates a form with audio file contents and the name of the model to use for
|
// audioMultipartForm creates a form with audio file contents and the name of the model to use for
|
||||||
|
|||||||
Reference in New Issue
Block a user