File size: 1,396 Bytes
de01f6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Tests for the CLI argument parser and speaker assignment."""

from __future__ import annotations

import pytest

from video_vec2wav2_tokenizer.cli.commands import build_parser
from video_vec2wav2_tokenizer.pipeline import assign_speaker
from video_vec2wav2_tokenizer.utils.config import Config


def test_parser_process() -> None:
    parser = build_parser()
    args = parser.parse_args(["process", "./videos", "--extract-features"])
    assert args.command == "process"
    assert args.input == "./videos"
    assert args.extract_features is True


def test_parser_requires_command() -> None:
    parser = build_parser()
    with pytest.raises(SystemExit):
        parser.parse_args([])


@pytest.mark.parametrize("command", ["transcribe", "segment", "features", "train"])
def test_parser_subcommands(command: str) -> None:
    parser = build_parser()
    args = parser.parse_args([command, "./input"])
    assert args.command == command


def test_speaker_modes() -> None:
    fixed = Config(speaker_mode="fixed", default_speaker="speaker_001")
    assert assign_speaker(fixed, video_index=3, file_index=7) == "speaker_001"

    per_video = Config(speaker_mode="per_video")
    assert assign_speaker(per_video, video_index=3, file_index=7) == "speaker_003"

    per_file = Config(speaker_mode="per_file")
    assert assign_speaker(per_file, video_index=3, file_index=7) == "speaker_007"