mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-12-06 01:47:39 +09:00
Added workaround for missing timestamps
This commit is contained in:
1 parent
995404582b
commit
050bfafbf7
2 files changed
+12
-7
No files matched your search
@@ -13,6 +13,6 @@ class TranscribedData:
|
||||
self.word = transcribed_json.get(
|
||||
"word", transcribed_json.get("text", None)
|
||||
)
|
||||
self.end = transcribed_json["end"]
|
||||
self.start = transcribed_json["start"]
|
||||
self.end = transcribed_json.get("end", None)
|
||||
self.start = transcribed_json.get("start", None)
|
||||
self.is_hyphen = None
|
||||
@@ -66,12 +66,17 @@ def convert_to_transcribed_data(result_aligned):
|
||||
transcribed_data = []
|
||||
for segment in result_aligned["segments"]:
|
||||
for obj in segment["words"]:
|
||||
if len(obj) < 4:
|
||||
print(
|
||||
f"{red_highlighted('Error: Skipping Word {}, because of missing timings'.format(obj['word']))}"
|
||||
)
|
||||
continue
|
||||
vtd = TranscribedData(obj) # create custom Word object
|
||||
vtd.word = vtd.word + " " # add space to end of word
|
||||
if len(obj) < 4:
|
||||
previous = transcribed_data[-1]
|
||||
if not previous:
|
||||
previous.end = 0
|
||||
previous.end = ""
|
||||
vtd.start = previous.end + 0.1
|
||||
vtd.end = previous.end + 0.2
|
||||
msg = f'Error: There is no timestamp for word: {obj["word"]}. ' \
|
||||
f'Fixing it by placing it after the previous word: {previous.word}. At start: {vtd.start} end: {vtd.end}. Fix it manually!'
|
||||
print(f"{red_highlighted(msg)}")
|
||||
transcribed_data.append(vtd) # and add it to list
|
||||
return transcribed_data
|
||||
Reference in new issue
Block a user