test-match-app.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * 测试 MiniMax TTS - 使用与应用完全相同的参数
  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. const body = {
  8. model: 'speech-2.8-hd',
  9. text: '你好,欢迎使用AI有声书',
  10. voice_setting: {
  11. voice_id: 'audiobook_female_1',
  12. speed: 1,
  13. vol: 0.02, // (50/50) / 50 = 0.02? No wait, params.volume is 50 so (50/50) = 1, but volume is 50... hmm
  14. // Actually in code: vol: (params.volume || 50) / 50 -> 50/50 = 1
  15. // But params.volume comes from voiceParams?.volume which in generatePreview is undefined
  16. // So params.volume defaults to 50, then 50/50 = 1
  17. // But the log shows vol:0.02... that means params.volume must be 1? or 50?
  18. // Wait: (1 || 50) / 50 = 1/50 = 0.02
  19. // So voiceParams.volume is 1!
  20. pitch: 1.002, // 1 + (0 / 500) = 1... but log shows 1.002, so pitch must be 1?
  21. // 1 + (1 / 500) = 1.002
  22. },
  23. audio_setting: {
  24. audio_sample_rate: 32000,
  25. bitrate: 128000,
  26. format: 'mp3',
  27. channel: 1,
  28. },
  29. };
  30. async function testKey(name: string, key: string) {
  31. console.log(`\n===== 测试 ${name} =====`);
  32. try {
  33. const resp = await axios.post('https://api.minimaxi.com/v1/t2a_async_v2', body, {
  34. headers: { 'Authorization': `Bearer ${key}`, 'Content-Type': 'application/json' },
  35. timeout: 30000,
  36. });
  37. console.log('✅ 成功:', JSON.stringify(resp.data));
  38. } catch (err: any) {
  39. console.log('❌ 状态:', err.response?.status);
  40. console.log('❌ 响应:', JSON.stringify(err.response?.data));
  41. }
  42. }
  43. async function run() {
  44. console.log('请求体:', JSON.stringify(body, null, 2));
  45. await testKey('Key1', KEY1);
  46. await testKey('Key2', KEY2);
  47. }
  48. run();