File size: 1,854 Bytes
bfc29c2
 
2b547d6
019ccc0
2b547d6
e45dd54
 
 
 
bfc29c2
 
 
2b547d6
bfc29c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
019ccc0
 
c232aea
 
 
35e81b5
bfc29c2
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
from random import choices

import gradio as gr
from TTS.api import TTS

# voice_conversion_models/multilingual/multi-dataset/knnvc
# voice_conversion_models/multilingual/multi-dataset/openvoice_v1
# voice_conversion_models/multilingual/multi-dataset/openvoice_v2
tts = TTS(model_name="voice_conversion_models/multilingual/vctk/freevc24", gpu=False)
tts2 = TTS(model_name="voice_conversion_models/multilingual/multi-dataset/knnvc", gpu=False)
tts3 = TTS(model_name="voice_conversion_models/multilingual/multi-dataset/openvoice_v1", gpu=False)
tts4 = TTS(model_name="voice_conversion_models/multilingual/multi-dataset/openvoice_v2", gpu=False)

def greet(source, target, choices_s):
    if choices_s == "freevc24":
        tts.voice_conversion_to_file(
            source_wav=source,
            target_wav=target,
            file_path="output.wav"
        )
    elif choices_s == "knnvc":
        tts2.voice_conversion_to_file(
            source_wav=source,
            target_wav=target,
            file_path="output.wav"
        )
    elif choices_s == "openvoice_v1":
        tts3.voice_conversion_to_file(
            source_wav=source,
            target_wav=target,
            file_path="output.wav"
        )
    elif choices_s == "openvoice_v2":
        tts4.voice_conversion_to_file(
            source_wav=source,
            target_wav=target,
            file_path="output.wav"
        )
    return "output.wav"

demo = gr.Interface(fn=greet, inputs=[gr.Audio(label="Source audio", value="kratos.wav", type="filepath"),
                                      gr.Audio(label="Target audio", value="nikole_kidman.wav", type="filepath"), 
                                      gr.Dropdown(label="Model name", choices=["freevc24", "knnvc", "openvoice_v1", "openvoice_v2"])],
                    outputs=gr.Audio(type="filepath"))
demo.launch()