Spaces:
Running on Zero
Running on Zero
Download tests/test_contracts.py from fffiloni/ZONOS3-Mini: direct link, hf CLI and curl.
- Browser
- Download file 3.05 kB
-
https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_contracts.py
- Command line
-
hf download hf://spaces/fffiloni/ZONOS3-Mini/tests/test_contracts.py
-
curl -L -o test_contracts.py https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_contracts.py
3.05 kB
| import inspect | |
| import json | |
| import os | |
| import gradio as gr | |
| import pytest | |
| from config import GRADIO_VERSION, LANGUAGES, MODEL_REVISION, ROOT, SPACES_VERSION | |
| def test_gradio_api_and_native_progress_contract(monkeypatch): | |
| monkeypatch.setenv("ZONOS_UI_ONLY","1") | |
| import app | |
| assert gr.__version__==GRADIO_VERSION | |
| assert set(app.demo.get_api_info()["named_endpoints"])=={"/generate","/cancel"} | |
| event=next(x for x in app.demo.config['dependencies'] if x['api_name']=='generate') | |
| assert event['show_progress']!='hidden' | |
| assert len(event['inputs'])==13 and len(event['outputs'])==5 | |
| assert event['trigger_mode']=='once' | |
| assert 'watch' in (ROOT/'assets/player.js').read_text() | |
| assert 'js_on_load' in inspect.signature(gr.HTML).parameters | |
| def test_voice_catalog_matches_supported_languages(): | |
| c=json.loads((ROOT/'voices.json').read_text()) | |
| assert c['model_revision']==MODEL_REVISION | |
| assert len(c['voices'])==23 | |
| assert all(v['language'] in LANGUAGES for v in c['voices']) | |
| assert next(v for v in c['voices'] if v['name']=='Gaspard')['language']=='fr_fr' | |
| def test_upstream_callback_and_decoder_contract(): | |
| import engine | |
| from zonos3.reference.synth import synthesize | |
| from zonos3.tokenizer.matched_codec import registry | |
| assert {'on_plan','on_audio'} <= set(inspect.signature(synthesize).parameters) | |
| assert all(x['decoder_default']=='keep2_plain' for x in registry().values()) | |
| assert engine.ENGINE is None # imports alone must not download weights | |
| def test_all_runtime_download_helpers_receive_pin(monkeypatch): | |
| import engine | |
| from zonos3.utils import release | |
| import huggingface_hub | |
| calls=[] | |
| monkeypatch.setattr(huggingface_hub,'hf_hub_download',lambda **kwargs:(calls.append(kwargs) or '/cache/test')) | |
| monkeypatch.setattr(huggingface_hub,'snapshot_download',lambda **kwargs:(calls.append(kwargs) or '/cache/test')) | |
| release.resolve_file.cache_clear();release.resolve_dir_or_local.cache_clear() | |
| release.resolve_file('hf://Zyphra/ZONOS3-Mini/autoencoder/generator.pt') | |
| release.resolve_dir_or_local('hf://Zyphra/ZONOS3-Mini/lm/zonos3_mini') | |
| assert len(calls)==2 and all(c['revision']==MODEL_REVISION for c in calls) | |
| release.resolve_file.cache_clear();release.resolve_dir_or_local.cache_clear() | |
| def test_speaker_and_codec_import_with_resolved_dependencies(): | |
| import engine | |
| from zonos3.models.speaker_cloning import create_speaker_embedder | |
| from zonos3.models.mect_speaker import MECTFbankSpeakerEmbedding | |
| from zonos3.codec.istft_head_a_20261002.model import ISTFTCodec | |
| from zonos3.codec.istft_head_a_20261002.stream import ISTFTStream | |
| assert all(callable(x) for x in [create_speaker_embedder,MECTFbankSpeakerEmbedding,ISTFTCodec,ISTFTStream]) | |
| def test_gpu_reservation_fits_public_takes(): | |
| from engine import gpu_budget | |
| assert gpu_budget({"text":"A short take."}, None, None) == 30 | |
| assert gpu_budget({"text":"a" * 600}, None, None) == 58 | |
| assert gpu_budget({"text":"a" * 3000}, None, None) == 60 | |