mirror of
https://github.com/m-bain/whisperX.git
synced 2025-07-01 18:17:27 -04:00
Merge pull request #440 from jim60105/main
chore(writer): Join words without spaces for ja, zh
This commit is contained in:
@ -118,6 +118,7 @@ def cli():
|
|||||||
f"{model_name} is an English-only model but receipted '{args['language']}'; using English instead."
|
f"{model_name} is an English-only model but receipted '{args['language']}'; using English instead."
|
||||||
)
|
)
|
||||||
args["language"] = "en"
|
args["language"] = "en"
|
||||||
|
align_language = args["language"] if args["language"] is not None else "en" # default to loading english if not specified
|
||||||
|
|
||||||
temperature = args.pop("temperature")
|
temperature = args.pop("temperature")
|
||||||
if (increment := args.pop("temperature_increment_on_fallback")) is not None:
|
if (increment := args.pop("temperature_increment_on_fallback")) is not None:
|
||||||
@ -174,7 +175,6 @@ def cli():
|
|||||||
if not no_align:
|
if not no_align:
|
||||||
tmp_results = results
|
tmp_results = results
|
||||||
results = []
|
results = []
|
||||||
align_language = args["language"] if args["language"] is not None else "en" # default to loading english if not specified
|
|
||||||
align_model, align_metadata = load_align_model(align_language, device, model_name=align_model)
|
align_model, align_metadata = load_align_model(align_language, device, model_name=align_model)
|
||||||
for result, audio_path in tmp_results:
|
for result, audio_path in tmp_results:
|
||||||
# >> Align
|
# >> Align
|
||||||
@ -213,6 +213,7 @@ def cli():
|
|||||||
results.append((result, input_audio_path))
|
results.append((result, input_audio_path))
|
||||||
# >> Write
|
# >> Write
|
||||||
for result, audio_path in results:
|
for result, audio_path in results:
|
||||||
|
result["language"] = align_language
|
||||||
writer(result, audio_path, writer_args)
|
writer(result, audio_path, writer_args)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -123,6 +123,7 @@ TO_LANGUAGE_CODE = {
|
|||||||
"castilian": "es",
|
"castilian": "es",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LANGUAGES_WITHOUT_SPACES = ["ja", "zh"]
|
||||||
|
|
||||||
system_encoding = sys.getdefaultencoding()
|
system_encoding = sys.getdefaultencoding()
|
||||||
|
|
||||||
@ -283,6 +284,9 @@ class SubtitlesWriter(ResultWriter):
|
|||||||
sstart, ssend, speaker = _[0]
|
sstart, ssend, speaker = _[0]
|
||||||
subtitle_start = self.format_timestamp(sstart)
|
subtitle_start = self.format_timestamp(sstart)
|
||||||
subtitle_end = self.format_timestamp(ssend)
|
subtitle_end = self.format_timestamp(ssend)
|
||||||
|
if result["language"] in LANGUAGES_WITHOUT_SPACES:
|
||||||
|
subtitle_text = "".join([word["word"] for word in subtitle])
|
||||||
|
else:
|
||||||
subtitle_text = " ".join([word["word"] for word in subtitle])
|
subtitle_text = " ".join([word["word"] for word in subtitle])
|
||||||
has_timing = any(["start" in word for word in subtitle])
|
has_timing = any(["start" in word for word in subtitle])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user