Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from gtts import gTTS
|
| 4 |
+
import pygame
|
| 5 |
+
|
| 6 |
+
def text_to_speech(text):
|
| 7 |
+
tts = gTTS(text=text, lang="ko")
|
| 8 |
+
tts.save("output.mp3")
|
| 9 |
+
pygame.init()
|
| 10 |
+
pygame.mixer.music.load("output.mp3")
|
| 11 |
+
pygame.mixer.music.play()
|
| 12 |
+
while pygame.mixer.music.get_busy():
|
| 13 |
+
pygame.time.Clock().tick(10)
|
| 14 |
+
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=text_to_speech,
|
| 17 |
+
inputs="text",
|
| 18 |
+
outputs="audio",
|
| 19 |
+
title="GTTS 기반 한글 음성 변환",
|
| 20 |
+
description="텍스트를 음성으로 변환합니다."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
iface.launch()
|