Vo Hoang Minh commited on
Commit ·
ff6576c
1
Parent(s): 821ed2f
- pkg/tts_run.py +9 -5
pkg/tts_run.py
CHANGED
|
@@ -169,6 +169,9 @@ def add_karaoke_subtitles(subs, words):
|
|
| 169 |
subs.append(pysubs2.SSAEvent(start=event_start, end=event_end, text=highlighted))
|
| 170 |
|
| 171 |
|
|
|
|
|
|
|
|
|
|
| 172 |
def speech(text, voice, rate, pitch, webhook=None):
|
| 173 |
text = text.strip()
|
| 174 |
|
|
@@ -205,12 +208,13 @@ def speech(text, voice, rate, pitch, webhook=None):
|
|
| 205 |
srt_file.write(srt_content)
|
| 206 |
|
| 207 |
if webhook:
|
| 208 |
-
dm = "https://minhvh-tool.hf.space/gradio_api"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
payload = {
|
| 210 |
-
"data":
|
| 211 |
-
"audio": f'{dm}/file={Path(audio_file.name)}',
|
| 212 |
-
"subtitle": f'{dm}/file={Path(srt_file.name)}'
|
| 213 |
-
},
|
| 214 |
"status": "success"
|
| 215 |
}
|
| 216 |
requests.post(webhook, json=payload, timeout=10)
|
|
|
|
| 169 |
subs.append(pysubs2.SSAEvent(start=event_start, end=event_end, text=highlighted))
|
| 170 |
|
| 171 |
|
| 172 |
+
def base64_encode(s):
|
| 173 |
+
return base64.b64encode(s.encode("utf-8")).decode("utf-8")
|
| 174 |
+
|
| 175 |
def speech(text, voice, rate, pitch, webhook=None):
|
| 176 |
text = text.strip()
|
| 177 |
|
|
|
|
| 208 |
srt_file.write(srt_content)
|
| 209 |
|
| 210 |
if webhook:
|
| 211 |
+
dm = "https://minhvh-tool.hf.space/gradio_api"
|
| 212 |
+
data = {
|
| 213 |
+
"audio": f"{dm}/file={Path(audio_file.name).name}",
|
| 214 |
+
"subtitle": f"{dm}/file={Path(srt_file.name).name}"
|
| 215 |
+
}
|
| 216 |
payload = {
|
| 217 |
+
"data" : base64_encode(str(data)),
|
|
|
|
|
|
|
|
|
|
| 218 |
"status": "success"
|
| 219 |
}
|
| 220 |
requests.post(webhook, json=payload, timeout=10)
|