feat: show fun preparation texts (while generating audio)

This commit is contained in:
Ayo Ayco 2025-09-04 21:40:39 +02:00
parent 6a0105ff1c
commit 79d5352329

27
tts.py
View file

@ -2,6 +2,7 @@ import os
from time import sleep, time
import warnings
import importlib
import random
import torch
import argparse
@ -19,6 +20,20 @@ voices = {
'brit': 'bf_emma'
}
prep_texts = [
"Check mic, 1-2-3...",
"*Tap* *tap* ... Is this thing on?",
"Ready, set... *Ahem!*",
"Mic's on, lights are set, I'm ready to roll.",
"All set? Let's make it a good one.",
"Ready, set, go—now that's the real countdown.",
"Checking the mic, one, two, three.",
"Lights, mic, action—now let's do this.",
"Hold tight—this is about to get interesting.",
"If the mic works, we're good to go.",
"All systems green—let's make this a good one."
]
def parse_args():
parser = argparse.ArgumentParser(description="Simple TTS", allow_abbrev=False)
parser.add_argument(
@ -83,7 +98,7 @@ def parse_args():
def generate_audio(generator, name, voice):
output_files = []
with yaspin():
for i, (gs, ps, audio) in enumerate(generator):
output_file_name=f'outputs/{name}/{name}-{voice}-{i}.wav'
os.makedirs(os.path.dirname(output_file_name), exist_ok=True)
@ -108,7 +123,16 @@ def play_audio(output_files):
colour='yellow'):
sleep(duration / 100)
def main():
# Get a randome "preparing" text
spinner_text = random.choice(prep_texts)
# Generate audio
with yaspin() as spinner:
spinner.text = spinner_text
args=parse_args()
if not args.verbose:
@ -172,6 +196,7 @@ def main():
print(f"[TTS] {len(output_files)} chunks generated in {generation_time:.2f} seconds")
print(f"[TTS] Output files are in: {directory}/*")
# Play audio
if args.skip_play:
print(f"[TTS] Audio player disabled: {directory}/*")
else: