/**
 * 测试 minimax-key1 vs key2 的 TTS API
 */
import axios from 'axios';

const KEY1 = 'sk-cp-s8hGJr4ACdlZ4GM0LjZ1l2ZNBUAMGwd2ahl0c3W2g6C0EiNH0UvwOBx2q0oJOYO6ca5HqJccP_KRUPucoBizavlwDSZp-ohOGeUw2ymAdXPuM6r3CIDmmlY';
const KEY2 = 'sk-cp-BOVwOolqOEmHycg8MzDX_UgQ_bDEK3snjPUFuwolUCb_TxMxhhlAfYhTT0_tqRvEz5K56xpl-aOoJtj97MuAY4UIA-PCQLVetUCY56i8LFimNuQqrrq5xWA';

async function testKey(name: string, key: string) {
  console.log(`\n===== 测试 ${name} =====`);
  try {
    const resp = await axios.post('https://api.minimaxi.com/v1/t2a_async_v2', {
      model: 'speech-2.8-hd',
      text: '你好',
      voice_setting: { voice_id: 'audiobook_female_1', speed: 1, vol: 1, pitch: 1 },
      audio_setting: { audio_sample_rate: 32000, bitrate: 128000, format: 'mp3', channel: 1 },
    }, {
      headers: { 'Authorization': `Bearer ${key}`, 'Content-Type': 'application/json' },
      timeout: 30000,
    });
    console.log('✅ 成功:', JSON.stringify(resp.data));
  } catch (err: any) {
    console.log('❌ 状态:', err.response?.status);
    console.log('❌ 响应:', JSON.stringify(err.response?.data));
  }
}

async function run() {
  await testKey('Key1', KEY1);
  await testKey('Key2', KEY2);
}
run();