-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Adds support for audio captioning with Whisper #267
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #267 +/- ##
==========================================
+ Coverage 91.45% 92.26% +0.80%
==========================================
Files 22 22
Lines 620 659 +39
==========================================
+ Hits 567 608 +41
+ Misses 39 37 -2
Partials 14 14
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Thank you so much for the PR! 🙌🏻 |
audio.go
Outdated
@@ -21,6 +28,7 @@ type AudioRequest struct { | |||
Prompt string // For translation, it should be in English | |||
Temperature float32 | |||
Language string // For translation, just do not use it. It seems "en" works, not confirmed... | |||
Format string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's maybe make typechecker work for us a little bit here?
type AudioResponseFormat string
const (
AudioResponseFormatJSON AudioResponseFormat = "json"
AudioResponseFormatSRT AudioResponseFormat = "srt"
AudioResponseFormatVTT AudioResponseFormat = "vtt"
)
type AudioRequest struct {
...
Format AudioResponseFormat
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done
client.go
Outdated
return decodeResponse(v, *res) | ||
} | ||
|
||
func decodeResponse(v interface{}, res http.Response) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func decodeResponse(v interface{}, res http.Response) error { | |
func decodeResponse(v any, res http.Response) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also rename v
to something sensible here and in sendRequest
, maybe response
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have:
- Used
any
- Updated
decodeResponse
arguments tobody io.Reader, v any
- This ordering is a little nicer (input/output)
- I struggled to come up with a good name for
v
- this is what is used in thejson
library to mean any value that we will decode into... so I feel like it is a better name than response which is used byhttp
(at least in this context)
Closes #143
Allows users to add a
Format:
argument to the request to get captions from the audio apis.Demonstration (using the same code added for README)
Screen.Recording.2023-04-19.at.4.13.29.PM.mov
Broke
decodeResponse
out of client, because cyclomatic complexity got above 20 with the string response changes.Added tests for
decodeResponse
to not decrease code coverage