ai-building-blocks / text_to_speech.py
LiKenun's picture
Add text-to-speech (TTS) sample
caf2559
raw
history blame
328 Bytes
import gc
from transformers import pipeline
from utils import spaces_gpu
@spaces_gpu
def text_to_speech(text: str) -> tuple[int, bytes]:
narrator = pipeline("text-to-speech", "kakao-enterprise/vits-ljs")
del narrator
gc.collect()
result = narrator(text)
return (result["sampling_rate"], result["audio"][0])