-
Notifications
You must be signed in to change notification settings - Fork 23
/
transcription.go
71 lines (61 loc) · 2.56 KB
/
transcription.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
64
65
66
67
68
69
70
71
package plivo
type TranscriptionService struct {
client *Client
}
type GetRecordingTranscriptionRequest struct {
TranscriptionID string `json:"transcription_id"`
TranscriptionType string `json:"type"`
}
type TranscriptionCallbackUrlStruct struct {
TranscriptionCallbackUrl string `json:"transcription_callback_url,omitempty" url:"transcription_callback_url,omitempty"`
}
type RecordingTranscriptionRequest struct {
RecordingID string `json:"recording_id"`
TranscriptionCallbackUrl string `json:"transcription_callback_url,omitempty" url:"transcription_callback_url,omitempty"`
}
type DeleteRecordingTranscriptionRequest struct {
TranscriptionID string `json:"transcription_id"`
}
type GetRecordingTranscriptionParams struct {
Type string `url:"type"`
}
type GetRecordingTranscriptionResponse struct {
APIID string `json:"api_id"`
Cost float64 `json:"cost"`
Rate float64 `json:"rate"`
RecordingDurationMs float64 `json:"recording_duration_ms"`
RecordingStartMs float64 `json:"recording_start_ms"`
Status string `json:"status"`
Transcription interface{} `json:"transcription"`
}
func (service *TranscriptionService) CreateRecordingTranscription(request RecordingTranscriptionRequest) (response map[string]interface{}, err error) {
param := TranscriptionCallbackUrlStruct{TranscriptionCallbackUrl: request.TranscriptionCallbackUrl}
req, err := service.client.NewRequest("POST", param, "Transcription/%s", request.RecordingID)
if err != nil {
return
}
response = make(map[string]interface{})
err = service.client.ExecuteRequest(req, &response, isVoiceRequest())
return
}
func (service *TranscriptionService) GetRecordingTranscription(request GetRecordingTranscriptionRequest) (response *GetRecordingTranscriptionResponse, err error) {
params := GetRecordingTranscriptionParams{
Type: request.TranscriptionType,
}
req, err := service.client.NewRequest("GET", params, "Transcription/%s", request.TranscriptionID)
if err != nil {
return
}
response = &GetRecordingTranscriptionResponse{}
err = service.client.ExecuteRequest(req, response, isVoiceRequest())
return
}
func (service *TranscriptionService) DeleteRecordingTranscription(request DeleteRecordingTranscriptionRequest) (response map[string]interface{}, err error) {
req, err := service.client.NewRequest("DELETE", nil, "Transcription/%s", request.TranscriptionID)
if err != nil {
return
}
response = make(map[string]interface{})
err = service.client.ExecuteRequest(req, &response, isVoiceRequest())
return
}