Spaces:
Sleeping
Sleeping
File size: 1,257 Bytes
eefe9ae 2ec67ac 508f2be eefe9ae 508f2be ebb2d0b 508f2be 564910c 508f2be eefe9ae 508f2be eefe9ae 508f2be eefe9ae 564910c |
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 |
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() as demo:
gr.Markdown("## Bulgarian Text-to-Speech (TTS)")
# 단일 불가리아어 입력만 받도록 구성
bulgarian_input = gr.Textbox(label="Enter Bulgarian Text:", placeholder="Здравейте")
output_audio = gr.Audio(label="Generated Speech", type="filepath")
generate_button = gr.Button("Generate Speech")
# 불가리아어 텍스트만 받아 TTS 오디오 파일 생성
generate_button.click(
bulgarian_tts,
inputs=bulgarian_input,
outputs=output_audio
)
if __name__ == "__main__":
demo.launch()
|