Spaces:
Runtime error
Runtime error
gchhablani
commited on
Commit
•
7e520da
1
Parent(s):
2ecf349
Fix TTS speech issue
Browse files- apps/mic.py +3 -2
- apps/utils.py +2 -2
apps/mic.py
CHANGED
@@ -139,10 +139,11 @@ def app(state):
|
|
139 |
|
140 |
try:
|
141 |
clean_text = re.sub(r'[^A-Za-z0-9 ]+', '', sequence[0])
|
|
|
142 |
audio_bytes = voicerss_tts(clean_text, lang_id)
|
143 |
-
st.audio(audio_bytes
|
144 |
except:
|
145 |
-
|
146 |
|
147 |
|
148 |
|
|
|
139 |
|
140 |
try:
|
141 |
clean_text = re.sub(r'[^A-Za-z0-9 ]+', '', sequence[0])
|
142 |
+
# st.write("**Cleaned Text**: ",clean_text)
|
143 |
audio_bytes = voicerss_tts(clean_text, lang_id)
|
144 |
+
st.audio(audio_bytes)
|
145 |
except:
|
146 |
+
st.info("Unabled to generate audio. Please try again in some time."
|
147 |
|
148 |
|
149 |
|
apps/utils.py
CHANGED
@@ -20,10 +20,10 @@ def voicerss_tts(text, lang_id):
|
|
20 |
}
|
21 |
url = "https://voicerss-text-to-speech.p.rapidapi.com/"
|
22 |
|
23 |
-
querystring = {"key":"
|
24 |
|
25 |
headers = {
|
26 |
-
'x-rapidapi-key':
|
27 |
'x-rapidapi-host': "voicerss-text-to-speech.p.rapidapi.com"
|
28 |
}
|
29 |
|
|
|
20 |
}
|
21 |
url = "https://voicerss-text-to-speech.p.rapidapi.com/"
|
22 |
|
23 |
+
querystring = {"key":st.secrets["voicerss_key"],"hl":lang_id_to_code_map[lang_id],"src":text,"f":"8khz_8bit_mono","c":"mp3","r":"0"}
|
24 |
|
25 |
headers = {
|
26 |
+
'x-rapidapi-key': "0493c0e0f4mshe80b4d8c8986e14p103af6jsna45ff41b76b1",
|
27 |
'x-rapidapi-host': "voicerss-text-to-speech.p.rapidapi.com"
|
28 |
}
|
29 |
|