Spaces:
Running on Zero
Running on Zero
Download tests/test_requests.py from fffiloni/ZONOS3-Mini: direct link, hf CLI and curl.
- Browser
- Download file 2.19 kB
-
https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_requests.py
- Command line
-
hf download hf://spaces/fffiloni/ZONOS3-Mini/tests/test_requests.py
-
curl -L -o test_requests.py https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_requests.py
2.19 kB
| import json | |
| import math | |
| import pytest | |
| from config import MAX_CHARS | |
| from requests_schema import InputError, validate | |
| def valid(**updates): | |
| values = dict(text="Bonjour !", picker=json.dumps({"voice":"Gaspard","language":"fr_fr"}), | |
| source="Preset", seed=42, randomize=False, normalize=True, | |
| temperature=.75, top_p=.69, top_k=80, repetition_penalty=2.4, | |
| rate=0, voice_names={"Gaspard","Savannah"}, clip_present=False, consent=False) | |
| values.update(updates) | |
| return validate(**values) | |
| def test_explicit_language_is_preserved(): | |
| result = valid(picker=json.dumps({"voice":"Savannah","language":"fr_fr"})) | |
| assert result.voice == "Savannah" and result.language == "fr_fr" | |
| def test_no_silent_english_fallback(language): | |
| with pytest.raises(InputError): | |
| valid(picker={"voice":"Gaspard","language":language}) | |
| def test_text_rejected_before_inference(text): | |
| with pytest.raises(InputError): | |
| valid(text=text) | |
| def test_numeric_input_does_not_silently_clamp(field,value): | |
| with pytest.raises(InputError): | |
| valid(**{field:value}) | |
| def test_reference_mode_requires_clip_and_permission(): | |
| with pytest.raises(InputError): valid(source="Voice clip") | |
| with pytest.raises(InputError): valid(source="Voice clip",clip_present=True) | |
| assert valid(source="Voice clip",clip_present=True,consent=True).source == "Voice clip" | |
| def test_fixed_seed_and_natural_rate(): | |
| result=valid() | |
| assert result.seed==42 and result.rate is None | |
| def test_malformed_picker(): | |
| with pytest.raises(InputError): valid(picker="{bad json") | |
| def test_picker_fields_require_strings(field): | |
| value={"voice":"Gaspard", "language":"fr_fr"} | |
| value[field]=[] | |
| with pytest.raises(InputError): valid(picker=value) | |