verify-audio-394.sh 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. set -e
  3. URL=$(cd /data/ai/audio/server && node -e '
  4. const { PrismaClient } = require("@prisma/client");
  5. const p = new PrismaClient();
  6. p.bookChapter.findUnique({ where: { id: 394 } }).then(c => { console.log(c.audioUrl); p.$disconnect(); });
  7. ')
  8. echo "新音频 URL: $URL"
  9. curl -sS -m 30 -o /tmp/audio394-new.mp3 "$URL"
  10. ls -la /tmp/audio394-new.mp3
  11. echo
  12. echo '=== 验证时长 / 码率 ==='
  13. file /tmp/audio394-new.mp3 | head -1
  14. ffmpeg -i /tmp/audio394-new.mp3 -f null - 2>&1 | grep -E 'Duration|Stream' | head -3
  15. echo
  16. echo '=== 文本字数 + 新语速 ==='
  17. CHAR=$(cd /data/ai/audio/server && node -e '
  18. const { PrismaClient } = require("@prisma/client");
  19. const p = new PrismaClient();
  20. p.bookChapter.findUnique({ where: { id: 394 } }).then(c => { console.log(c.content.length); p.$disconnect(); });
  21. ')
  22. SEC=$(ffmpeg -i /tmp/audio394-new.mp3 -f null - 2>&1 | grep Duration | head -1 | sed 's/Duration: //; s/,.*//' | awk -F: '{print ($1*3600+$2*60+$3)}')
  23. echo "文本字数: $CHAR 字"
  24. echo "时长: $SEC 秒 ($(echo "scale=1; $SEC/60" | bc) 分钟)"
  25. echo "对比旧音频: 580 秒 (9:39), 现在 $SEC 秒"
  26. python3 -c "
  27. sec=$SEC; ch=$CHAR; old=580
  28. print(f'提升: {old-sec:.0f} 秒 ({old/sec:.2f}x 加速)')
  29. print(f'新语速: {ch/sec:.2f} 字/秒')
  30. print(f'正常参考: 3.5-4.5 字/秒')
  31. "