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'
while not make_audio_queue.empty():
(text, filename) = make_audio_queue.get()
audio = self.tts_model.apply_tts(text=text,
speaker=speaker,
sample_rate=sample_rate)
#audio_path=filename)
channels = 2 if (audio.ndim == 2 and audio.shape[1] == 2) else 1
#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")
if text == "":
shutil.move("data/empty_audio.ogg", filename)
else:
audio = self.tts_model.apply_tts(text=text,
speaker=speaker,
sample_rate=sample_rate)
#audio_path=filename)
channels = 2 if (audio.ndim == 2 and audio.shape[1] == 2) else 1
#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):
if self.story_settings.gen_audio and self.koboldai_vars.experimental_features: