Compare commits
No commits in common. "6a91980030033b11612b43460dd1305d1e0c33a0" and "68010e22a96da86d2e338a32174b0e76ed30a1b0" have entirely different histories.
6a91980030
...
68010e22a9
2 changed files with 5 additions and 13 deletions
|
@ -36,11 +36,7 @@ class Clip:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def empty(cls, channels, samplerate, length=0):
|
def empty(cls, channels, samplerate, length=0):
|
||||||
samples = int(samplerate * length)
|
blank = np.zeros((channels, length), dtype='float32')
|
||||||
if channels > 1:
|
|
||||||
blank = np.zeros((channels, samples), dtype='float32')
|
|
||||||
else:
|
|
||||||
blank = np.zeros((samples,), dtype='float32')
|
|
||||||
return cls(blank, samplerate)
|
return cls(blank, samplerate)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
|
@ -91,7 +87,7 @@ class Clip:
|
||||||
|
|
||||||
def trim(self, aggressive=False):
|
def trim(self, aggressive=False):
|
||||||
"""Remove leading and trailing silence"""
|
"""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
|
return self
|
||||||
|
|
||||||
def stretch(self, speed):
|
def stretch(self, speed):
|
||||||
|
@ -125,7 +121,6 @@ class Clip:
|
||||||
self.samples, fix=False, scale=False,
|
self.samples, fix=False, scale=False,
|
||||||
orig_sr=self.samplerate * speed, target_sr=self.samplerate,
|
orig_sr=self.samplerate * speed, target_sr=self.samplerate,
|
||||||
)
|
)
|
||||||
return self
|
|
||||||
|
|
||||||
def _opcheck(self, other):
|
def _opcheck(self, other):
|
||||||
if not isinstance(other, Clip):
|
if not isinstance(other, Clip):
|
||||||
|
|
|
@ -23,11 +23,8 @@ class TextToSpeechPlugin(PluginBase):
|
||||||
conf_overrides = {k[2:]: v for k, v in kwargs.items() if k.startswith('o_')}
|
conf_overrides = {k[2:]: v for k, v in kwargs.items() if k.startswith('o_')}
|
||||||
|
|
||||||
self.cache_dir = os.path.join(CACHE_DIR, 'tts')
|
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 = {}
|
self.cache = {}
|
||||||
|
os.makedirs(os.path.dirname(self.cache_dir), exist_ok=True)
|
||||||
|
|
||||||
self.cuda = cuda
|
self.cuda = cuda
|
||||||
|
|
||||||
|
@ -63,7 +60,7 @@ class TextToSpeechPlugin(PluginBase):
|
||||||
for task in self.tasks:
|
for task in self.tasks:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
self.output.close()
|
self.output.close()
|
||||||
shutil.rmtree(self.output_dir)
|
shutil.rmtree(self.cache_dir)
|
||||||
|
|
||||||
async def text_to_clip(self, text):
|
async def text_to_clip(self, text):
|
||||||
# Force punctuation (keeps the models from acting unpredictably)
|
# Force punctuation (keeps the models from acting unpredictably)
|
||||||
|
@ -76,7 +73,7 @@ class TextToSpeechPlugin(PluginBase):
|
||||||
return Clip.from_file(cached)
|
return Clip.from_file(cached)
|
||||||
else:
|
else:
|
||||||
self.logger.info(f'Generating TTS "{text}"...')
|
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:
|
if self.speaker_wav:
|
||||||
fn = lambda _text: self.synthesizer.tts(_text, None, 'en', self.speaker_wav)
|
fn = lambda _text: self.synthesizer.tts(_text, None, 'en', self.speaker_wav)
|
||||||
|
|
Loading…
Add table
Reference in a new issue