deekshachilukuri commited on
Commit
6a6f2e1
1 Parent(s): d53d512

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -16,13 +16,23 @@ with patch('builtins.input', always_yes):
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
- output_path = "/content/cloned_audio.wav" # Setting the output path
20
- tts.tts_to_file(text,
21
- speaker_wav=audio_file_path, # Directly use the file path string
22
- language="en", # Assuming the language is English
23
- file_path=output_path,
24
- split_sentences=True)
 
 
 
 
 
 
 
 
 
25
  return output_path
 
26
 
27
  import gradio as gr
28
  # Define the Gradio interface
 
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
+ # Create a directory if it does not exist
20
+ output_dir = "/tmp/"
21
+ if not os.path.exists(output_dir):
22
+ os.makedirs(output_dir)
23
+
24
+ output_path = os.path.join(output_dir, "cloned_audio.wav") # Using /tmp/ directory
25
+ tts.tts_to_file(
26
+ text,
27
+ speaker_wav=audio_file_path, # Directly use the file path string
28
+ language="en", # Assuming the language is English
29
+ file_path=output_path,
30
+ split_sentences=True,
31
+ # Assuming the TTS model requires a speaker identifier and '1' is a valid identifier
32
+ speaker="1"
33
+ )
34
  return output_path
35
+
36
 
37
  import gradio as gr
38
  # Define the Gradio interface