| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // 测试音频生成
- async function testAudioGeneration() {
- const bookId = 5;
- const chapterId = 1214; // 版本控制的概念与价值
- const testText = "版本控制的概念与价值\n\n版本控制是软件开发中不可或缺的工具,它帮助我们追踪文件的变化历史,支持多人协作开发,并允许我们在出现问题时回退到之前的状态。";
-
- console.log('\n🎵 测试音频生成:\n');
- console.log(`书籍ID: ${bookId}`);
- console.log(`章节ID: ${chapterId}`);
- console.log(`测试文本: ${testText.substring(0, 50)}...\n`);
-
- try {
- // 调用音频生成API
- const response = await fetch('http://localhost:3000/api/tts/generate', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- text: testText,
- voiceId: 'cherry',
- bookId: bookId.toString(),
- chapterTitle: '版本控制的概念与价值',
- }),
- });
-
- const data = await response.json();
-
- console.log('📤 API响应:');
- console.log(JSON.stringify(data, null, 2));
-
- if (data.code === 0) {
- console.log('\n✅ 音频生成任务已提交!');
- console.log(`\n💡 等待30-60秒后检查音频是否生成成功`);
- } else {
- console.log('\n❌ 音频生成失败:', data.message);
- }
- } catch (error) {
- console.error('\n❌ 请求失败:', error.message);
- }
- }
- testAudioGeneration();
|