Add back words-in-cue support (#342)

Closes https://github.com/rany2/edge-tts/issues/335
Closes https://github.com/rany2/edge-tts/issues/336

Signed-off-by: rany <rany2@riseup.net>
This commit is contained in:
Rany
2024-12-07 22:34:50 +02:00
committed by GitHub
parent e1add45640
commit 3942edeb13
3 changed files with 42 additions and 0 deletions

View File

@@ -75,6 +75,9 @@ async def _run_tts(args: UtilArgs) -> None:
elif chunk["type"] == "WordBoundary":
submaker.feed(chunk)
if args.words_in_cue > 0:
submaker.merge_cues(args.words_in_cue)
if sub_file is not None:
sub_file.write(submaker.get_srt())
finally:
@@ -107,6 +110,12 @@ async def amain() -> None:
parser.add_argument("--rate", help="set TTS rate. Default +0%%.", default="+0%")
parser.add_argument("--volume", help="set TTS volume. Default +0%%.", default="+0%")
parser.add_argument("--pitch", help="set TTS pitch. Default +0Hz.", default="+0Hz")
parser.add_argument(
"--words-in-cue",
help="number of words in a subtitle cue. Default: 10.",
default=10,
type=int,
)
parser.add_argument(
"--write-media", help="send media output to file instead of stdout"
)