-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnls.d.ts
217 lines (195 loc) · 4.67 KB
/
nls.d.ts
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import RPCClient from '@alicloud/pop-core';
// Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
// Project: [~THE PROJECT NAME~]
// Definitions by: [~YOUR NAME~] <[~A URL FOR YOU~]>
/*~ This is the module template file for class modules.
*~ You should rename it to index.d.ts and place it in a folder with the same name as the module.
*~ For example, if you were writing a file for "super-greeter", this
*~ file should be 'super-greeter/index.d.ts'
*/
/*~ Note that ES6 modules cannot directly export class objects.
*~ This file should be imported using the CommonJS-style:
*~ import x = require('someLibrary');
*~
*~ Refer to the documentation to understand common
*~ workarounds for this limitation of ES6 modules.
*/
/*~ This declaration specifies that the class constructor function
*~ is the exported object from the file
*/
declare namespace AliyunNLS {
export class AliyunTTS {
/**
*应用Key
*
* @type {string}
* @memberof AliTTS
*/
appKey: string;
/**
*密钥配置
*
* @type {RpcConfig}
* @memberof AliTTS
*/
rpcConfig: AliyunTTS.Config;
/**
*客户端
*
* @type {RPCClient}
* @memberof AliTTS
*/
client: RPCClient;
/**
*Token 值
*
* @type {string}
* @memberof AliyunTTS
*/
token: string;
/**
*token 过期时间
*
* @type {number}
* @memberof AliyunTTS
*/
tokenExpire: number;
constructor(rpcConfig: AliyunTTS.Config, appKey?: string);
/**
* debug log
* @param message
* @param level
*/
log(message: Object, level: string): void;
/**
* 获取token
* @returns
*/
getToken(): Promise<string>;
/**
* 开始转换任务,并获取任务ID
* @param text 文本内容
* @param options 转换选项
* @param appKey 使用的应用key
* @returns
*/
task(
text: string,
options?: AliyunTTS.TTSOption,
appKey?: string
): Promise<string>;
/**
* 获取转换状态
* @param taskId
* @param appKey
* @returns
*/
status(taskId: string, appKey?: string): Promise<AliyunTTS.TTSComplete>;
/**
* 同步完成转换
* @param text 文字
* @param options 转换配置
* @param 轮训时间 秒
*/
taskSync(
text: string,
options: AliyunTTS.TTSOption,
interval?: number
): Promise<AliyunTTS.TTSComplete>;
/**
*检查配置
* @returns
*/
checkConfig(): Promise<boolean>;
}
export namespace AliyunTTS {
export interface Config extends RPCClient.Config {
nlsUrl: string;
}
/**
* 长语音合成参数
*/
export interface TTSOption {
appKey?: string;
/**
* 音频编码格式,支持pcm/wav/mp3格式,默认是pcm。
*/
format?: string;
/**
* 音频采样率,支持16000Hz和8000Hz,默认是16000Hz。
*/
sample_rate?: number;
/**
* 发音人,默认是xiaoyun。更多发音人请参见接口说明。 https://help.aliyun.com/document_detail/130509.htm?spm=a2c4g.11186623.0.0.442a38adeflvK0#topic-2606811
*/
voice?: string;
/**
* 音量,范围是0~100,默认50。
*/
volume?: number;
/**
* 语速,范围是0-100,默认是50。
*/
speech_rate?: number;
/**
* 语调,范围是0-100,默认是50。
*/
pitch_rate?: number;
/**
* 是否启用句级时间戳功能,默认值为false。
*/
enable_subtitle?: boolean;
/**
* 是否启用回调功能,默认值为false。
*/
enable_notify?: boolean;
/**
* 回调服务的地址。当enable_notify取值为true时,本字段必填。
* URL支持HTTP/HTTPS协议,Host不能使用IP地址。
*/
notify_url?: string;
}
/**
* 合成的返回数据定义
*/
export interface TTSComplete {
/**
* 返回的任务ID
*/
task_id: string;
/**
* 合成的音频URL
*/
audio_address: string;
/**
* 回调地址
*/
notify_custom: string;
/**
* 句级时间戳对象
*/
sentences: any;
/**
* 使用的APP Key
*/
appKey: string;
/**
* 合成选项
*/
options: TTSOption;
/**
* 合成文本
*/
text: string;
/**
* 合成开始时间(毫秒时间戳)
*/
startTime: number;
/**
* 合成耗时(毫秒)
*/
elapsed: number;
}
}
}
export = AliyunNLS;