import gradio as gr | |
from gtts import gTTS | |
import os | |
# TTS ๋ณํ ํจ์ | |
def text_to_speech_korean(text): | |
# gTTS๋ฅผ ์ฌ์ฉํ์ฌ ํ ์คํธ๋ฅผ ํ๊ตญ์ด๋ก ๋ณํ | |
tts = gTTS(text, lang='ko') | |
# ์ถ๋ ฅํ ์ค๋์ค ํ์ผ ์ด๋ฆ ์ค์ | |
output_path = "output.mp3" | |
tts.save(output_path) | |
return output_path | |
# Gradio ์ธํฐํ์ด์ค ์ค์ | |
iface = gr.Interface( | |
fn=text_to_speech_korean, | |
inputs=gr.Textbox(label="ํ๊ตญ์ด ํ ์คํธ ์ ๋ ฅ"), | |
outputs=gr.Audio(type="filepath", label="TTS ์ถ๋ ฅ"), | |
title="ํ๊ตญ์ด TTS", | |
description="ํ๊ตญ์ด ํ ์คํธ๋ฅผ ์ ๋ ฅํ๋ฉด TTS๋ก ์์ฑ ์ถ๋ ฅํฉ๋๋ค." | |
) | |
# ์ธํฐํ์ด์ค ์คํ | |
iface.launch() |