From 6fbf87567369c2d615efd15e4d2bd2c7d37eca34 Mon Sep 17 00:00:00 2001 From: rany Date: Sun, 11 Jul 2021 17:17:03 +0300 Subject: [PATCH] Actually fix --- setup.cfg | 2 +- src/edgeTTS/__init__.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 370092c..db7f26f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = edge-tts -version = 2.2.0 +version = 2.2.1 author = rany author_email = ranygh@riseup.net description = Microsoft Edge's TTS diff --git a/src/edgeTTS/__init__.py b/src/edgeTTS/__init__.py index c3f6b16..193e3bd 100755 --- a/src/edgeTTS/__init__.py +++ b/src/edgeTTS/__init__.py @@ -76,6 +76,7 @@ async def list_voices(): class SubMaker: def __init__(self, overlapping=5): self.subsAndOffset = [] + self.brokenOffset = [] self.overlapping = (overlapping * (10**7)) def formatter(self, offset1, offset2, subdata): @@ -85,8 +86,9 @@ class SubMaker: def createSub(self, timestamp, text): if len(self.subsAndOffset) >= 2: - if self.subsAndOffset[-2] >= timestamp: - timestamp = timestamp + self.subsAndOffset[-2] + if self.subsAndOffset[-2] >= timestamp + sum(self.brokenOffset): + self.brokenOffset.append(self.subsAndOffset[-2]) + timestamp = timestamp + sum(self.brokenOffset) self.subsAndOffset.append(timestamp) self.subsAndOffset.append(text)