Spaces:
Running
Running
deekshachilukuri
commited on
Commit
•
b0c0136
1
Parent(s):
d53d512
Update app.py
Browse files
app.py
CHANGED
@@ -15,13 +15,23 @@ with patch('builtins.input', always_yes):
|
|
15 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
16 |
tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=False).to(device)
|
17 |
|
|
|
18 |
def generate_voice(text, audio_file_path):
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
return output_path
|
26 |
|
27 |
import gradio as gr
|
|
|
15 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
16 |
tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=False).to(device)
|
17 |
|
18 |
+
|
19 |
def generate_voice(text, audio_file_path):
|
20 |
+
# Create a directory if it does not exist
|
21 |
+
output_dir = "/tmp/"
|
22 |
+
if not os.path.exists(output_dir):
|
23 |
+
os.makedirs(output_dir)
|
24 |
+
|
25 |
+
output_path = os.path.join(output_dir, "cloned_audio.wav") # Using /tmp/ directory
|
26 |
+
tts.tts_to_file(
|
27 |
+
text,
|
28 |
+
speaker_wav=audio_file_path, # Directly use the file path string
|
29 |
+
language="en", # Assuming the language is English
|
30 |
+
file_path=output_path,
|
31 |
+
split_sentences=True,
|
32 |
+
# Assuming the TTS model requires a speaker identifier and '1' is a valid identifier
|
33 |
+
speaker="1"
|
34 |
+
)
|
35 |
return output_path
|
36 |
|
37 |
import gradio as gr
|