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