test-minimax-params.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * 测试 MiniMax TTS - 测试 vol 和 pitch 的影响
  3. */
  4. import axios from 'axios';
  5. const KEY1 = 'sk-cp-s8hGJr4ACdlZ4GM0LjZ1l2ZNBUAMGwd2ahl0c3W2g6C0EiNH0UvwOBx2q0oJOYO6ca5HqJccP_KRUPucoBizavlwDSZp-ohOGeUw2ymAdXPuM6r3CIDmmlY';
  6. async function test() {
  7. // 测试1: vol=1, pitch=1 (默认值)
  8. console.log('测试1: vol=1, pitch=1');
  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 ${KEY1}`, 'Content-Type': 'application/json' },
  17. timeout: 30000,
  18. });
  19. console.log('成功:', JSON.stringify(resp.data));
  20. } catch (err: any) {
  21. console.log('失败:', err.response?.data || err.message);
  22. }
  23. // 测试2: 完全不传 vol 和 pitch
  24. console.log('\n测试2: 不传 vol 和 pitch');
  25. try {
  26. const resp = await axios.post('https://api.minimaxi.com/v1/t2a_async_v2', {
  27. model: 'speech-2.8-hd',
  28. text: '你好',
  29. voice_setting: { voice_id: 'audiobook_female_1' },
  30. audio_setting: { audio_sample_rate: 32000, bitrate: 128000, format: 'mp3', channel: 1 },
  31. }, {
  32. headers: { 'Authorization': `Bearer ${KEY1}`, 'Content-Type': 'application/json' },
  33. timeout: 30000,
  34. });
  35. console.log('成功:', JSON.stringify(resp.data));
  36. } catch (err: any) {
  37. console.log('失败:', err.response?.data || err.message);
  38. }
  39. }
  40. test();