test-both-keys.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * 测试 minimax-key1 vs key2 的 TTS API
  3. */
  4. import axios from 'axios';
  5. const KEY1 = 'sk-cp-s8hGJr4ACdlZ4GM0LjZ1l2ZNBUAMGwd2ahl0c3W2g6C0EiNH0UvwOBx2q0oJOYO6ca5HqJccP_KRUPucoBizavlwDSZp-ohOGeUw2ymAdXPuM6r3CIDmmlY';
  6. const KEY2 = 'sk-cp-BOVwOolqOEmHycg8MzDX_UgQ_bDEK3snjPUFuwolUCb_TxMxhhlAfYhTT0_tqRvEz5K56xpl-aOoJtj97MuAY4UIA-PCQLVetUCY56i8LFimNuQqrrq5xWA';
  7. async function testKey(name: string, key: string) {
  8. console.log(`\n===== 测试 ${name} =====`);
  9. try {
  10. const resp = await axios.post('https://api.minimaxi.com/v1/t2a_async_v2', {
  11. model: 'speech-2.8-hd',
  12. text: '你好',
  13. voice_setting: { voice_id: 'audiobook_female_1', speed: 1, vol: 1, pitch: 1 },
  14. audio_setting: { audio_sample_rate: 32000, bitrate: 128000, format: 'mp3', channel: 1 },
  15. }, {
  16. headers: { 'Authorization': `Bearer ${key}`, 'Content-Type': 'application/json' },
  17. timeout: 30000,
  18. });
  19. console.log('✅ 成功:', JSON.stringify(resp.data));
  20. } catch (err: any) {
  21. console.log('❌ 状态:', err.response?.status);
  22. console.log('❌ 响应:', JSON.stringify(err.response?.data));
  23. }
  24. }
  25. async function run() {
  26. await testKey('Key1', KEY1);
  27. await testKey('Key2', KEY2);
  28. }
  29. run();