File size: 1,563 Bytes
125d85c
daf4e8e
 
 
125d85c
daf4e8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6d0059
 
daf4e8e
 
 
 
 
 
 
 
 
 
 
 
 
125d85c
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
import gradio as gr
import sys
from viitor_voice.inference.transformers_engine import TransformersEngine
import spaces

if __name__ == '__main__':
    # Initialize your OfflineInference class with the appropriate paths
    offline_inference = TransformersEngine("ZzWater/viitor-voice-mix")


    @spaces.GPU
    def clone_batch(text_list, prompt_audio, prompt_text):
        print(prompt_audio.name)
        try:
            audios = offline_inference.batch_infer(
                text_list=[text_list],
                prompt_audio_path=prompt_audio.name,  # Use uploaded file's path
                prompt_text=prompt_text,
            )
            return 24000, audios[0].cpu().numpy()[0].astype('float32')
        except Exception as e:
            return str(e)


    with gr.Blocks() as demo:
        gr.Markdown("# TTS Inference Interface")
        with gr.Tab("Batch Clone"):
            gr.Markdown("### Batch Clone TTS")

            text_list_clone = gr.Textbox(label="Input Text List",
                                         placeholder="Enter text")
            prompt_audio = gr.File(label="Upload Prompt Audio")
            prompt_text = gr.Textbox(label="Prompt Text", placeholder="Enter the prompt text")

            clone_button = gr.Button("Run Batch Clone")
            clone_output = gr.Audio(label="Generated Audios", type="numpy")

            clone_button.click(
                fn=clone_batch,
                inputs=[text_list_clone, prompt_audio, prompt_text],
                outputs=clone_output
            )

    demo.launch()