Vo Hoang Minh commited on
Commit
bb2e58f
·
1 Parent(s): 5b3c98c
Files changed (1) hide show
  1. pkg/tts_run.py +10 -12
pkg/tts_run.py CHANGED
@@ -216,27 +216,25 @@ def speech(text, voice, rate, pitch, webhook=None):
216
  r = requests.get('https://minhvh-n8.hf.space/api/upload', params={"name": key}, timeout=10)
217
  r.raise_for_status()
218
  return r.json().get('data')
219
-
220
-
221
-
222
- with open(audio_file.name, "rb") as f:
223
- r = requests.post(upload_url(audio_file.name), data=f, timeout=10)
224
- r.raise_for_status()
225
 
226
- with open(srt_file.name, "rb") as f:
227
- r = requests.post(upload_url(srt_file.name), data=f, timeout=10)
228
- r.raise_for_status()
 
 
 
 
 
229
 
230
  dm = 'https://s3.g86.xyz'
231
  data = {
232
- "audio": f'{dm}/{audio_file.name}',
233
- "subtitle": f'{dm}/{srt_file.name}'
234
  }
235
  payload = {
236
  "data" : data,
237
  "status": "success"
238
  }
239
- print(payload)
240
 
241
  requests.post(webhook, json=payload, timeout=10)
242
 
 
216
  r = requests.get('https://minhvh-n8.hf.space/api/upload', params={"name": key}, timeout=10)
217
  r.raise_for_status()
218
  return r.json().get('data')
 
 
 
 
 
 
219
 
220
+ audio_name = audio_file.name.split("/")[-1]
221
+ srt_name = srt_file.name.split("/")[-1]
222
+ names = [audio_name, srt_name]
223
+ for nm in names:
224
+ with open(nm, "rb") as f:
225
+ r = requests.post(upload_url(nm), data=f, timeout=10)
226
+ r.raise_for_status()
227
+
228
 
229
  dm = 'https://s3.g86.xyz'
230
  data = {
231
+ "audio": f'{dm}/{audio_name}',
232
+ "subtitle": f'{dm}/{srt_name}'
233
  }
234
  payload = {
235
  "data" : data,
236
  "status": "success"
237
  }
 
238
 
239
  requests.post(webhook, json=payload, timeout=10)
240