ProPerNounpYK commited on
Commit
3adb62b
ยท
verified ยท
1 Parent(s): c0f0a53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -1
app.py CHANGED
@@ -21,4 +21,50 @@ iface = gr.Interface(
21
  description="ํ…์ŠคํŠธ๋ฅผ ์Œ์„ฑ์œผ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค."
22
  )
23
 
24
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  description="ํ…์ŠคํŠธ๋ฅผ ์Œ์„ฑ์œผ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค."
22
  )
23
 
24
+ iface.launch()
25
+
26
+ import os
27
+ import torch
28
+ from transformers import pipeline
29
+ from gtts import gTTS
30
+ import pygame
31
+ from huggingface_hub import HfApi, ModelRepository
32
+
33
+ api = HfApi()
34
+ repo_id = api.create_repo("codepilot/gtts-ko", exist_ok=True)
35
+ repo = ModelRepository(repo_id, clone_from_local=True)
36
+
37
+ torch.save({"model": "gtts-ko"}, os.path.join(repo.local_dir, "pytorch_model.bin"))
38
+
39
+ with open(os.path.join(repo.local_dir, "requirements.txt"), "w") as f:
40
+ f.write("gtts\npygame\ngradio\ntorch\ntransformers\nhuggingface_hub\nanyio")
41
+
42
+ with open(os.path.join(repo.local_dir, "app.py"), "w") as f:
43
+ f.write("""
44
+ import gradio as gr
45
+ import os
46
+ from gtts import gTTS
47
+ import pygame
48
+
49
+ def text_to_speech(text):
50
+ pygame.init()
51
+ pygame.mixer.init()
52
+ tts = gTTS(text=text, lang="ko")
53
+ tts.save("output.mp3")
54
+ pygame.mixer.music.load("output.mp3")
55
+ pygame.mixer.music.play()
56
+ while pygame.mixer.music.get_busy():
57
+ pygame.time.Clock().tick(10)
58
+
59
+ iface = gr.Interface(
60
+ fn=text_to_speech,
61
+ inputs="text",
62
+ outputs="audio",
63
+ title="GTTS ๊ธฐ๋ฐ˜ ํ•œ๊ธ€ ์Œ์„ฑ ๋ณ€ํ™˜",
64
+ description="ํ…์ŠคํŠธ๋ฅผ ์Œ์„ฑ์œผ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค."
65
+ )
66
+
67
+ iface.launch()
68
+ """)
69
+
70
+ repo.push_to_hub()