Spaces:
Sleeping
Sleeping
File size: 1,737 Bytes
3206546 6f55b68 3206546 6f55b68 3206546 6f55b68 3206546 6f55b68 3206546 6f55b68 3206546 6f55b68 3adb62b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
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() |