Spaces:
Runtime error
Runtime error
import gradio as gr | |
from TTS.api import TTS | |
import os | |
# Load the voice cloning model | |
tts = TTS("tts_models/multilingual/multi-dataset/your_tts").to("cpu") | |
def generate_cloned_voice(text, reference_audio): | |
output_path = "output.wav" | |
# Generate cloned speech | |
tts.tts_to_file(text=text, speaker_wav=reference_audio, file_path=output_path) | |
return output_path | |
# Create the Gradio interface | |
interface = gr.Interface( | |
fn=generate_cloned_voice, | |
inputs=[ | |
gr.Textbox(label="Enter Translated Text"), | |
gr.Audio(label="Upload Reference Audio", type="filepath") | |
], | |
outputs=gr.Audio(label="Generated Cloned Voice"), | |
title="Free Voice Cloning API", | |
description="Upload a sample voice and input text. The system will generate the text in the same voice." | |
) | |
# Launch the Gradio app | |
interface.launch() | |