# Copyright 2026 Umbra Tools (umbratools.com) # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import tempfile from pathlib import Path import pytest from umbraaudio.analysis import CharacterProfile from umbraaudio.assembly import AudioStitcher @pytest.fixture def temp_dir(): with tempfile.TemporaryDirectory() as d: yield Path(d) @pytest.fixture def sample_wavs(temp_dir: Path) -> list[Path]: import numpy as np import soundfile as sf paths = [] sr = 24000 for i in range(3): path = temp_dir / f"test_{i}.wav" audio = np.random.randn(sr).astype(np.float32) * 0.1 sf.write(str(path), audio, sr) paths.append(path) return paths @pytest.fixture def stitcher() -> AudioStitcher: return AudioStitcher( silence_between_utterances_ms=100, silence_between_paragraphs_ms=200, silence_between_chapters_ms=300, sample_rate=24000, ) @pytest.fixture def narrator_profile() -> CharacterProfile: return CharacterProfile( name="Narrator", gender="male", age_range="adult", is_narrator=True, ) @pytest.fixture def character_profile() -> CharacterProfile: return CharacterProfile( name="John Smith", aliases=["John", "Smithy"], gender="male", age_range="young_adult", pitch_register="low", energy="measured", timbre="warm", texture="smooth", formality="formal", emotional_baseline="neutral_calm", pace_baseline="slow", distinguishing_trait="deep resonant voice", accent_marker="british_rp", voice_description="A deep, warm voice with a British RP accent", ) @pytest.fixture def registry_db_path(temp_dir: Path) -> Path: return temp_dir / "voice_registry.db"