check-audio-status.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkAudioStatus() {
  4. const bookId = 5;
  5. // 查找已完成内容的小节
  6. const subsections = await prisma.bookChapter.findMany({
  7. where: {
  8. bookId,
  9. level: 3,
  10. contentStatus: 'completed'
  11. },
  12. select: {
  13. id: true,
  14. title: true,
  15. wordCount: true,
  16. audioUrl: true,
  17. audioDuration: true,
  18. },
  19. orderBy: { id: 'asc' },
  20. take: 10
  21. });
  22. console.log('\n Book 5 小节音频生成状态检查:\n');
  23. console.log('=' .repeat(80));
  24. const withAudio = subsections.filter(s => s.audioUrl);
  25. const withoutAudio = subsections.filter(s => !s.audioUrl);
  26. console.log(`\n✅ 已有音频的小节:${withAudio.length}个`);
  27. withAudio.forEach((sub, index) => {
  28. console.log(` ${index + 1}. ${sub.title} (${sub.wordCount}字, ${sub.audioDuration || 0}秒)`);
  29. });
  30. console.log(`\n❌ 未生成音频的小节:${withoutAudio.length}个`);
  31. withoutAudio.slice(0, 5).forEach((sub, index) => {
  32. console.log(` ${index + 1}. ${sub.title} (${sub.wordCount}字)`);
  33. });
  34. if (withoutAudio.length > 5) {
  35. console.log(` ... 还有${withoutAudio.length - 5}个`);
  36. }
  37. console.log('\n' + '='.repeat(80));
  38. // 检查audio表
  39. const audioRecords = await prisma.audio.count({
  40. where: { bookId }
  41. });
  42. console.log(`\n📊 Audio表记录数: ${audioRecords}`);
  43. await prisma.$disconnect();
  44. }
  45. checkAudioStatus().catch(console.error);