/** * 快速测试 LLM 文本生成和 TTS */ import { callLLMWithMessages } from '../src/services/llm'; async function testLLM() { console.log('===== 测试文本生成 ====='); // 测试实际调用 console.log('\n[1] 测试 LLM 调用'); try { const response = await callLLMWithMessages( [ { role: 'user', content: '请用一句话回答:1+1等于几?' } ], undefined, // 不指定模型,使用默认模型 100 // maxTokens ); console.log('LLM 响应:', response); console.log('✅ 文本生成正常'); } catch (err: any) { console.error('❌ 文本生成失败:', err.message); } } async function testTTS() { console.log('\n===== 测试 TTS ====='); const TtsService = await import('../src/modules/tts/tts.service'); try { // 用 generatePreview 来测试 TTS(无需数据库记录) const result = await TtsService.generatePreview( 'cherry', { speed: 1.0, pitch: 0, volume: 50 }, // volume=50 是默认值,对应 vol=1 'minimax' // 指定 MiniMax provider ); console.log('TTS 结果:', result ? '有音频数据' : '无数据'); console.log('✅ TTS 正常'); } catch (err: any) { console.error('❌ TTS 失败:', err.message); } } async function main() { await testLLM(); await testTTS(); process.exit(0); } main().catch(console.error);