Spaces:
Running
Running
Commit
·
f34b85f
1
Parent(s):
ff0618d
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -35,29 +35,39 @@ def write(filename, dtype, result_aligned):
|
|
| 35 |
|
| 36 |
if dtype == "vtt":
|
| 37 |
with open(
|
| 38 |
-
os.path.join(".", os.path.splitext(filename)[0] + ".vtt"),
|
|
|
|
|
|
|
| 39 |
) as vtt:
|
| 40 |
write_vtt(result_aligned["segments"], file=vtt)
|
| 41 |
if dtype == "srt":
|
| 42 |
with open(
|
| 43 |
-
os.path.join(".", os.path.splitext(filename)[0] + ".srt"),
|
|
|
|
|
|
|
| 44 |
) as srt:
|
| 45 |
write_srt(result_aligned["segments"], file=srt)
|
| 46 |
if dtype == "ass":
|
| 47 |
with open(
|
| 48 |
-
os.path.join(".", os.path.splitext(filename)[0] + ".ass"),
|
|
|
|
|
|
|
| 49 |
) as ass:
|
| 50 |
write_ass(result_aligned["segments"], file=ass)
|
| 51 |
if dtype == "tsv":
|
| 52 |
with open(
|
| 53 |
-
os.path.join(".", os.path.splitext(filename)[0] + ".tsv"),
|
|
|
|
|
|
|
| 54 |
) as tsv:
|
| 55 |
write_tsv(result_aligned["segments"], file=tsv)
|
| 56 |
if dtype == "plain text":
|
| 57 |
print("here")
|
| 58 |
print(filename)
|
| 59 |
with open(
|
| 60 |
-
os.path.join(".", os.path.splitext(filename)[0] + ".txt"),
|
|
|
|
|
|
|
| 61 |
) as txt:
|
| 62 |
write_txt(result_aligned["segments"], file=txt)
|
| 63 |
|
|
@@ -81,3 +91,5 @@ def get_key(val):
|
|
| 81 |
if val == value:
|
| 82 |
return key
|
| 83 |
return "Key not found"
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
if dtype == "vtt":
|
| 37 |
with open(
|
| 38 |
+
os.path.join(".", os.path.splitext(filename)[0] + ".vtt"),
|
| 39 |
+
"w",
|
| 40 |
+
encoding="utf-8",
|
| 41 |
) as vtt:
|
| 42 |
write_vtt(result_aligned["segments"], file=vtt)
|
| 43 |
if dtype == "srt":
|
| 44 |
with open(
|
| 45 |
+
os.path.join(".", os.path.splitext(filename)[0] + ".srt"),
|
| 46 |
+
"w",
|
| 47 |
+
encoding="utf-8",
|
| 48 |
) as srt:
|
| 49 |
write_srt(result_aligned["segments"], file=srt)
|
| 50 |
if dtype == "ass":
|
| 51 |
with open(
|
| 52 |
+
os.path.join(".", os.path.splitext(filename)[0] + ".ass"),
|
| 53 |
+
"w",
|
| 54 |
+
encoding="utf-8",
|
| 55 |
) as ass:
|
| 56 |
write_ass(result_aligned["segments"], file=ass)
|
| 57 |
if dtype == "tsv":
|
| 58 |
with open(
|
| 59 |
+
os.path.join(".", os.path.splitext(filename)[0] + ".tsv"),
|
| 60 |
+
"w",
|
| 61 |
+
encoding="utf-8",
|
| 62 |
) as tsv:
|
| 63 |
write_tsv(result_aligned["segments"], file=tsv)
|
| 64 |
if dtype == "plain text":
|
| 65 |
print("here")
|
| 66 |
print(filename)
|
| 67 |
with open(
|
| 68 |
+
os.path.join(".", os.path.splitext(filename)[0] + ".txt"),
|
| 69 |
+
"w",
|
| 70 |
+
encoding="utf-8",
|
| 71 |
) as txt:
|
| 72 |
write_txt(result_aligned["segments"], file=txt)
|
| 73 |
|
|
|
|
| 91 |
if val == value:
|
| 92 |
return key
|
| 93 |
return "Key not found"
|
| 94 |
+
|
| 95 |
+
|