Commit
·
1f8d235
1
Parent(s):
8c27967
limit long audio files
Browse files
app.py
CHANGED
|
@@ -182,6 +182,19 @@ def process(
|
|
| 182 |
date_time = now.strftime("%Y-%m-%d %H:%M:%S.%f")
|
| 183 |
MyPrint(f"Started at {date_time}")
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
start = time.time()
|
| 186 |
|
| 187 |
recognizer = get_pretrained_model(
|
|
@@ -198,8 +211,6 @@ def process(
|
|
| 198 |
date_time = now.strftime("%Y-%m-%d %H:%M:%S.%f")
|
| 199 |
end = time.time()
|
| 200 |
|
| 201 |
-
metadata = torchaudio.info(filename)
|
| 202 |
-
duration = metadata.num_frames / sample_rate
|
| 203 |
rtf = (end - start) / duration
|
| 204 |
|
| 205 |
MyPrint(f"Finished at {date_time} s. Elapsed: {end - start: .3f} s")
|
|
|
|
| 182 |
date_time = now.strftime("%Y-%m-%d %H:%M:%S.%f")
|
| 183 |
MyPrint(f"Started at {date_time}")
|
| 184 |
|
| 185 |
+
metadata = torchaudio.info(filename)
|
| 186 |
+
duration = metadata.num_frames / sample_rate
|
| 187 |
+
|
| 188 |
+
if duration > 40:
|
| 189 |
+
info = f"""
|
| 190 |
+
Input audio is too long.
|
| 191 |
+
Please switch to
|
| 192 |
+
https://huggingface.co/spaces/k2-fsa/generate-subtitles-for-videos
|
| 193 |
+
for long audios.
|
| 194 |
+
"""
|
| 195 |
+
MyPrint(info)
|
| 196 |
+
return "audio tooooo loooooong", build_html_output(info)
|
| 197 |
+
|
| 198 |
start = time.time()
|
| 199 |
|
| 200 |
recognizer = get_pretrained_model(
|
|
|
|
| 211 |
date_time = now.strftime("%Y-%m-%d %H:%M:%S.%f")
|
| 212 |
end = time.time()
|
| 213 |
|
|
|
|
|
|
|
| 214 |
rtf = (end - start) / duration
|
| 215 |
|
| 216 |
MyPrint(f"Finished at {date_time} s. Elapsed: {end - start: .3f} s")
|