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