Compare commits

..

No commits in common. "6a91980030033b11612b43460dd1305d1e0c33a0" and "68010e22a96da86d2e338a32174b0e76ed30a1b0" have entirely different histories.

2 changed files with 5 additions and 13 deletions

View file

@ -36,11 +36,7 @@ class Clip:
@classmethod
def empty(cls, channels, samplerate, length=0):
samples = int(samplerate * length)
if channels > 1:
blank = np.zeros((channels, samples), dtype='float32')
else:
blank = np.zeros((samples,), dtype='float32')
blank = np.zeros((channels, length), dtype='float32')
return cls(blank, samplerate)
def copy(self):
@ -91,7 +87,7 @@ class Clip:
def trim(self, aggressive=False):
"""Remove leading and trailing silence"""
self.samples, _ = librosa.effects.trim(self.samples, top_db=10 if aggressive else 30)
self.samples, _ = librosa.effects.trim(self.samples, top_db=10 if aggressive else 20)
return self
def stretch(self, speed):
@ -125,7 +121,6 @@ class Clip:
self.samples, fix=False, scale=False,
orig_sr=self.samplerate * speed, target_sr=self.samplerate,
)
return self
def _opcheck(self, other):
if not isinstance(other, Clip):

View file

@ -23,11 +23,8 @@ class TextToSpeechPlugin(PluginBase):
conf_overrides = {k[2:]: v for k, v in kwargs.items() if k.startswith('o_')}
self.cache_dir = os.path.join(CACHE_DIR, 'tts')
os.makedirs(os.path.dirname(self.cache_dir), exist_ok=True)
self.output_dir = os.path.join(self.cache_dir, 'outputs')
os.makedirs(self.output_dir, exist_ok=True)
self.cache = {}
os.makedirs(os.path.dirname(self.cache_dir), exist_ok=True)
self.cuda = cuda
@ -63,7 +60,7 @@ class TextToSpeechPlugin(PluginBase):
for task in self.tasks:
task.cancel()
self.output.close()
shutil.rmtree(self.output_dir)
shutil.rmtree(self.cache_dir)
async def text_to_clip(self, text):
# Force punctuation (keeps the models from acting unpredictably)
@ -76,7 +73,7 @@ class TextToSpeechPlugin(PluginBase):
return Clip.from_file(cached)
else:
self.logger.info(f'Generating TTS "{text}"...')
filename = os.path.join(self.output_dir, f'{uuid.uuid1()}.wav')
filename = os.path.join(self.cache_dir, f'{uuid.uuid1()}.wav')
if self.speaker_wav:
fn = lambda _text: self.synthesizer.tts(_text, None, 'en', self.speaker_wav)