初始提交:3 款纯音频游戏 + 共享引擎 + 完整文档与资产管线
- 共享引擎(app/src/main):GestureEngine 6 手势识别、AudioEngine 三层音频 (ExoPlayer BGM 交叉淡入 / 对白 ducking / SoundPool 低延迟)、Game/GameEngine 状态机接口、MainActivity 全屏封面 + TalkBack - 《声命线》storyline:末世互动广播剧,3 幕 8 抉择点 4 结局 - 《声东击西》reflex:听声辨位反应,12 波战斗 + BGM 三档 BPM 变速 - 《暗室》escape:3x3 网格密室逃脱,钥匙→铁柜→保险丝→电箱→大门谜题链 - 文档:setup(从零搭建)/ architecture(架构)/ engine-api(引擎 API)/ asset-pipeline(资产流水线)/ games/*(三款游戏设计文档) - 资产管线:Qwen3-TTS 对白 + 程序合成音效/BGM + Mureka BGM 的 gen 脚本与台账, 全部 ogg 资产入库可复现 - env.d 环境脚本:android/tts 入库;sfx/mureka 含密钥不入库,仅提交 .example.sh 模板
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from huggingface_hub import hf_hub_download, try_to_load_from_cache
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ModelConfig:
|
||||
repo_id: str
|
||||
config_path: str
|
||||
ckpt_path: str
|
||||
|
||||
def resolve(self):
|
||||
"""Download files from HuggingFace Hub and return local cached paths."""
|
||||
local_config = hf_hub_download(repo_id=self.repo_id, filename=self.config_path)
|
||||
local_ckpt = hf_hub_download(repo_id=self.repo_id, filename=self.ckpt_path)
|
||||
return local_config, local_ckpt
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AutoencoderModelConfig:
|
||||
"""Config for a standalone autoencoder HF repo (e.g. stabilityai/SAME-S).
|
||||
|
||||
resolve() first checks whether any full Stable Audio 3 checkpoint that contains the same
|
||||
autoencoder is already cached locally. If one is found it is used as-is
|
||||
(load_autoencoder strips the pretransform.* prefix automatically), avoiding a
|
||||
redundant download. Otherwise the lightweight AE-only repo is fetched instead.
|
||||
"""
|
||||
|
||||
ae_repo_id: str
|
||||
ae_config_path: str
|
||||
ae_ckpt_path: str
|
||||
stable_audio_3: tuple[ModelConfig, ...]
|
||||
|
||||
def resolve(self):
|
||||
"""Return (config_path, ckpt_path), preferring an already-cached Stable Audio 3 checkpoint."""
|
||||
for fallback in self.stable_audio_3:
|
||||
cached_config = try_to_load_from_cache(
|
||||
fallback.repo_id, fallback.config_path
|
||||
)
|
||||
cached_ckpt = try_to_load_from_cache(fallback.repo_id, fallback.ckpt_path)
|
||||
if isinstance(cached_config, str) and isinstance(cached_ckpt, str):
|
||||
return cached_config, cached_ckpt
|
||||
|
||||
# No Stable Audio 3 checkpoint found in local cache — download the AE-only repo.
|
||||
local_config = hf_hub_download(
|
||||
repo_id=self.ae_repo_id, filename=self.ae_config_path
|
||||
)
|
||||
local_ckpt = hf_hub_download(
|
||||
repo_id=self.ae_repo_id, filename=self.ae_ckpt_path
|
||||
)
|
||||
return local_config, local_ckpt
|
||||
|
||||
|
||||
models: dict[str, ModelConfig] = {
|
||||
"small-music": ModelConfig(
|
||||
"stabilityai/stable-audio-3-small-music",
|
||||
"model_config.json",
|
||||
"model.safetensors",
|
||||
),
|
||||
"small-music-base": ModelConfig(
|
||||
"stabilityai/stable-audio-3-small-music-base",
|
||||
"model_config.json",
|
||||
"model.safetensors",
|
||||
),
|
||||
"small-sfx": ModelConfig(
|
||||
"stabilityai/stable-audio-3-small-sfx",
|
||||
"model_config.json",
|
||||
"model.safetensors",
|
||||
),
|
||||
"small-sfx-base": ModelConfig(
|
||||
"stabilityai/stable-audio-3-small-sfx-base",
|
||||
"model_config.json",
|
||||
"model.safetensors",
|
||||
),
|
||||
"medium": ModelConfig(
|
||||
"stabilityai/stable-audio-3-medium",
|
||||
"model_config.json",
|
||||
"model.safetensors",
|
||||
),
|
||||
"medium-base": ModelConfig(
|
||||
"stabilityai/stable-audio-3-medium-base",
|
||||
"model_config.json",
|
||||
"model.safetensors",
|
||||
),
|
||||
}
|
||||
|
||||
# Stable Audio 3 full-model configs to probe (in order) before downloading the AE-only repo.
|
||||
_small_stable_audio_3: tuple[ModelConfig, ...] = (
|
||||
models["small-music"],
|
||||
models["small-sfx"],
|
||||
)
|
||||
_medium_stable_audio_3: tuple[ModelConfig, ...] = (models["medium"],)
|
||||
|
||||
ae_models: dict[str, AutoencoderModelConfig] = {
|
||||
"same-s": AutoencoderModelConfig(
|
||||
ae_repo_id="stabilityai/SAME-S",
|
||||
ae_config_path="model_config.json",
|
||||
ae_ckpt_path="model.safetensors",
|
||||
stable_audio_3=_small_stable_audio_3,
|
||||
),
|
||||
"same-l": AutoencoderModelConfig(
|
||||
ae_repo_id="stabilityai/SAME-L",
|
||||
ae_config_path="model_config.json",
|
||||
ae_ckpt_path="model.safetensors",
|
||||
stable_audio_3=_medium_stable_audio_3,
|
||||
),
|
||||
}
|
||||
|
||||
base_models: dict[str, ModelConfig] = {
|
||||
k: v for k, v in models.items() if k.endswith("-base")
|
||||
}
|
||||
|
||||
all_models: dict[str, ModelConfig | AutoencoderModelConfig] = {
|
||||
**models,
|
||||
**ae_models,
|
||||
}
|
||||
Reference in New Issue
Block a user