"""Voice scoring helpers (delivery / confidence). HTTP /communication-analysis is disabled."""

from __future__ import annotations

from app.services.audio.voice_scoring import score_voice_analysis


def test_scoring_helper_balanced_rate() -> None:
    scored = score_voice_analysis(
        features={
            "words_per_minute": 140,
            "silence_percentage": 18,
            "pause_count": 4,
            "long_pause_count": 0,
            "speech_duration_seconds": 45,
            "rms_energy_mean": 0.05,
            "rms_energy_std": 0.02,
            "pitch_available": True,
            "pitch_std_hz": 22,
        },
        transcript_text="I led the migration and we measured clear improvements.",
    )
    assert scored["speech_patterns"]["speaking_rate_band"] == "balanced"
    assert scored["delivery"]["score"] >= 0.55
    assert scored["confidence_indicators"]["band"] in {"medium", "high"}


def test_rushed_speech_flags_delivery_gap() -> None:
    scored = score_voice_analysis(
        features={
            "words_per_minute": 220,
            "silence_percentage": 3,
            "pause_count": 1,
            "speech_duration_seconds": 20,
            "rms_energy_mean": 0.08,
            "rms_energy_std": 0.06,
        },
        transcript_text="um uh maybe I think we kind of did stuff quickly.",
    )
    assert scored["speech_patterns"]["speaking_rate_band"] == "rushed"
    assert scored["improvement_areas"]
    assert scored["confidence_indicators"]["score"] < 0.75
