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:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user