Adds support for audio captioning with Whisper (#267)

* Add speech to text example in docs

* Add caption formats for audio transcription

* Add caption example to README

* Address sanity check errors

* Add tests for decodeResponse

* Use typechecker for audio response format

* Decoding response refactors
This commit is contained in:
Hoani Bryson
2023-04-21 01:07:04 +12:00
committed by GitHub
parent d6ab1b3a4f
commit ecdea45b67
5 changed files with 129 additions and 8 deletions

View File

@@ -1,6 +1,8 @@
package openai //nolint:testpackage // testing private field
import (
"bytes"
"io"
"testing"
)
@@ -20,3 +22,38 @@ func TestClient(t *testing.T) {
t.Errorf("Client does not contain proper orgID")
}
}
func TestDecodeResponse(t *testing.T) {
stringInput := ""
testCases := []struct {
name string
value interface{}
body io.Reader
}{
{
name: "nil input",
value: nil,
body: bytes.NewReader([]byte("")),
},
{
name: "string input",
value: &stringInput,
body: bytes.NewReader([]byte("test")),
},
{
name: "map input",
value: &map[string]interface{}{},
body: bytes.NewReader([]byte(`{"test": "test"}`)),
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := decodeResponse(tc.body, tc.value)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
})
}
}