Fix for empty text and audio generation

This commit is contained in:
ebolam
2022-12-06 08:12:43 -05:00
parent 1f62f154a5
commit dee494a301
2 changed files with 12 additions and 9 deletions

BIN
data/empty_audio.ogg Normal file

Binary file not shown.

View File

@@ -1886,15 +1886,18 @@ class KoboldStoryRegister(object):
speaker = 'en_5' speaker = 'en_5'
while not make_audio_queue.empty(): while not make_audio_queue.empty():
(text, filename) = make_audio_queue.get() (text, filename) = make_audio_queue.get()
audio = self.tts_model.apply_tts(text=text, if text == "":
speaker=speaker, shutil.move("data/empty_audio.ogg", filename)
sample_rate=sample_rate) else:
#audio_path=filename) audio = self.tts_model.apply_tts(text=text,
channels = 2 if (audio.ndim == 2 and audio.shape[1] == 2) else 1 speaker=speaker,
#y = np.int16(audio) sample_rate=sample_rate)
y = np.int16(audio * 2 ** 15) #audio_path=filename)
song = pydub.AudioSegment(y.tobytes(), frame_rate=sample_rate, sample_width=2, channels=channels) channels = 2 if (audio.ndim == 2 and audio.shape[1] == 2) else 1
song.export(filename, format="ogg", bitrate="16k") #y = np.int16(audio)
y = np.int16(audio * 2 ** 15)
song = pydub.AudioSegment(y.tobytes(), frame_rate=sample_rate, sample_width=2, channels=channels)
song.export(filename, format="ogg", bitrate="16k")
def gen_all_audio(self, overwrite=False): def gen_all_audio(self, overwrite=False):
if self.story_settings.gen_audio and self.koboldai_vars.experimental_features: if self.story_settings.gen_audio and self.koboldai_vars.experimental_features: