Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
from TTS.
|
4 |
-
from TTS import TTS
|
5 |
-
import numpy as np
|
6 |
-
import soundfile as sf
|
7 |
|
8 |
# Define paths to the model and configuration
|
9 |
model_path = "best_model.pth" # Directory where your model is saved
|
10 |
config_path = "config.json" # Configuration file
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
tts = TTS(config, model_path=model_path)
|
15 |
|
16 |
def generate_speech(text):
|
17 |
# Generate speech using the model
|
18 |
-
wav = tts.
|
19 |
|
20 |
# Save the generated audio to a temporary file
|
21 |
audio_path = "output.wav"
|
22 |
-
|
|
|
23 |
|
24 |
# Read the audio file to return as binary data
|
25 |
with open(audio_path, "rb") as f:
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from TTS.api import TTS # Correct import path for TTS API
|
|
|
|
|
|
|
4 |
|
5 |
# Define paths to the model and configuration
|
6 |
model_path = "best_model.pth" # Directory where your model is saved
|
7 |
config_path = "config.json" # Configuration file
|
8 |
|
9 |
+
# Initialize TTS with your model and configuration
|
10 |
+
tts = TTS(model_path=model_path, config_path=config_path)
|
|
|
11 |
|
12 |
def generate_speech(text):
|
13 |
# Generate speech using the model
|
14 |
+
wav = tts.tts(text)
|
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 |
# Read the audio file to return as binary data
|
22 |
with open(audio_path, "rb") as f:
|