-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_transcribe.go
63 lines (48 loc) · 1.68 KB
/
task_transcribe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// go-mirage-api
//
// Copyright 2023, Valerian Saliou
// Author: Valerian Saliou <[email protected]>
package mirage
// TranscribeSpeechRequest mapping
type TranscribeSpeechRequest struct {
Locale *TranscribeSpeechRequestLocale `json:"locale,omitempty"`
Media TranscribeSpeechRequestMedia `json:"media"`
}
// TranscribeSpeechRequestLocale mapping
type TranscribeSpeechRequestLocale struct {
To string `json:"to"`
}
// TranscribeSpeechRequestMedia mapping
type TranscribeSpeechRequestMedia struct {
Type *string `json:"type,omitempty"`
URL string `json:"url"`
}
// TranscribeSpeechResponseData mapping
type TranscribeSpeechResponseData struct {
Data *TranscribeSpeechResponse `json:"data"`
}
// TranscribeSpeechResponse mapping
type TranscribeSpeechResponse struct {
Locale string `json:"locale"`
Parts []TranscribeSpeechResponsePart `json:"parts"`
}
// TranscribeSpeechResponse mapping
type TranscribeSpeechResponsePart struct {
Start float32 `json:"start"`
End float32 `json:"end"`
Text string `json:"text"`
}
// String returns the string representation of TranscribeSpeechResponse
func (instance TranscribeSpeechResponse) String() string {
return Stringify(instance)
}
// TranscribeSpeech transcribe speech from an audio file to text.
func (service *TaskService) TranscribeSpeech(ctx RequestContext, data TranscribeSpeechRequest) (*TranscribeSpeechResponse, error) {
req, _ := service.client.NewRequest("POST", "task/transcribe/speech", data, ctx)
result := new(TranscribeSpeechResponseData)
_, err := service.client.Do(req, result)
if err != nil {
return nil, err
}
return result.Data, err
}