trigger-book-82-audio.js 691 B

123456789101112131415161718
  1. // 触发 book 82 所有章节的音频生成
  2. const { bookStore } = require('./dist/modules/book-generator/book-generator.store.js');
  3. const { PrismaClient } = require('@prisma/client');
  4. const p = new PrismaClient();
  5. (async () => {
  6. const chs = await p.bookChapter.findMany({ where: { bookId: 82 }, select: { id: true, title: true } });
  7. console.log(`book 82: ${chs.length} chapters`);
  8. for (const ch of chs) {
  9. try {
  10. await bookStore.generateChapterAudioById(ch.id, 1, undefined, {});
  11. console.log(` queued ch#${ch.id} ${ch.title.slice(0, 30)}`);
  12. } catch (e) {
  13. console.log(` err ch#${ch.id}: ${e.message.slice(0, 100)}`);
  14. }
  15. }
  16. await p.$disconnect();
  17. })();