Spaces:
Build error
Build error
File size: 1,174 Bytes
18d028b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | """Tests for the TTS module — silent-stub fallback path."""
from __future__ import annotations
from pathlib import Path
import soundfile as sf
from signbridge.voice.tts import synthesize_speech
class TestSynthesize:
def test_empty_text_returns_none(self) -> None:
assert synthesize_speech("") is None
def test_returns_path_to_existing_wav(self) -> None:
# Without the heavy Coqui XTTS package, the module emits a silent stub.
# That stub MUST be a real readable WAV file.
path = synthesize_speech("hello, world!")
assert path is not None and path != ""
p = Path(path)
assert p.exists()
assert p.suffix == ".wav"
# Read it back to confirm it's a valid WAV
data, sr = sf.read(str(p))
assert sr > 0
assert len(data) > 0
def test_caches_per_text(self) -> None:
path1 = synthesize_speech("repeat me")
path2 = synthesize_speech("repeat me")
assert path1 == path2
def test_different_text_different_file(self) -> None:
path1 = synthesize_speech("alpha")
path2 = synthesize_speech("beta")
assert path1 != path2
|