Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

fix: align sound CLI and Python argument handling

Soohong Kim2c88844a5f48
diff --git a/sprite_gen/audio/sound.py b/sprite_gen/audio/sound.py
index 23950b7..88b05fe 100644
--- a/sprite_gen/audio/sound.py
+++ b/sprite_gen/audio/sound.py
@@ -77,12 +77,14 @@ def run(**kwargs):
add_arguments(parser)
args = namespace_from_kwargs(parser, kwargs)
try:
- prompt = args.prompt_file.read_text() if args.prompt_file else args.prompt
+ if (args.prompt is None) == (args.prompt_file is None):
+ raise ValueError('provide exactly one of prompt or prompt_file')
+ prompt = Path(args.prompt_file).read_text() if args.prompt_file is not None else args.prompt
result = generate(kind=args.kind, prompt=prompt, duration=args.duration, event=args.event,
out_dir=args.out_dir, cache_dir=args.cache_dir, loop=args.loop,
target_lufs=args.target_lufs, crossfade=args.crossfade)
except (ValueError, OSError) as exc:
raise SystemExit(f'sound: {exc}') from None
- print(json.dumps({'ok': True, 'manifest': str(args.out_dir/'sound.json'),
+ print(json.dumps({'ok': True, 'manifest': str(Path(args.out_dir)/'sound.json'),
'cache_hit': result['cache_hit'], 'duration_seconds': result['duration_seconds']}))
return 0
diff --git a/tests/audio/test_sound.py b/tests/audio/test_sound.py
index c1188d7..4d75339 100644
--- a/tests/audio/test_sound.py
+++ b/tests/audio/test_sound.py
@@ -165,7 +165,7 @@ def test_error_body_and_transport_cannot_disclose_key(monkeypatch, capsys):
def test_broken_refusal_body_is_not_retried_or_printed(monkeypatch, capsys):
calls = []
- class Broken:
+ class Broken(io.BytesIO):
def read(self, *args): raise http.client.IncompleteRead(b'secret-key', 100)
def send(req, **kw):
calls.append(req)
@@ -174,3 +174,17 @@ def test_broken_refusal_body_is_not_retried_or_printed(monkeypatch, capsys):
with pytest.raises(ValueError, match='unresolved') as err:
provider.generate(provider.request('sfx', 'impact', 1, False))
assert len(calls) == 1 and 'secret-key' not in str(err.value) + capsys.readouterr().err
+
+
+def test_cli_and_python_entry_publish_the_same_bundle(tmp_path, monkeypatch, capsys):
+ from sprite_gen.cli import main
+ monkeypatch.setattr(provider, 'generate', lambda req: (wav_bytes(1), {}))
+ args = ['sound', '--kind', 'sfx', '--prompt', 'synthetic', '--duration', '1', '--event', 'hit',
+ '--out-dir', str(tmp_path/'out'), '--cache-dir', str(tmp_path/'cache')]
+ assert main(args) == 0
+ monkeypatch.delenv('ELEVENLABS_API_KEY')
+ assert sound.run(kind='sfx',prompt='synthetic',duration=1,event='hit',out_dir=str(tmp_path/'out'),
+ cache_dir=tmp_path/'cache') == 0
+ lines = [json.loads(line) for line in capsys.readouterr().out.splitlines()]
+ assert lines[1]['cache_hit'] is True
+ assert lines[0]['manifest'] == lines[1]['manifest']