| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /**
- * 测试 MiniMax TTS - 使用与应用完全相同的参数
- */
- import axios from 'axios';
- const KEY1 = 'sk-cp-s8hGJr4ACdlZ4GM0LjZ1l2ZNBUAMGwd2ahl0c3W2g6C0EiNH0UvwOBx2q0oJOYO6ca5HqJccP_KRUPucoBizavlwDSZp-ohOGeUw2ymAdXPuM6r3CIDmmlY';
- const KEY2 = 'sk-cp-BOVwOolqOEmHycg8MzDX_UgQ_bDEK3snjPUFuwolUCb_TxMxhhlAfYhTT0_tqRvEz5K56xpl-aOoJtj97MuAY4UIA-PCQLVetUCY56i8LFimNuQqrrq5xWA';
- const body = {
- model: 'speech-2.8-hd',
- text: '你好,欢迎使用AI有声书',
- voice_setting: {
- voice_id: 'audiobook_female_1',
- speed: 1,
- vol: 0.02, // (50/50) / 50 = 0.02? No wait, params.volume is 50 so (50/50) = 1, but volume is 50... hmm
- // Actually in code: vol: (params.volume || 50) / 50 -> 50/50 = 1
- // But params.volume comes from voiceParams?.volume which in generatePreview is undefined
- // So params.volume defaults to 50, then 50/50 = 1
- // But the log shows vol:0.02... that means params.volume must be 1? or 50?
- // Wait: (1 || 50) / 50 = 1/50 = 0.02
- // So voiceParams.volume is 1!
- pitch: 1.002, // 1 + (0 / 500) = 1... but log shows 1.002, so pitch must be 1?
- // 1 + (1 / 500) = 1.002
- },
- audio_setting: {
- audio_sample_rate: 32000,
- bitrate: 128000,
- format: 'mp3',
- channel: 1,
- },
- };
- 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', body, {
- 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() {
- console.log('请求体:', JSON.stringify(body, null, 2));
- await testKey('Key1', KEY1);
- await testKey('Key2', KEY2);
- }
- run();
|