generated from tailored/router-db-template
Refactor ASR module and remove deprecated AliAsrServer
- Introduced AsrRelatime class for real-time ASR using WebSocket. - Removed AliAsrServer and related files from the aliyun provider. - Updated base class for ASR to use WSServer for WebSocket connections. - Added new test cases for the updated ASR functionality. - Cleaned up unused imports and files across the project. - Adjusted TypeScript configuration for better module resolution. - Implemented silence generation for audio streaming.
This commit is contained in:
25
src/asr/provider/aliyun/nls/test/get-text.ts
Normal file
25
src/asr/provider/aliyun/nls/test/get-text.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { AliAsrServer } from '../aliyun-asr-server.ts';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
// const videoTestPath = path.join(process.cwd(), 'videos/asr_example.wav');
|
||||
// const videoTestPath = path.join(process.cwd(), 'videos/asr_example2.wav');
|
||||
// const videoTestPath = path.join(process.cwd(), 'videos/tts_mix.mp3');
|
||||
const videoTestPath = path.join(process.cwd(), 'videos/my_speech_text.wav');
|
||||
const name = 'output-1746007775571.mp3';
|
||||
const videoTestPath2 = path.join(process.cwd(), 'build', name);
|
||||
|
||||
// 使用示例
|
||||
async function main() {
|
||||
const asrServer = new AliAsrServer({
|
||||
appkey: process.env.ALI_ASR_APP_KEY,
|
||||
token: process.env.ALI_ASR_TOKEN,
|
||||
format: 'mp3',
|
||||
// format: 'wav',
|
||||
});
|
||||
|
||||
const audioContent = await fs.readFile(videoTestPath);
|
||||
await asrServer.processAudio(audioContent);
|
||||
}
|
||||
|
||||
// 执行主函数
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user