Vo Hoang Minh commited on
Commit ·
2f0faec
1
Parent(s): 1d3c16f
- pkg/tts_run.py +17 -3
pkg/tts_run.py
CHANGED
|
@@ -209,15 +209,29 @@ def speech(text, voice, rate, pitch, webhook=None):
|
|
| 209 |
srt_file.write(srt_content)
|
| 210 |
|
| 211 |
if webhook:
|
| 212 |
-
dm = "https://minhvh-tool.hf.space/gradio_api"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
data = json.dumps({
|
| 214 |
-
"audio":
|
| 215 |
-
"subtitle":
|
| 216 |
})
|
| 217 |
payload = {
|
| 218 |
"data" : base64_encode(data),
|
| 219 |
"status": "success"
|
| 220 |
}
|
|
|
|
| 221 |
requests.post(webhook, json=payload, timeout=10)
|
| 222 |
|
| 223 |
return audio_file.name, srt_file.name
|
|
|
|
| 209 |
srt_file.write(srt_content)
|
| 210 |
|
| 211 |
if webhook:
|
| 212 |
+
dm = "https://minhvh-tool.hf.space/gradio_api"
|
| 213 |
+
|
| 214 |
+
audio_url = ""
|
| 215 |
+
srt_url = ""
|
| 216 |
+
with open(audio_file.name, "rb") as f:
|
| 217 |
+
r = requests.post(dm + '/upload', files={"files": f}, timeout=10)
|
| 218 |
+
r.raise_for_status()
|
| 219 |
+
audio_url = f'{dm}/file={r.json()[0]}'
|
| 220 |
+
|
| 221 |
+
with open(srt_file.name, "rb") as f:
|
| 222 |
+
r = requests.post(dm + '/upload', files={"files": f}, timeout=10)
|
| 223 |
+
r.raise_for_status()
|
| 224 |
+
srt_url = f'{dm}/file={r.json()[0]}'
|
| 225 |
+
|
| 226 |
data = json.dumps({
|
| 227 |
+
"audio": audio_url,
|
| 228 |
+
"subtitle": srt_url
|
| 229 |
})
|
| 230 |
payload = {
|
| 231 |
"data" : base64_encode(data),
|
| 232 |
"status": "success"
|
| 233 |
}
|
| 234 |
+
|
| 235 |
requests.post(webhook, json=payload, timeout=10)
|
| 236 |
|
| 237 |
return audio_file.name, srt_file.name
|