Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
from TTS.api import TTS
|
3 |
-
import requests
|
4 |
-
|
5 |
-
#API_URL = "https://YOUR-SPACE-NAME.hf.space/api/predict"
|
6 |
-
API_URL = "https://shanulhaq-elevenlabs-ai-audio.hf.space"
|
7 |
-
|
8 |
-
data = {
|
9 |
-
"data": ["Your text to convert to speech."]
|
10 |
-
}
|
11 |
-
|
12 |
-
response = requests.post(API_URL, json=data)
|
13 |
-
|
14 |
-
if response.status_code == 200:
|
15 |
-
try:
|
16 |
-
json_response = response.json()
|
17 |
-
if "data" in json_response:
|
18 |
-
audio_content = json_response["data"][0]
|
19 |
-
else:
|
20 |
-
print("No data found in the response:", json_response)
|
21 |
-
except requests.exceptions.JSONDecodeError:
|
22 |
-
print("Failed to decode JSON. Response content:", response.text)
|
23 |
-
else:
|
24 |
-
print(f"Failed to get a valid response. Status code: {response.status_code}")
|
25 |
-
print("Response content:", response.text)
|
26 |
-
|
27 |
-
|
28 |
-
# Initialize the TTS model
|
29 |
-
#tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False, gpu=False)
|
30 |
|
31 |
# Initialize the multilingual TTS model
|
32 |
tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
|
33 |
|
34 |
-
|
35 |
def text_to_speech(text):
|
36 |
# Generate speech from text
|
37 |
audio_path = tts.tts_to_file(text=text, file_path="output.wav")
|
@@ -43,8 +15,8 @@ def text_to_speech(text):
|
|
43 |
# Create Gradio interface
|
44 |
interface = gr.Interface(
|
45 |
fn=text_to_speech,
|
46 |
-
inputs=gr.
|
47 |
-
outputs=gr.
|
48 |
title="AI-Powered Text-to-Speech Converter",
|
49 |
description="Convert text to speech using AI models.",
|
50 |
)
|
|
|
1 |
import gradio as gr
|
2 |
from TTS.api import TTS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Initialize the multilingual TTS model
|
5 |
tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
|
6 |
|
|
|
7 |
def text_to_speech(text):
|
8 |
# Generate speech from text
|
9 |
audio_path = tts.tts_to_file(text=text, file_path="output.wav")
|
|
|
15 |
# Create Gradio interface
|
16 |
interface = gr.Interface(
|
17 |
fn=text_to_speech,
|
18 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter text here..."),
|
19 |
+
outputs=gr.Audio(type="file"),
|
20 |
title="AI-Powered Text-to-Speech Converter",
|
21 |
description="Convert text to speech using AI models.",
|
22 |
)
|