KiranRand commited on
Commit
f41d3a4
·
verified ·
1 Parent(s): 0cfffd5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from TTS.api import TTS
3
+ import os
4
+
5
+ # Load the voice cloning model
6
+ tts = TTS("tts_models/multilingual/multi-dataset/your_tts").to("cpu")
7
+
8
+ def generate_cloned_voice(text, reference_audio):
9
+ output_path = "output.wav"
10
+
11
+ # Generate cloned speech
12
+ tts.tts_to_file(text=text, speaker_wav=reference_audio, file_path=output_path)
13
+
14
+ return output_path
15
+
16
+ # Create the Gradio interface
17
+ interface = gr.Interface(
18
+ fn=generate_cloned_voice,
19
+ inputs=[
20
+ gr.Textbox(label="Enter Translated Text"),
21
+ gr.Audio(label="Upload Reference Audio", type="filepath")
22
+ ],
23
+ outputs=gr.Audio(label="Generated Cloned Voice"),
24
+ title="Free Voice Cloning API",
25
+ description="Upload a sample voice and input text. The system will generate the text in the same voice."
26
+ )
27
+
28
+ # Launch the Gradio app
29
+ interface.launch()