| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/usr/bin/env node
- /**
- * 语音合成端到端模拟测试
- * 测试流程:模拟配置 → 创建测试文本 → 验证调用链路
- */
- const path = require('path');
- const fs = require('fs');
- console.log('🧪 语音合成端到端模拟测试\n');
- // 测试 1: 验证配置
- console.log('【测试 1】验证环境配置...');
- const envPath = path.resolve('D:', 'qiwei-training', '.env.local');
- if (!fs.existsSync(envPath)) {
- console.error(' ❌ 配置文件不存在:', envPath);
- process.exit(1);
- }
- const envContent = fs.readFileSync(envPath, 'utf8');
- const tokenMatch = envContent.match(/^QIWEI_AUTH_TOKEN=(.+)$/m);
- if (!tokenMatch || !tokenMatch[1].trim()) {
- console.error(' ❌ 未配置 QIWEI_AUTH_TOKEN');
- process.exit(1);
- }
- const token = tokenMatch[1].trim();
- console.log(' ✅ Token 已配置(内容已隐藏)');
- // 测试 2: 加载语音服务模块
- console.log('\n【测试 2】加载语音服务模块...');
- try {
- const { VoiceCloneService } = require('../mcp/src/core/voice-clone-service.js');
- console.log(' ✅ VoiceCloneService 类加载成功');
- // 测试 3: 实例化服务
- console.log('\n【测试 3】实例化语音服务...');
- const service = new VoiceCloneService({
- config: {
- endpoint: 'https://server.fmode.cn/api/voice/indextts2',
- authToken: token
- },
- qiwei: { uid: 'test-uid', guid: 'test-guid' }
- });
- console.log(' ✅ 服务实例化成功');
- console.log(' 端点:', service.config.endpoint);
- console.log(' 超时:', service.config.requestTimeoutMs, 'ms');
- // 测试 4: 验证依赖
- console.log('\n【测试 4】验证音频处理依赖...');
- const ffmpeg = require('@ffmpeg-installer/ffmpeg');
- const ffprobe = require('@ffprobe-installer/ffprobe');
- const WxVoice = require('@binsee/wx-voice');
- console.log(' ✅ ffmpeg:', fs.existsSync(ffmpeg.path) ? '可用' : '不可用');
- console.log(' ✅ ffprobe:', fs.existsSync(ffprobe.path) ? '可用' : '不可用');
- console.log(' ✅ wx-voice:', typeof WxVoice.WxVoice === 'function' ? '可用' : '不可用');
- console.log('\n' + '='.repeat(60));
- console.log('✅ 所有模拟测试通过!');
- console.log('='.repeat(60));
- console.log('\n📝 下一步:真实语音测试需要:');
- console.log(' 1. 准备 5-30 秒参考音频(WAV/MP3)');
- console.log(' 2. 启动工作台: D:\\qiwei-training\\qiwei-workbench.exe');
- console.log(' 3. 在工作台上传参考音频初始化档案');
- console.log(' 4. 输入测试文本并发送到测试联系人');
- } catch (err) {
- console.error(' ❌ 测试失败:', err.message);
- process.exit(1);
- }
|