File size: 1,481 Bytes
0019e18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

# import gradio as gr
# import spaces
from infer_rvc_python import BaseLoader
import random
import logging
import time
import soundfile as sf
from infer_rvc_python.main import download_manager
import zipfile

converter = BaseLoader(
    only_cpu=True, hubert_path="./hubert_base.pt", rmvpe_path="./rmvpe.pt"
)


def main():
    audio_out = run(
        ["super-shy-mdx.mp3"],
        "test.pth",
        "rmvpe+",
        -12,
        "added_IVF839_Flat_nprobe_1_test_v2.index",
        0.75,  # index_influence
        3,  # respiration_median_filtering,
        0.25,  # envelope_ratio,
        0.5,  # consonant_breath_protection
    )


def convert_now(audio_files, random_tag, converter):
    return converter(audio_files, random_tag, overwrite=False, parallel_workers=0)


def run(
    audio_files,
    file_m,
    pitch_alg,
    pitch_lvl,
    file_index,
    index_inf,
    r_m_f,
    e_r,
    c_b_p,
):
    random_tag = "USER_" + str(random.randint(10000000, 99999999))

    converter.apply_conf(
        tag=random_tag,
        file_model=file_m,
        pitch_algo=pitch_alg,
        pitch_lvl=pitch_lvl,
        file_index=file_index,
        index_influence=index_inf,
        respiration_median_filtering=r_m_f,
        envelope_ratio=e_r,
        consonant_breath_protection=c_b_p,
        resample_sr=44100 if audio_files[0].endswith(".mp3") else 0,
    )

    return convert_now(audio_files, random_tag, converter)

if __name__ == "__main__":
    main()