Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| from gtts import gTTS | |
| import pygame | |
| def text_to_speech(text): | |
| pygame.init() | |
| pygame.mixer.init() | |
| tts = gTTS(text=text, lang="ko") | |
| tts.save("output.mp3") | |
| pygame.mixer.music.load("output.mp3") | |
| pygame.mixer.music.play() | |
| while pygame.mixer.music.get_busy(): | |
| pygame.time.Clock().tick(10) | |
| iface = gr.Interface( | |
| fn=text_to_speech, | |
| inputs="text", | |
| outputs="audio", | |
| title="GTTS ๊ธฐ๋ฐ ํ๊ธ ์์ฑ ๋ณํ", | |
| description="ํ ์คํธ๋ฅผ ์์ฑ์ผ๋ก ๋ณํํฉ๋๋ค." | |
| ) | |
| iface.launch() | |
| import os | |
| import torch | |
| from transformers import pipeline | |
| from gtts import gTTS | |
| import pygame | |
| from huggingface_hub import HfApi, ModelRepository | |
| api = HfApi() | |
| repo_id = api.create_repo("codepilot/gtts-ko", exist_ok=True) | |
| repo = ModelRepository(repo_id, clone_from_local=True) | |
| torch.save({"model": "gtts-ko"}, os.path.join(repo.local_dir, "pytorch_model.bin")) | |
| with open(os.path.join(repo.local_dir, "requirements.txt"), "w") as f: | |
| f.write("gtts\npygame\ngradio\ntorch\ntransformers\nhuggingface_hub\nanyio") | |
| with open(os.path.join(repo.local_dir, "app.py"), "w") as f: | |
| f.write(""" | |
| import gradio as gr | |
| import os | |
| from gtts import gTTS | |
| import pygame | |
| def text_to_speech(text): | |
| pygame.init() | |
| pygame.mixer.init() | |
| tts = gTTS(text=text, lang="ko") | |
| tts.save("output.mp3") | |
| pygame.mixer.music.load("output.mp3") | |
| pygame.mixer.music.play() | |
| while pygame.mixer.music.get_busy(): | |
| pygame.time.Clock().tick(10) | |
| iface = gr.Interface( | |
| fn=text_to_speech, | |
| inputs="text", | |
| outputs="audio", | |
| title="GTTS ๊ธฐ๋ฐ ํ๊ธ ์์ฑ ๋ณํ", | |
| description="ํ ์คํธ๋ฅผ ์์ฑ์ผ๋ก ๋ณํํฉ๋๋ค." | |
| ) | |
| iface.launch() | |
| """) | |
| repo.push_to_hub() |