test-key2.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * 测试 minimax-key2 API Key 是否正常
  3. */
  4. import axios from 'axios';
  5. const KEY2 = 'sk-cp-BOVwOolqOEmHycg8MzDX_UgQ_bDEK3snjPUFuwolUCb_TxMxhhlAfYhTT0_tqRvEz5K56xpl-aOoJtj97MuAY4UIA-PCQLVetUCY56i8LFimNuQqrrq5xWA';
  6. async function test() {
  7. console.log('测试 minimax-key2 TTS API...\n');
  8. const body = {
  9. model: 'speech-2.8-hd',
  10. text: '你好,欢迎使用AI有声书',
  11. voice_setting: {
  12. voice_id: 'audiobook_female_1',
  13. speed: 1,
  14. vol: 1,
  15. pitch: 1,
  16. },
  17. audio_setting: {
  18. audio_sample_rate: 32000,
  19. bitrate: 128000,
  20. format: 'mp3',
  21. channel: 1,
  22. },
  23. };
  24. try {
  25. const resp = await axios.post('https://api.minimaxi.com/v1/t2a_async_v2', body, {
  26. headers: {
  27. 'Authorization': `Bearer ${KEY2}`,
  28. 'Content-Type': 'application/json',
  29. },
  30. timeout: 30000,
  31. });
  32. console.log('✅ 成功:', JSON.stringify(resp.data, null, 2));
  33. } catch (err: any) {
  34. console.log('❌ 状态码:', err.response?.status);
  35. console.log('❌ 响应:', JSON.stringify(err.response?.data, null, 2));
  36. }
  37. }
  38. test();