-
Notifications
You must be signed in to change notification settings - Fork 104
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
TimestampGranularities is not working properly #59
Comments
Thanks for the detailed report, we're investigating. |
+1. The following snippet only returns segment and not word granularity. Curl works fine transcriptionParams := openai.AudioTranscriptionNewParams{
File: openai.F(reader),
Model: openai.F(openai.AudioModelWhisper1),
Language: openai.F("en"),
Prompt: openai.F(promtp),
ResponseFormat: openai.F(openai.AudioResponseFormatVerboseJSON),
TimestampGranularities: openai.F([]openai.AudioTranscriptionNewParamsTimestampGranularity{
openai.AudioTranscriptionNewParamsTimestampGranularityWord,
}),
} |
Current workaround that I did is by manually overwriting the RequestBody using body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
fileWriter, err := writer.CreateFormFile("file", audioPath)
if err != nil {
return res, err
}
file, err := os.Open(audioPath)
if err != nil {
return res, err
}
_, err = io.Copy(fileWriter, file)
if err != nil {
return res, err
}
writer.WriteField("model", "whisper-1")
writer.WriteField("timestamp_granularities[]", "word")
writer.WriteField("timestamp_granularities[]", "segment")
writer.WriteField("response_format", "verbose_json")
writer.Close()
transcription, err := client.Audio.Transcriptions.New(
context.TODO(),
openai.AudioTranscriptionNewParams{
File: file,
Model: openai.AudioModelWhisper1,
TimestampGranularities: []string{"word", "segment"},
ResponseFormat: openai.AudioResponseFormatVerboseJSON,
},
option.WithRequestBody(writer.FormDataContentType(), body),
)
// ... continue Not the prettiest workaround, but it works for now. I don't think you also need the full openai.AudioTranscriptionNewParams parameter (second parameter) since you're over-writing it later on. |
Currently it is only possible to get segment timestamps but no other.
It is possible to set other granularities in the client and in the api, but it looks like the form data request from the client is not correct.
Looks like the client sets the wrong name (
timestamp_granularities.0
/timestamp_granularities.1
instead oftimestamp_granularities[]
). The request via curl works without problems.The text was updated successfully, but these errors were encountered: