Voice mother with Carol and synchronize all call events
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Split a voice batch against word timestamps; reject missing script words.
|
||||
|
||||
Usage: python split_voice_batch.py AUDIO WORDS_JSON LINES_JSON OUTPUT_DIRECTORY
|
||||
Usage: python split_voice_batch.py AUDIO WORDS_JSON LINES_JSON OUTPUT_DIRECTORY [SCORE_JSON]
|
||||
Requires soundfile (the local build helper directory is also supported).
|
||||
"""
|
||||
from pathlib import Path
|
||||
@@ -26,11 +26,24 @@ def main():
|
||||
data = json.loads(words_path.read_text(encoding="utf-8"))
|
||||
words = data["words"] if isinstance(data, dict) else data
|
||||
lines = json.loads(lines_path.read_text(encoding="utf-8"))
|
||||
pronunciations = {}
|
||||
if len(sys.argv) > 5:
|
||||
score = json.loads(Path(sys.argv[5]).read_text(encoding="utf-8"))
|
||||
pronunciations = score["pronunciation"]
|
||||
spoken, timing = [], []
|
||||
in_tag = False
|
||||
for word in words:
|
||||
if word.get("type", "word") != "word":
|
||||
continue
|
||||
for token in tokens(word["text"]):
|
||||
text = word["text"]
|
||||
# The provider may retain direction tags and IPA in its timed output.
|
||||
# Tags are metadata, not dialogue; map IPA back to the caption word.
|
||||
if text.startswith("[") or in_tag:
|
||||
in_tag = "]" not in text
|
||||
continue
|
||||
for spelling, ipa in pronunciations.items():
|
||||
text = text.replace(ipa, spelling)
|
||||
for token in tokens(text):
|
||||
spoken.append(token)
|
||||
timing.append((float(word["start"]), float(word["end"])))
|
||||
reference, spans = [], []
|
||||
|
||||
Reference in New Issue
Block a user