File size: 1,703 Bytes
938411e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
67
import argparse
import os 
import json


def validate_sampling_rate(value):
    valid_sampling = [
        "32000",
        "40000",
        "48000",
    ]
    if value in valid_sampling:
        return value
    else:
        raise argparse.ArgumentTypeError(
            f"Invalid sampling_rate. Please choose from {valid_sampling} not {value}"
        )


def validate_f0up_key(value):
    f0up_key = int(value)
    if -24 <= f0up_key <= 24:
        return f0up_key
    else:
        raise argparse.ArgumentTypeError(f"f0up_key must be in the range of -24 to +24")

def validate_true_false(value):
    valid_tf = [
        "True",
        "False",
    ]
    if value in valid_tf:
        return value
    else:
        raise argparse.ArgumentTypeError(
            f"Invalid true_false. Please choose from {valid_tf} not {value}"
        )

def validate_f0method(value):
    valid_f0methods = [
        "pm",
        "dio",
        "crepe",
        "crepe-tiny",
        "harvest",
        "rmvpe",
    ]
    if value in valid_f0methods:
        return value
    else:
        raise argparse.ArgumentTypeError(
            f"Invalid f0method. Please choose from {valid_f0methods} not {value}"
        )

def validate_tts_voices(value):
    json_path = os.path.join("rvc", "lib", "tools", "tts_voices.json")
    with open(json_path, 'r') as file:
        tts_voices_data = json.load(file)

    # Extrae los valores de "ShortName" del JSON
    short_names = [voice.get("ShortName", "") for voice in tts_voices_data]
    if value in short_names:
        return value
    else:
        raise argparse.ArgumentTypeError(
            f"Invalid voice. Please choose from {short_names} not {value}"
        )