ProPerNounpYK commited on
Commit
3206546
·
verified ·
1 Parent(s): 0b8d382

Update app.py

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