Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,16 +19,11 @@ def get_text():
|
|
19 |
# Function to select the language model
|
20 |
def select_language():
|
21 |
language_options = {
|
22 |
-
"English": "
|
23 |
-
"Spanish": "
|
24 |
-
"German": "
|
25 |
-
"French": "
|
26 |
-
"
|
27 |
-
"Chinese": "espnet/kan-bayashi_csmsc_vits",
|
28 |
-
"Russian": "espnet/kan-bayashi_css10_russian_tts_train_conformer_fastspeech2",
|
29 |
-
"Italian": "espnet/kan-bayashi_css10_italian_tts_train_conformer_fastspeech2",
|
30 |
-
"Portuguese": "espnet/kan-bayashi_css10_portuguese_tts_train_conformer_fastspeech2",
|
31 |
-
"Dutch": "espnet/kan-bayashi_css10_dutch_tts_train_conformer_fastspeech2"
|
32 |
}
|
33 |
selected_language = st.selectbox("Select Language", list(language_options.keys()))
|
34 |
return language_options[selected_language]
|
@@ -62,13 +57,17 @@ if submit and user_input:
|
|
62 |
url = f"https://api-inference.huggingface.co/models/{model_id}"
|
63 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_API_TOKEN}"}
|
64 |
payload = {"inputs": user_input}
|
|
|
65 |
# Requesting raw response with the option to manually handle the audio
|
66 |
response = requests.post(url, headers=headers, json=payload, stream=True)
|
|
|
67 |
if response.status_code == 200:
|
68 |
audio_data = response.content
|
69 |
-
# Assuming the response is in audio/
|
70 |
play_audio(audio_data)
|
71 |
else:
|
72 |
st.error(f"Error: {response.status_code} - {response.text}")
|
73 |
elif submit:
|
74 |
-
st.warning("Please enter some text.") # Warning for empty input
|
|
|
|
|
|
19 |
# Function to select the language model
|
20 |
def select_language():
|
21 |
language_options = {
|
22 |
+
"English": "google/tts_model_en",
|
23 |
+
"Spanish": "google/tts_model_es",
|
24 |
+
"German": "google/tts_model_de",
|
25 |
+
"French": "google/tts_model_fr",
|
26 |
+
"Italian": "google/tts_model_it",
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
selected_language = st.selectbox("Select Language", list(language_options.keys()))
|
29 |
return language_options[selected_language]
|
|
|
57 |
url = f"https://api-inference.huggingface.co/models/{model_id}"
|
58 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_API_TOKEN}"}
|
59 |
payload = {"inputs": user_input}
|
60 |
+
|
61 |
# Requesting raw response with the option to manually handle the audio
|
62 |
response = requests.post(url, headers=headers, json=payload, stream=True)
|
63 |
+
|
64 |
if response.status_code == 200:
|
65 |
audio_data = response.content
|
66 |
+
# Assuming the response is in audio/wav or another format
|
67 |
play_audio(audio_data)
|
68 |
else:
|
69 |
st.error(f"Error: {response.status_code} - {response.text}")
|
70 |
elif submit:
|
71 |
+
st.warning("Please enter some text.") # Warning for empty input
|
72 |
+
|
73 |
+
has context menu
|