Neomindapp commited on
Commit
44aa222
·
verified ·
1 Parent(s): dcf3e06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -1,32 +1,26 @@
1
  import gradio as gr
2
- from TTS.api import TTS # Ensure this import path is correct
3
 
4
- # Define paths to the model and configuration
5
- model_path = "best_model.pth" # Directory where your model is saved
6
- config_path = "config.json" # Configuration file
7
 
8
- # Initialize TTS with your model and configuration
9
- tts = TTS(model_path=model_path, config_path=config_path)
 
10
 
11
  def generate_speech(text):
12
- # Generate speech using the model
13
- # Adjust based on the correct method for generating speech
14
- wav = tts.tts(text) # Ensure this is the correct method for your version
15
-
16
- # Save the generated audio to a temporary file
17
  audio_path = "output.wav"
18
  with open(audio_path, "wb") as f:
19
  f.write(wav)
20
-
21
  return audio_path
22
 
23
- # Define the Gradio interface
24
  iface = gr.Interface(
25
  fn=generate_speech,
26
  inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
27
  outputs=gr.Audio(type="filepath"),
28
- title="Text-to-Speech with Coqui TTS",
29
- description="Generate speech from text using a custom Coqui TTS model."
30
  )
31
 
32
  if __name__ == "__main__":
 
1
  import gradio as gr
2
+ from TTS.api import TTS # Import TTS API
3
 
4
+ # Initialize TTS
5
+ tts = TTS(model_path="best_model.pth", config_path="config.json")
 
6
 
7
+ # Ensure the 'is_multi_lingual' attribute is set if it's not present
8
+ if not hasattr(tts, 'is_multi_lingual'):
9
+ tts.is_multi_lingual = False # Set to False since your model is not multilingual
10
 
11
  def generate_speech(text):
12
+ wav = tts.tts(text) # Ensure this is the correct method for generating speech
 
 
 
 
13
  audio_path = "output.wav"
14
  with open(audio_path, "wb") as f:
15
  f.write(wav)
 
16
  return audio_path
17
 
18
+ # Define Gradio interface
19
  iface = gr.Interface(
20
  fn=generate_speech,
21
  inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
22
  outputs=gr.Audio(type="filepath"),
23
+ title="Text-to-Speech with Coqui TTS"
 
24
  )
25
 
26
  if __name__ == "__main__":