| import gradio as gr |
| from pocket_tts import TTSModel |
| import pocket_tts |
| import numpy as np |
|
|
| |
| import pocket_tts.data |
|
|
| print("โณ ๋ชจ๋ธ ๋ก๋ฉ ์ค...") |
| model = TTSModel.load_model() |
| print("โ
๋ชจ๋ธ ๋ก๋ ์๋ฃ.") |
|
|
| |
| |
| |
| print("\n" + "="*40) |
| print("๐ฆ [DEBUG] 'pocket_tts.data' ์ฐฝ๊ณ ๊ฐ๋ฐฉ") |
| |
| data_contents = dir(pocket_tts.data) |
| print(f"์ฐฝ๊ณ ๋ด์ฉ๋ฌผ: {data_contents}") |
|
|
| |
| found_voices = None |
| for item_name in data_contents: |
| if item_name in ['speakers', 'voices', 'catalog', 'predefined_voices']: |
| print(f"โ
์ ๋ ฅํ ์ฉ์์ ๋ฐ๊ฒฌ: pocket_tts.data.{item_name}") |
| found_voices = getattr(pocket_tts.data, item_name) |
| break |
|
|
| print("="*40 + "\n") |
|
|
| def generate_speech(text): |
| if not text: |
| return (24000, np.zeros(24000)) |
|
|
| |
| voice_state = None |
| |
| |
| if found_voices and isinstance(found_voices, dict) and 'alba' in found_voices: |
| print("๐ ์ฑ๊ณต! ์ฐฝ๊ณ ๋ชฉ๋ก์์ 'alba'๋ฅผ ์ฐพ์์ต๋๋ค.") |
| voice_state = found_voices['alba'] |
| |
| |
| |
| if voice_state is None: |
| print("โ ๏ธ ์ฐฝ๊ณ ์์ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ง ๋ชปํด, ๊ธฐ๋ณธ ์ด๋ฆํ('alba')๋ฅผ ์ฌ์ฉํฉ๋๋ค.") |
| |
| voice_state = 'alba' |
|
|
| try: |
| |
| print(f"๐ฃ๏ธ ์์ฑ ์์ฑ ์๋ (๋ฐ์ดํฐ ํ์
: {type(voice_state)})") |
| audio = model.generate_audio(voice_state, text) |
| return (model.sample_rate, audio.numpy()) |
| |
| except Exception as e: |
| print(f"โ ์์ฑ ์คํจ: {e}") |
| return (24000, np.zeros(24000)) |
|
|
| |
| with gr.Blocks(title="๐ issamTTS (Data Warehouse)") as demo: |
| gr.Markdown("## ๐ฆ ์ฐฝ๊ณ (Data Module) ์์ ๋ชจ๋") |
| gr.Markdown("Logs ํญ์์ **'์ฐฝ๊ณ ๋ด์ฉ๋ฌผ'** ๋ฆฌ์คํธ๋ฅผ ํ์ธํด ์ฃผ์ธ์. ๊ทธ ์์ ์ ๋ต์ด ์์ต๋๋ค.") |
| |
| input_text = gr.Textbox(label="ํ
์คํธ", value="๋ฐ์ฑํ ์ด์ฌ๋, ์ฐฝ๊ณ ๋ฌธ์ ์ด์์ต๋๋ค. ์์ ๋ฌด์์ด ์์ต๋๊น?") |
| btn = gr.Button("์์ ๋ฐ ์์ฑ (Search & Generate)") |
| output_audio = gr.Audio() |
| |
| btn.click(fn=generate_speech, inputs=[input_text], outputs=[output_audio]) |
|
|
| if __name__ == "__main__": |
| demo.launch() |