univoice 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/univoice.svg)](https://www.npmjs.com/package/univoice)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/univoice.svg)](https://www.npmjs.com/package/univoice)
11
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
12
12
  [![codecov](https://codecov.io/gh/shenjingnan/univoice/branch/main/graph/badge.svg)](https://codecov.io/gh/shenjingnan/univoice)
13
13
 
14
14
  **统一的 TTS(文字转语音)和 ASR(语音识别)SDK**
@@ -189,13 +189,14 @@ const asr = createASR({
189
189
  });
190
190
 
191
191
  const audioBuffer = readFileSync('audio.mp3');
192
- const result = await asr.recognize({
193
- audio: audioBuffer,
194
- });
195
192
 
196
- console.log(`识别结果: ${result.text}`);
197
- console.log(`语言: ${result.language}`);
198
- console.log(`时长: ${result.duration}s`);
193
+ // 流式识别
194
+ for await (const chunk of asr.listen(audioBuffer)) {
195
+ console.log(`识别文本: ${chunk.text}`);
196
+ if (chunk.isFinal) {
197
+ console.log('识别完成');
198
+ }
199
+ }
199
200
  ```
200
201
 
201
202
  ---
@@ -269,7 +270,7 @@ const asr = createASR({
269
270
 
270
271
  | 方法 | 说明 | 返回类型 |
271
272
  |------|------|----------|
272
- | `asr.recognize(request)` | 语音识别 | `Promise<ASRResponse>` |
273
+ | `asr.listen(audio)` | 流式语音识别 | `AsyncIterable<ASRStreamChunk>` |
273
274
 
274
275
  #### 工具函数
275
276
 
@@ -462,7 +463,7 @@ src/
462
463
 
463
464
  ## 许可证
464
465
 
465
- [MIT](LICENSE)
466
+ [Apache-2.0](LICENSE)
466
467
 
467
468
  ---
468
469