Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -61,7 +61,7 @@ async def generate_audio_with_voice_prefix(text_segment, default_voice, rate, pi
|
|
61 |
voice4_full = "en-GB-ThomasNeural - en-GB (Male)"
|
62 |
voice4_short = voice4_full.split(" - ")[0]
|
63 |
voice4F_full ="en-US-EmmaNeural - en-US (Female)"
|
64 |
-
voice4F_short =
|
65 |
voice5_full = "en-GB-RyanNeural - en-GB (Male)" #Old Man
|
66 |
voice5_short = voice5_full.split(" - ")[0]
|
67 |
voice6_full = "en-GB-MaisieNeural - en-GB (Female)" #Child
|
@@ -221,10 +221,15 @@ async def transcript_to_speech(transcript_text, voice, rate, pitch):
|
|
221 |
|
222 |
# Check duration until the next timestamp
|
223 |
if i + 1 < len(lines):
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
228 |
if current_audio_duration > duration_to_next:
|
229 |
# Hold and append audio from subsequent lines
|
230 |
j = i + 1
|
@@ -242,10 +247,15 @@ async def transcript_to_speech(transcript_text, voice, rate, pitch):
|
|
242 |
|
243 |
#check duration to the next timestamp.
|
244 |
if j + 1 < len(lines):
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
|
|
|
|
|
|
|
|
|
|
249 |
break
|
250 |
j += 1
|
251 |
else:
|
|
|
61 |
voice4_full = "en-GB-ThomasNeural - en-GB (Male)"
|
62 |
voice4_short = voice4_full.split(" - ")[0]
|
63 |
voice4F_full ="en-US-EmmaNeural - en-US (Female)"
|
64 |
+
voice4F_short = voice4_full.split(" - ")[0]
|
65 |
voice5_full = "en-GB-RyanNeural - en-GB (Male)" #Old Man
|
66 |
voice5_short = voice5_full.split(" - ")[0]
|
67 |
voice6_full = "en-GB-MaisieNeural - en-GB (Female)" #Child
|
|
|
221 |
|
222 |
# Check duration until the next timestamp
|
223 |
if i + 1 < len(lines):
|
224 |
+
next_start_time_line = lines[i+1]
|
225 |
+
next_start_time_match = re.match(r'(\d{2}):(\d{2}):(\d{2}),(\d{3})\s+.*', next_start_time_line)
|
226 |
+
if next_start_time_match:
|
227 |
+
next_h, next_m, next_s, next_ms = next_start_time_match.groups()
|
228 |
+
next_start_time_ms = (int(next_h) * 3600000 + int(next_m) * 60000 + int(next_s) * 1000 + int(next_ms))
|
229 |
+
duration_to_next = next_start_time_ms - start_time
|
230 |
+
else:
|
231 |
+
duration_to_next = float('inf') # Or some other large value
|
232 |
+
|
233 |
if current_audio_duration > duration_to_next:
|
234 |
# Hold and append audio from subsequent lines
|
235 |
j = i + 1
|
|
|
247 |
|
248 |
#check duration to the next timestamp.
|
249 |
if j + 1 < len(lines):
|
250 |
+
next_start_time_line_2 = lines[j+1]
|
251 |
+
next_start_time_match_2 = re.match(r'(\d{2}):(\d{2}):(\d{2}),(\d{3})\s+.*', next_start_time_line_2)
|
252 |
+
if next_start_time_match_2:
|
253 |
+
next_h_2, next_m_2, next_s_2, next_ms_2 = next_start_time_match_2.groups()
|
254 |
+
next_start_time_ms_2 = (int(next_h_2) * 3600000 + int(next_m_2) * 60000 + int(next_s_2) * 1000 + int(next_ms_2))
|
255 |
+
duration_to_next_2 = next_start_time_ms_2 - start_time
|
256 |
+
if current_audio_duration <= duration_to_next_2:
|
257 |
+
break
|
258 |
+
else:
|
259 |
break
|
260 |
j += 1
|
261 |
else:
|