Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,9 +34,13 @@ def gain_time(audio):
|
|
| 34 |
return float(result.stdout)
|
| 35 |
|
| 36 |
def left_justified(audio):
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
def time_verify():
|
| 42 |
audios = [vocals_monorail, text_to_speech]
|
|
@@ -110,12 +114,14 @@ def video_inputs(video, TR_LANGUAGE, LANGUAGE, SPEAKER):
|
|
| 110 |
'transcribe', # str in 'Task' Radio component
|
| 111 |
api_name='/predict'
|
| 112 |
)
|
|
|
|
|
|
|
| 113 |
except ffmpy.FFRuntimeError:
|
| 114 |
raise gr.Error('Mismatched audio!')
|
| 115 |
-
except
|
| 116 |
-
raise gr.Error(e)
|
| 117 |
-
|
| 118 |
-
|
| 119 |
|
| 120 |
async def amain():
|
| 121 |
communicate = edge_tts.Communicate(ts_text, SPEAKER)
|
|
|
|
| 34 |
return float(result.stdout)
|
| 35 |
|
| 36 |
def left_justified(audio):
|
| 37 |
+
try:
|
| 38 |
+
command = ['ffmpeg', '-i', audio, '-af', 'silencedetect=n=-38dB:d=0.01', '-f', 'null', '-']
|
| 39 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
| 40 |
+
start_justified = re.search(r'silence_duration: (\d.\d+)', result.stdout.decode(), re.M|re.S).group(1)
|
| 41 |
+
except AttributeError:
|
| 42 |
+
raise gr.Error('No start sound detected!')
|
| 43 |
+
return start_justified
|
| 44 |
|
| 45 |
def time_verify():
|
| 46 |
audios = [vocals_monorail, text_to_speech]
|
|
|
|
| 114 |
'transcribe', # str in 'Task' Radio component
|
| 115 |
api_name='/predict'
|
| 116 |
)
|
| 117 |
+
|
| 118 |
+
ts_text = translator(result, TR_LANGUAGE, LANGUAGE)
|
| 119 |
except ffmpy.FFRuntimeError:
|
| 120 |
raise gr.Error('Mismatched audio!')
|
| 121 |
+
except RemoteDisconnected as e:
|
| 122 |
+
raise gr.Error(f'API:{e}')ConnectionError
|
| 123 |
+
except ConnectionError as i:
|
| 124 |
+
raise gr.Error(f'translator ConnectionError:{i}')
|
| 125 |
|
| 126 |
async def amain():
|
| 127 |
communicate = edge_tts.Communicate(ts_text, SPEAKER)
|