Spaces:
Running
Running
Update app.py
Browse files33 unmodified lines3435363737383940414342434410 unmodified lines5556576058596044 unmodified lines10510610711110810911011111611211311415 unmodified lines13013113213313413513613713813813914014114214214314414510 unmodified lines15615715815915916016116220 unmodified lines18318418518618618718818933 unmodified lines data = json.load(f) for item in data.get("items",[]): if len(item) == 2: # 무쑰건 μμ 곡백μ μ κ±°νμ¬ λ‘λ© flat_dict[item[0].strip()] = item[1].strip() except: pass return flat_dict
# λ³ν ν΅μ¬ λ‘μ§ (μλ³Έμ 보νΈνλ©° λ±λ‘λ λ¨μ΄λ§ μ νν μΉν)def process_text(input_text): if not input_text or not input_text.strip(): return "", "", "μ
λ ₯ κΈμ μ: 0μ"10 unmodified lines pass else: sorted_keys = sorted(flat_dict.keys(), key=len, reverse=True) # λμ΄μ°κΈ°κ° μ¬λ¬ κ° λ€μ΄κ° κ²½μ°λ λ°©μ΄ pattern = re.compile("|".join(map(re.escape, sorted_keys))) parts =[]44 unmodified linesdef clear_all(): return "", "", "", "μ
λ ₯ κΈμ μ: 0μ"
# [ν΅μ¬] λ¨μ΄ μΆκ°μ λμμ ν
μ€νΈλ₯Ό μ¦μ μ¬λ³νdef add_and_update(word, pronun, current_input): if not word or not pronun: return "β οΈ κΈ°μ‘΄ λ¨μ΄μ μνλ λ°μμ λͺ¨λ μ
λ ₯νμΈμ.", gr.update(), gr.update(), gr.update() # μ€μλ‘ λ€μ΄κ° 곡백 μλ²½ μ κ±° word = word.strip() pronun = pronun.strip() 15 unmodified lines try: with open(dict_path, "w", encoding="utf-8") as f: json.dump(j_struct, f, ensure_ascii=False, indent=2) # β
μλ‘ μΆκ°λ λΆμΌμΉ κ²½κ³ λ‘μ§ β
if current_input and word not in current_input: status_msg = f"β οΈ μ¬μ μ μ₯ μλ£! νμ§λ§ μλ³Έ ν
μ€νΈμ '{word}'(μ΄)κ° μμ΄ νλ©΄μ λ³νκ° μμ΅λλ€. (1λ² μ°½μμ κ·Έλλ‘ λ³΅μ¬ν΄μ€μΈμ!)" else: status_msg = f"β
'{word}' -> '{pronun}' μ μ₯ λ° μ¦μ μ¬λ³ν μ μ© μλ£!" status_msg = f"β
'{word}' -> '{pronun}' μ μ₯ λ° μ¦μ μ¬λ³ν μ μ© μλ£!" except Exception as e: status_msg = f"β μ μ₯ μ€ν¨: {e}"
# μ¦μ νλ©΄ κ°±μ if current_input and current_input.strip(): final_text, html_output, char_count = process_text(current_input) return status_msg, final_text, html_output, char_count10 unmodified lines return "β οΈ νμΌμ΄ μμ΅λλ€."
with gr.Blocks(theme="default") as iface: gr.Markdown("## ποΈ λλ§μ TTS μ μ²λ¦¬ λ³νκΈ° (곡백/μ€λ₯ μλ²½ 보μ ν)") gr.Markdown("## ποΈ λλ§μ TTS μ μ²λ¦¬ λ³νκΈ° (μ€λ§νΈ λΆμΌμΉ κ°μ§ν)") with gr.Tabs(): with gr.Tab("ποΈ λ©μΈ νλ©΄"):20 unmodified lines gr.Markdown("---") with gr.Row(): nw = gr.Textbox(label="κΈ°μ‘΄ λ¨μ΄ λλ λ¬Έμ₯ (μλ³Έμ μλ κΈμ)") nw = gr.Textbox(label="κΈ°μ‘΄ λ¨μ΄ λλ λ¬Έμ₯ (β
λ°λμ 1λ² μ°½μμ 볡μ¬ν΄μ€μΈμβ
)") np = gr.Textbox(label="μνλ λ°μ") btn_add = gr.Button("πΎ μ¬μ μ μΆκ°νκ³ μ¦μ λλ³Έ λ³ννκΈ°", variant="primary") app.py+9-9