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:
2025-12-21 18:56:32 +08:00
parent 9e94a4d898
commit 58b27b86fe
20 changed files with 858 additions and 3626 deletions

View 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);