File size: 1,871 Bytes
5f0f535
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Unreleased tracks (speaker diarization, full duplex) are switched off by default."""

from __future__ import annotations

import json

import features


def test_switches_are_off_by_default(monkeypatch):
    monkeypatch.delenv("FFASR_ENABLE_DIARIZATION", raising=False)
    monkeypatch.delenv("FFASR_ENABLE_DUPLEX", raising=False)
    assert not features.diarization_enabled() and not features.duplex_enabled()
    assert features.enabled_tracks() == ["asr"]


def test_switches_turn_tracks_on(monkeypatch):
    monkeypatch.setenv("FFASR_ENABLE_DIARIZATION", "1")
    monkeypatch.setenv("FFASR_ENABLE_DUPLEX", "true")
    assert features.enabled_tracks() == ["asr", "diarization", "duplex"]


def test_methodology_has_diarization_only_when_on():
    import constants

    off = constants.about_text(diarization=False)
    on = constants.about_text(diarization=True)
    assert "diarization" not in off.lower() and "__DIARIZATION_SECTION__" not in off
    assert "## Speaker diarization" in on and on.index("## Speaker diarization") < on.index("## Dataset")
    assert "### FFAS score" in off and "FFAS_raw = 4 / (1/A_near" in off
    assert "__SPACE_ID__" not in off


def test_app_builds_without_diarization_or_duplex():
    """With both switches off nothing of either track reaches the page config."""
    import app

    assert not features.diarization_enabled() and not features.duplex_enabled()
    # Components only: shared CSS may still name the track containers.
    config = json.dumps(app.demo.config["components"], default=str)
    for needle in (
        "diarization-tab",
        "duplex-tab",
        "diarization-table",
        "duplex-table",
        "Speaker diarization",
        "Full-duplex",
        "Who spoke when",
        "pyannote",
        "diarization",
    ):
        assert needle not in config, needle
    assert "asr-track" in config