2 Commits

Author SHA1 Message Date
aa701237ff add new error type 2025-03-13 14:04:06 -07:00
Jose Ramirez
29fa401714 s/speeh/speech (#11) 2025-03-04 00:20:55 -08:00
3 changed files with 16 additions and 5 deletions

View File

@@ -104,7 +104,7 @@ func (c *Client) ConvertSpeechToTextFromReader(ctx context.Context, reader io.Re
case 422:
fallthrough
default:
ve := types.ValidationError{}
ve := types.ParamError{}
defer res.Body.Close()
jerr := json.NewDecoder(res.Body).Decode(&ve)
if jerr != nil {

View File

@@ -202,6 +202,17 @@ func (ve ValidationError) Error() string {
return fmt.Sprintf("%s %s: ", ve.Type_, ve.Msg)
}
type ParamError struct {
Detail struct {
Status string `json:"status"`
Message string `json:"message"`
} `json:"detail"`
}
func (pe ParamError) Error() string {
return fmt.Sprintf("%s %s: ", pe.Detail.Status, pe.Detail.Message)
}
type VerificationAttemptResponseModel struct {
Text string `json:"text"`
DateUnix int32 `json:"date_unix"`
@@ -242,16 +253,16 @@ const (
TimestampsGranularityCharacter TimestampsGranularity = "character"
)
type SpeehToTextModel string
type SpeechToTextModel string
const (
SpeehToTextModelScribeV1 SpeehToTextModel = "scribe_v1"
SpeechToTextModelScribeV1 SpeechToTextModel = "scribe_v1"
)
// SpeechToTextRequest represents a request to the speech-to-text API
type SpeechToTextRequest struct {
// The ID of the model to use for transcription (currently only 'scribe_v1')
ModelID SpeehToTextModel `json:"model_id"`
ModelID SpeechToTextModel `json:"model_id"`
// ISO-639-1 or ISO-639-3 language code. If not specified, language is auto-detected
LanguageCode string `json:"language_code,omitempty"`
// Whether to tag audio events like (laughter), (footsteps), etc.

View File

@@ -17,7 +17,7 @@ func main() {
filePath := os.Args[1]
resp, err := client.ConvertSpeechToText(ctx, filePath, types.SpeechToTextRequest{
ModelID: types.SpeehToTextModelScribeV1,
ModelID: types.SpeechToTextModelScribeV1,
TimestampsGranularity: types.TimestampsGranularityWord,
Diarize: true,
})