-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
42 lines (37 loc) · 1.07 KB
/
api.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
package api
import (
"context"
"io"
)
// UploadData keeps structure for upload method
type UploadData struct {
Params map[string]string
Files map[string]io.Reader
}
// StatusData keeps structure for status method
type StatusData struct {
ID string
Text string
Completed bool
ErrorCode string
Error string
Status string
Progress int
AudioReady bool
AvResults []string
RecognizedText string `json:"recognizedText,omitempty"`
}
// FileData contains name and data
type FileData struct {
Name string
Content []byte
}
// Transcriber provides transcription
type Transcriber interface {
Upload(ctx context.Context, audioFunc func(context.Context) (*UploadData, func(), error)) (string, error)
HookToStatus(ctx context.Context, ID string) (<-chan StatusData, func(), error)
GetStatus(ctx context.Context, ID string) (*StatusData, error)
GetAudio(ctx context.Context, ID string) (*FileData, error)
GetResult(ctx context.Context, ID, name string) (*FileData, error)
Clean(ctx context.Context, ID string) error
}