File size: 980 Bytes
d33f32d
 
 
 
0a5aead
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from TTS.api import TTS
import gradio as gr

# Initialize the TTS model
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)

@spaces.GPU
def generate_speech(text, speaker_wav, language):
    # Generate speech using the provided text, speaker voice, and language
    file_path = "output.wav"
    tts.tts_to_file(text=text,
                    file_path=file_path,
                    speaker_wav=speaker_wav,
                    language=language)
    return file_path

# Create the Gradio interface
interface = gr.Interface(
    fn=generate_speech,
    inputs=[
        gr.Textbox(label="Enter your text"),
        gr.Textbox(label="Path to target speaker WAV file", value="/content/speaker.wav"),
        gr.Dropdown(label="Language", choices=["en"], value="en")
    ],
    outputs="audio",
    title="Voice Synthesis and Cloning with Coqui-XTTS",
    description="Synthesize speech using a target voice and language."
)
# Launch the interface
interface.launch()