deekshachilukuri commited on
Commit
d344bc4
·
verified ·
1 Parent(s): 4b21b18
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -1,3 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  # Define the Gradio interface
3
  iface = gr.Interface(
 
1
+ import gradio as gr
2
+ import torch
3
+ from TTS.api import TTS
4
+
5
+ # Assume that the TTS and its required setup are correctly configured similar to your script above
6
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
7
+ tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=False).to(device)
8
+
9
+ def generate_voice(text, audio_file_path):
10
+ output_path = "/content/cloned_audio.wav" # Setting the output path
11
+ tts.tts_to_file(text,
12
+ speaker_wav=audio_file_path, # Directly use the file path string
13
+ language="en", # Assuming the language is English
14
+ file_path=output_path,
15
+ split_sentences=True)
16
+ return output_path
17
+
18
  import gradio as gr
19
  # Define the Gradio interface
20
  iface = gr.Interface(