diff --git a/audio.go b/audio.go index 4cbe4fe64..ec4be0ecd 100644 --- a/audio.go +++ b/audio.go @@ -68,11 +68,15 @@ type AudioResponse struct { } type audioTextResponse struct { - Text string `json:"text"` + Text string httpHeader } +func (r *audioTextResponse) SetText(text string) { + r.Text = text +} + func (r *audioTextResponse) ToAudioResponse() AudioResponse { return AudioResponse{ Text: r.Text, diff --git a/client.go b/client.go index 056226c61..20f04836d 100644 --- a/client.go +++ b/client.go @@ -24,6 +24,10 @@ type Response interface { SetHeader(http.Header) } +type TextResponse interface { + SetText(string) +} + type httpHeader http.Header func (h *httpHeader) SetHeader(header http.Header) { @@ -195,6 +199,13 @@ func decodeResponse(body io.Reader, v any) error { if result, ok := v.(*string); ok { return decodeString(body, result) + } else if result, ok := v.(TextResponse); ok { + var text string + if err := decodeString(body, &text); err != nil { + return err + } + result.SetText(text) + return nil } return json.NewDecoder(body).Decode(v) }