-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
api_ai_recognize_speech_file.go
90 lines (78 loc) · 3.85 KB
/
api_ai_recognize_speech_file.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Code generated by lark_sdk_gen. DO NOT EDIT.
/**
* Copyright 2022 chyroc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package lark
import (
"context"
)
// RecognizeSpeechFile 语音文件识别接口, 上传整段语音文件进行一次性识别。接口适合 60 秒以内音频识别。
//
// 单租户限流: 20QPS, 同租户下的应用没有限流, 共享本租户的 20QPS 限流。免费版不支持调用。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/ai/speech_to_text-v1/speech/file_recognize
// new doc: https://open.feishu.cn/document/server-docs/ai/speech_to_text-v1/file_recognize
func (r *AIService) RecognizeSpeechFile(ctx context.Context, request *RecognizeSpeechFileReq, options ...MethodOptionFunc) (*RecognizeSpeechFileResp, *Response, error) {
if r.cli.mock.mockAIRecognizeSpeechFile != nil {
r.cli.Log(ctx, LogLevelDebug, "[lark] AI#RecognizeSpeechFile mock enable")
return r.cli.mock.mockAIRecognizeSpeechFile(ctx, request, options...)
}
req := &RawRequestReq{
Scope: "AI",
API: "RecognizeSpeechFile",
Method: "POST",
URL: r.cli.openBaseURL + "/open-apis/speech_to_text/v1/speech/file_recognize",
Body: request,
MethodOption: newMethodOption(options),
NeedTenantAccessToken: true,
}
resp := new(recognizeSpeechFileResp)
response, err := r.cli.RawRequest(ctx, req, resp)
return resp.Data, response, err
}
// MockAIRecognizeSpeechFile mock AIRecognizeSpeechFile method
func (r *Mock) MockAIRecognizeSpeechFile(f func(ctx context.Context, request *RecognizeSpeechFileReq, options ...MethodOptionFunc) (*RecognizeSpeechFileResp, *Response, error)) {
r.mockAIRecognizeSpeechFile = f
}
// UnMockAIRecognizeSpeechFile un-mock AIRecognizeSpeechFile method
func (r *Mock) UnMockAIRecognizeSpeechFile() {
r.mockAIRecognizeSpeechFile = nil
}
// RecognizeSpeechFileReq ...
type RecognizeSpeechFileReq struct {
Speech *RecognizeSpeechFileReqSpeech `json:"speech,omitempty"` // 语音资源
Config *RecognizeSpeechFileReqConfig `json:"config,omitempty"` // 配置属性
}
// RecognizeSpeechFileReqConfig ...
type RecognizeSpeechFileReqConfig struct {
FileID string `json:"file_id,omitempty"` // 仅包含字母数字和下划线的 16 位字符串作为文件的标识, 用户生成, 示例值: "qwe12dd34567890w"
Format string `json:"format,omitempty"` // 语音格式, 目前仅支持: pcm, 示例值: "pcm"
EngineType string `json:"engine_type,omitempty"` // 引擎类型, 目前仅支持: 16k_auto 中英混合, 示例值: "16k_auto"
}
// RecognizeSpeechFileReqSpeech ...
type RecognizeSpeechFileReqSpeech struct {
Speech *string `json:"speech,omitempty"` // pcm格式音频文件(文件识别)或音频分片(流式识别)经base64编码后的内容, 示例值: "PdmrfE267Cd/Z9KpmNFh71A2PSJZxSp7+8upCg["
}
// RecognizeSpeechFileResp ...
type RecognizeSpeechFileResp struct {
RecognitionText string `json:"recognition_text,omitempty"` // 语音识别后的文本信息
}
// recognizeSpeechFileResp ...
type recognizeSpeechFileResp struct {
Code int64 `json:"code,omitempty"` // 错误码, 非 0 表示失败
Msg string `json:"msg,omitempty"` // 错误描述
Data *RecognizeSpeechFileResp `json:"data,omitempty"`
Error *ErrorDetail `json:"error,omitempty"`
}