abersbail's picture
Deploy tiny code-only TTS Space
0a88ee7 verified
raw
history blame contribute delete
735 Bytes
from .synth import TinyTTSSynthesizer
class LocalTTSService:
def __init__(self):
self.engine = TinyTTSSynthesizer()
def describe(self) -> str:
return "Local TTS engine ready. No API key and no external model."
def synthesize(
self,
text: str,
voice: str,
speed: float,
pitch_shift: float,
):
sample_rate, audio, normalized = self.engine.synthesize(
text=text,
voice=voice,
speed=float(speed),
pitch_shift=float(pitch_shift),
)
status = f"Generated local speech with voice={voice}, speed={speed:.2f}, pitch_shift={pitch_shift:.2f}"
return (sample_rate, audio), status, normalized