Spaces:
Running
Running
File size: 1,577 Bytes
eefe9ae 2ec67ac 508f2be eefe9ae 508f2be ebb2d0b 508f2be 564910c 508f2be eefe9ae 386e0da 8f8db0f 386e0da 508f2be 8f8db0f 508f2be 8f8db0f eefe9ae 8f8db0f eefe9ae 564910c 386e0da |
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 |
import gradio as gr
from gtts import gTTS
from pydub import AudioSegment
from io import BytesIO
def bulgarian_tts(bulgarian_text):
# gTTS를 이용해 불가리아어 텍스트를 음성으로 변환
tts = gTTS(text=bulgarian_text, lang="bg")
# 메모리 버퍼에 mp3로 저장 후, pydub 오디오 세그먼트로 로딩
audio_buffer = BytesIO()
tts.write_to_fp(audio_buffer)
audio_buffer.seek(0)
tts_audio = AudioSegment.from_file(audio_buffer, format="mp3")
# mp3 파일로 내보내기
output_file = "bulgarian_output.mp3"
tts_audio.export(output_file, format="mp3")
return output_file
with gr.Blocks(css="""
.gradio-container { font-family: 'Arial', sans-serif; }
.title { text-align: center; font-size: 24px; font-weight: bold; }
.textbox { border-radius: 8px; padding: 10px; }
.button { background-color: #4CAF50; color: white; border-radius: 8px; padding: 10px 15px; }
.button:hover { background-color: #45a049; }
""") as demo:
gr.Markdown("<div class='title'>🇧🇬 Bulgarian Text-to-Speech (TTS)</div>")
with gr.Row():
bulgarian_input = gr.Textbox(label="Enter Bulgarian Text:", placeholder="Здравейте", elem_classes=["textbox"])
with gr.Row():
generate_button = gr.Button("🎤 Generate Speech", elem_classes=["button"])
output_audio = gr.Audio(label="Generated Speech", type="filepath")
generate_button.click(bulgarian_tts, inputs=bulgarian_input, outputs=output_audio)
if __name__ == "__main__":
demo.launch() |