| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- /**
- * 快速测试 MiniMax TTS API 直接调用
- */
- import axios from 'axios';
- const API_KEY = 'sk-cp-BOVwOolqOEmHycg8MzDX_UgQ_bDEK3snjPUFuwolUCb_TxMxhhlAfYhTT0_tqRvEz5K56xpl-aOoJtj97MuAY4UIA-PCQLVetUCY56i8LFimNuQqrrq5xWA';
- const API_BASE = 'https://api.minimaxi.com';
- async function testMiniMaxTTS() {
- console.log('===== 测试 MiniMax TTS API =====');
- const body = {
- model: 'speech-2.8-hd',
- text: '你好,欢迎使用AI有声书',
- voice_setting: {
- voice_id: 'audiobook_female_1',
- speed: 1,
- vol: 1,
- pitch: 1,
- },
- audio_setting: {
- audio_sample_rate: 32000,
- bitrate: 128000,
- format: 'mp3',
- channel: 1,
- },
- };
- console.log('请求体:', JSON.stringify(body, null, 2));
- try {
- const response = await axios.post(`${API_BASE}/v1/t2a_async_v2`, body, {
- headers: {
- 'Authorization': `Bearer ${API_KEY}`,
- 'Content-Type': 'application/json',
- },
- timeout: 30000,
- });
- console.log('✅ 成功:', JSON.stringify(response.data, null, 2));
- } catch (error: any) {
- console.error('❌ 失败:', error.response?.data || error.message);
- }
- }
- testMiniMaxTTS().catch(console.error);
|