Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for non json speech to text #621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
SetHeader(http.Header)
}

type TextResponse interface {
SetText(string)
}

type httpHeader http.Header

func (h *httpHeader) SetHeader(header http.Header) {
Expand Down Expand Up @@ -195,6 +199,13 @@

if result, ok := v.(*string); ok {
return decodeString(body, result)
} else if result, ok := v.(TextResponse); ok {

Check failure on line 202 in client.go

View workflow job for this annotation

GitHub Actions / Sanity check

shadow: declaration of "ok" shadows declaration at line 200 (govet)
var text string
if err := decodeString(body, &text); err != nil {
return err
}
result.SetText(text)
return nil
}
return json.NewDecoder(body).Decode(v)
}
Expand Down
Loading