generated from tailored/router-template
29 lines
1014 B
TypeScript
29 lines
1014 B
TypeScript
import { AsrWsClient } from '../asr-ws-big-model-client.ts';
|
|
import { audioPath, audioPath2, blankAudioPath, config } from './common.ts';
|
|
import fs from 'fs';
|
|
// const asr = new AsrWsClient('videos/asr_example.wav');
|
|
|
|
// tsx src/asr/provider/volcengine/test/asr-bigmodel.ts
|
|
const main = async () => {
|
|
const audioId = '123';
|
|
const asrClient = new AsrWsClient({
|
|
appid: config.VOLCENGINE_ASR_MODEL_APPID,
|
|
token: config.VOLCENGINE_ASR_MODEL_TOKEN,
|
|
});
|
|
asrClient.emitter.on('message', (result) => {
|
|
console.log('识别结果', JSON.stringify(result, null, 2));
|
|
})
|
|
asrClient.emitter.on('end', (result) => {
|
|
console.log('识别结束', JSON.stringify(result, null, 2));
|
|
})
|
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
const data = fs.readFileSync(audioPath);
|
|
await asrClient.sendVoiceFile(data);
|
|
// await asrClient.sendVoiceFile(fs.readFileSync(blankAudioPath));
|
|
asrClient.setIsEnd(true);
|
|
// await asrClient.sendVoiceFile(fs.readFileSync(audioPath2));
|
|
|
|
};
|
|
|
|
main();
|