bgtts / app.py
englissi's picture
Update app.py
740beea verified
raw
history blame
796 Bytes
import gradio as gr
import torch
from transformers import pipeline
# Hugging Face TTS λͺ¨λΈ λ‘œλ“œ (λΆˆκ°€λ¦¬μ•„μ–΄ λͺ¨λΈλ‘œ λ³€κ²½ ν•„μš”)
tts = pipeline(task="text-to-speech", model="facebook/mms-tts-bul", device=0 if torch.cuda.is_available() else -1)
# TTS λ³€ν™˜ ν•¨μˆ˜
def tts_generate(text):
audio = tts(text, return_tensors=True)
return (audio['speech'].numpy(), 22050) # λ°˜ν™˜ν•  μƒ˜ν”Œλ§ 속도와 μ˜€λ””μ˜€ 데이터
# Gradio μΈν„°νŽ˜μ΄μŠ€ 생성
iface = gr.Interface(fn=tts_generate,
inputs="text",
outputs="audio",
title="Bulgarian TTS Generator",
description="Enter text to generate speech in Bulgarian.")
# μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰
if __name__ == "__main__":
iface.launch()