Files
SoundGame/web/escape/check_assets.py
T
SoundGame Dev cc0f8c008d HTML5 重写:6 款游戏 + 用户系统 + 全局设置 + 5 轮迭代重构
- 新增 web/ 纯音频 HTML5 平台:共享引擎(手势/WebAudio 三层/设置/震动)、
  Node 零依赖服务器(静态 + 注册登录 + 进度存档 API)
- 游戏:剑与声(RPG 新作)、声命线、暗室(重设计)、音序回响(重设计)、
  节拍行者(跟随领奏重构)、盲航(同向闪避重构);声东击西删除
- 全局功能:男声/女声双套 TTS 资产、三档语速、BGM 音量三档、
  震动反馈语言(10 种震型)、服务器进度同步
- 资产:899 ogg + 899 m4a(Qwen3-TTS 双性别语音、Stable Audio 3 音效、
  Mureka BGM 4+3 首),终检零缺失
- 文档:docs/design/ 13 篇设计审查文档、docs/audio/ 资产管线、
  web/server/README.md API 文档
2026-08-29 21:55:44 +08:00

39 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""资产引用校验:game.js 引用的每个音频 id 都必须有 .ogg 和 .m4a 文件。"""
import re, sys, pathlib
root = pathlib.Path('/home/ubuntu/SoundGame/web/escape')
src = (root / 'game.js').read_text(encoding='utf-8')
ids = set()
# 1) 静态字符串 id:'sfx/xxx' / 'voice/xxx' / 'bgm/xxx'
for m in re.finditer(r"['\"]((bgm|voice|sfx)/[a-z0-9_]+)['\"]", src):
ids.add(m.group(1))
# 2) 动态数字播报 voice/n${...} → n0..n9
if re.search(r"voice/n\$\{", src):
ids.update(f'voice/n{i}' for i in range(10))
missing = []
for aid in sorted(ids):
for ext in ('.ogg', '.m4a'):
if not (root / 'audio' / (aid + ext)).is_file():
missing.append(aid + ext)
print(f'引用的音频 id 数: {len(ids)}')
for aid in sorted(ids):
print(' ', aid)
if missing:
print('\n缺失文件:')
for f in missing:
print(' MISSING', f)
sys.exit(1)
print('\nOK:所有引用的 id 均有 .ogg 和 .m4a')
# 反向检查:目录里是否存在从未被引用的音频(仅提示,不算失败)
import os
on_disk = {str(p.relative_to(root / 'audio'))[:-4]
for p in (root / 'audio').rglob('*.ogg')}
unused = on_disk - ids
if unused:
print('未被代码引用(仅提示):', ', '.join(sorted(unused)))