Spaces:
Running
Running
Update app.py
Browse files21 unmodified lines2223242526272849 unmodified lines7879808182838420 unmodified lines10510610710810911012 unmodified lines1231241251261271281293 unmodified lines13313413513613713813920 unmodified lines16016116216316416516686 unmodified lines25325425525625725825978 unmodified lines33833934034134234317 unmodified lines36136236336436536636736836937037137237321 unmodified linesdict_path = "custom_dict.json"AUTO_MERGE_WORDS = [["GSλ§μ΄μ΅", "μ§μμ€λ§μ΄μ΅"],["μ§μμ€ λ§μ΄μ΅", "μ§μμ€ λ§μ΄μ΅"],["1+1", "μνλ¬μ€μ"],["2+1", "ν¬νλ¬μ€μ"],["F/W", "μν λλΈμ "],["S/S", "μμ€ μμ€"],["VIP", "λΈμ΄μμ΄νΌ"],["ν μΈκ°", "νλ¦°κΉ"],["νΉκ°", "νΉκΉ"],["μ΅μ κ°", "μ΅μ κΉ"],["λ¨λ ꡬμ±", "λ¨λ κΎΈμ±"],["μλκΈ", "μλλ"],["μ±κ²°μ ", "μ±κ»Όμ "],["μΌμλΆ", "μΌμ¨λΆ"],["무μ΄μ", "무μ΄μ"],["λ§€μ§μλ°", "λ§€μ§λλ°"],["μλμ£Όλ¬Έ", "μλμ£Όλ¬Έ"],["μ¬μν", "μ¬μν"],["ν리ν°λ₯Ό", "ν리ν°λ₯Ό"],["λν μΌμ΄", "λν μ΄λ¦¬"],["μ€λ£¨μ£μ΄", "μ€λ£¨μμ"],["컀ν°μ€λ² ", "컀ν°μ€λ² "],["μΈλ₯΄μ¦λΈλμ½", "μΈλ₯΄μ¦λΈλμ½"],["ν¬λ¨Έν°λΈ", "ν¬λ¨Έν°λΈ"],["λΉνΈλ¦΄", "λΉνΈλ¦΄"],["λ λ―Έμ€λ₯΄λ£¨", "λ λ―Έμ€λ₯΄λ£¨"],["μλν΄λΌμ°μ€", "μλν΄λΌμ°μ€"],["νΈλ§κ³¨ν", "νΈλ§κ³¨ν"],["컬λΌλΉμ", "컬λΌλΉμ"],["μμ€κΉλ€μ€ν¬μΈ ", "μμ€κΉλ€μ€ν¬μΈ "],["μμ€μΉ΄λ€μ€ν¬μΈ ", "μμ€κΉλ€μ€ν¬μΈ "],["μμΈ", "μμΈ"],["μλνλ", "μλνλ"],["λΌμμν", "λΌμμν"],["λͺ¨λ₯΄κ°", "λͺ¨λ₯΄κ°"],["λ§μ€μ€νλμ€", "λ§μ°μ€νλμ€"],["λ°μΌλ¦¬λΈλ£¨", "λ°μΌλ¦¬λΈλ£¨"],["νΈλΌμ΄μν", "νΈλΌμ΄μν"],["μμ¨λΉ ν΄λ‘ν΄λ½", "μμ¨λΉ ν΄λ‘ν΄λ½"],["κΈ°ν ", "κΈ°ν "],["μ€λ‘ λ", "μ€λ‘ λ"],["SJμλ", "μμ€μ μ΄μλ"],["μ½μ΄ μ΄μΌν±", "μ½μ΄ μ΄μΌν±"],["λ₯΄λ€ν¬λ£¨", "λ₯΄λ€ν¬λ£¨"],["λν", "λν"],["1μ’ ", "μΌμ’ "],["2μ’ ", "μ΄μ’ "],["3μ’ ", "μΌμ’ "],["4μ’ ", "μ¬μ’ "],["5μ’ ", "μ€μ’ "],["10μ’ ", "μμ’ "],["4in1", "ν¬μΈμ"],["25FW", "μ΄μ€ μν λλΈμ "],["25 F/W", "μ΄μ€ μν λλΈμ "],["μ΄μ€ μνλ λΈμ ", "μ΄μ€ μν λλΈμ "],["26SS", "μ΄μλ΅μμ€μμ€"],["2026 SS", "μ΄μ²μ΄μλ΅ μμ€μμ€"],["SSμμ¦", "μμ€μμ€ μμ¦"],["μ μ ", "μΈλ₯"],["리λ²μλΈ", "리λ²μλΈ"],["맨ν¬λ§¨", "맨ν¬λ§¨"],["μν°ν¬μΈ ", "μν°ν¬μΈ "],["λ³Έλ©ν¬μΈ ", "λ³Έλ©ν¬μΈ "],["μ€μμμΌ", "μ€μμμΌ"],["νμ΄λΈλ¦¬λ", "νμ΄λΈλ¦¬λ"],["λ μ΄μ΄λ§", "λ μ΄μ΄λ§"],["λ μ΄μ΄λ", "λ μ΄μ΄λ"],["μμΉ΄λΌ", "μμΉ΄λΌ"],["μΈνμ€", "μΈνμ€"],["λλ€μ΄ν¨λ©", "λλ°μ΄ν¨λ©"],["λλ€μ΄μ€μ»€νΈ", "λλ°μ΄μ€μ»€νΈ"],["κ·Έλ μ΄μ§", "κ·Έλ μ΄μ§"],["νΈμ", "νΈμ"],["νκ°λ¨ΌνΈ", "νκ°λ¨ΌνΈ"],["νλ¬νΌ", "νλ¬νΌ"],["λ Έλ₯΄λ", "λ Έλ₯΄λ"],["μΈλΈλ λ", "μΈλΈλ λ"],["λΌμΏ€ λΈλ λ", "λΌμΏ€ λΈλ λ"],["μΈμ΄μ§κ·Έλ¦°", "μΈμ΄μ§κ·Έλ¦°"],["λͺ¨λΈμμΈ", "λͺ¨λΈμμΈ"],["ν¬λ‘μ", "ν¬λ‘μ °"],["λ μ΄μ€ ν¨μ§", "λ μ΄μ€ ν¨μ§"],["μμ΄μ컀", "μμ΄μ컀"],["νΈλ μ€νμΌλ¬", "νΈλ μ€νμΌλ¬"],["μμΌλ ", "μμΌλ "],["μμ΄ λΈλ μ΄μ ", "μμ΄ λΈλ μ΄μ "],["νΈλΈλ£¨", "νΈλΈλ£¨"],["μμ΄λ¦¬", "μμ΄λ¦¬"],["νν±", "νν±"],["μ¬λ¦¬λΈλ¦¬μ€", "μ¬λ¦¬λΈλ¦¬μ€"],["ν€ λ μ΄μ΄λ", "ν€ λ μ΄μ΄λ"],["μ¬ν°", "μ¬ν°"],["μν¬λΈλ", "μν¬λΈλ"],["μΈλ¨ΈλΈλΌμ΄", "μΈλ¨ΈλΈλΌμ΄"],["λΈλ£Ένν¬", "λΈλ£Ένν¬"],["λ―Έμ€νΈλΈλ£¨", "λ―Έμ€νΈλΈλ£¨"],["λ₯΄λ€λ² μ΄μ§", "λ₯΄λ€λ² μ΄μ§"],["μΈλ¨ΈμΉ΄ν€", "μΈλ¨ΈμΉ΄ν€"],["μΈνΌλν°λΈλ£¨", "μΈνΌλν°λΈλ£¨"],["λ₯΄λ€λΈλ", "λ₯΄λ€λΈλ"],["λΈλ£Ένμ΄νΈ", "λΈλ£Ένμ΄νΈ"],["μΈλ¨Έλ€μ΄λΉ", "μΈλ¨Έλ€μ΄λΉ"],["λΈλΌμΈνν¬", "λΈλΌμΈνν¬"],["μΈλ¨Έλ² μ΄μ§", "μΈλ¨Έλ² μ΄μ§"],["λ₯μμΈ", "λ₯μμΈ"],["100νλ‘", "λ°±νλ‘"],["100%", "λ°±νλ‘"],["86%", "νμμ‘νλ‘"],["14%", "μμ¬νλ‘"],["1,499,900μ", "λ°±μ¬μκ΅¬λ§ κ΅¬μ²κ΅¬λ°± μ"],["169,900μ", "μμ‘λ§ κ΅¬μ²κ΅¬λ°± μ"],["159,900μ", "μμ€λ§ ꡬμ²κ΅¬λ°± μ"],["149,000μ", "μμ¬λ§ κ΅¬μ² μ"],["12λ§ 9μ² 8λ°± μ", "μμ΄λ§ ꡬμ²νλ°± μ"],["10λ§ 9μ²μ", "μλ§ κ΅¬μ²μ"],["89,900μ", "νλ§ κ΅¬μ²κ΅¬λ°± μ"],["79,900μ", "μΉ λ§ κ΅¬μ²κ΅¬λ°± μ"],["79,900 μ", "μΉ λ§ κ΅¬μ²κ΅¬λ°± μ"],["6λ§ 9μ² 9λ°± μ", "μ‘λ§ κ΅¬μ²κ΅¬λ°± μ"],["69,900μ", "μ‘λ§ κ΅¬μ²κ΅¬λ°± μ"],["69,900 μ", "μ‘λ§ κ΅¬μ²κ΅¬λ°± μ"],["3λ§ 6μ²μλ", "μΌλ§ μ‘μ²μλ"]]def perform_auto_recovery_and_merge():if not os.path.exists(dict_path):49 unmodified linesreturn "".join(res)return textdef process_text(input_text, ai_mode, auto_break, font_size):if not input_text or not input_text.strip():return "", "", "μ λ ₯ κΈμ μ: 0μ"20 unmodified linesif tail: parts.append(apply_g2p(tail, ai_mode))final_text = "".join(parts)if auto_break:final_text = final_text.replace(". ", ".\n\n").replace("? ", "?\n\n")12 unmodified linesdef clear_all():return "", "", "", "μ λ ₯ κΈμ μ: 0μ"def add_and_update(word, pronun, current_input, ai_mode, auto_break, font_size):if not word or not pronun:return "β οΈ κΈ°μ‘΄ λ¨μ΄μ μνλ λ°μμ λͺ¨λ μ λ ₯νμΈμ.", gr.update(), gr.update(), gr.update()3 unmodified linesif len(word) == 1:error_msg = f"π« [λ±λ‘ μ€ν¨] '{word}'μ²λΌ 1κΈμλ§ λ±λ‘νλ©΄ μλ³Έμ΄ νΌμλ©λλ€! 2κΈμ μ΄μμΌλ‘ λ±λ‘ν΄μ£ΌμΈμ."if current_input and current_input.strip():final_text, html_output, char_count = process_text(current_input, ai_mode, auto_break, font_size)return error_msg, final_text, html_output, char_countreturn error_msg, "", "", "μ λ ₯ κΈμ μ: 0μ"20 unmodified linesstatus_msg = f"β μ μ₯ μ€ν¨: {e}"if current_input and current_input.strip():final_text, html_output, char_count = process_text(current_input, ai_mode, auto_break, font_size)return status_msg, final_text, html_output, char_countreturn status_msg, "", "", "μ λ ₯ κΈμ μ: 0μ"86 unmodified lines#prompter_output_div { height: 500px !important; max-height: 500px !important; overflow-y: auto !important; padding: 16px !important; line-height: 1.8 !important; box-sizing: border-box !important; background-color: #333 !important; color: #fff !important; border: 1px solid #ddd !important; border-radius: 8px !important; white-space: pre-wrap !important; word-break: break-word !important; text-align: left !important; margin-top: 0 !important; width: 100% !important; max-width: 100% !important; }"""# β μ¬λΌμ‘λ μ€ν¬λ‘€ λκΈ°ν μ½λκ° μλ²½νκ² λ³΅κ΅¬λ λΆλΆμ λλ€! βscript_js = """function() {function applyFontSize(size) {78 unmodified linesgr.Markdown("**βοΈ λ³ν λ° νλ©΄ μ€μ **")ai_mode = gr.Radio(choices=["λκΈ° (μλ μ¬μ λ§ μ μ©)", "μν λ§ (λ¨μ΄λ³ λκΈ° - κ³Όλν μ°μ λ°©μ§)", "λ§€μ΄ λ§ (λ¬Έμ₯ ν΅μ§Έλ‘ - μμ°μ€λ¬μ΄ μ°μ)"], value="λκΈ° (μλ μ¬μ λ§ μ μ©)", label="π€ AI λ°μ λ³ν κ°λ μ ν")auto_break = gr.Checkbox(label="π λ¬Έμ₯ λμμ μλμΌλ‘ μ€λ°κΏ νκΈ°", value=False)font_size = gr.Slider(minimum=16, maximum=40, value=22, step=2, label="π κ²°κ³Όμ°½ κΈμ ν¬κΈ° μ‘°μ ")char_count = gr.Textbox(label="κΈμ μ νμΈ", value="μ λ ₯ κΈμ μ: 0μ", interactive=False)with gr.Row():17 unmodified linesbtn_clear_dict_inputs = gr.Button("π§Ή λ¨μ΄ μ λ ₯μΉΈ λΉμ°κΈ°", variant="secondary")status = gr.Textbox(label="μ μ₯ μν κ²°κ³Όμ°½", interactive=False)btn_conv.click(fn=process_text, inputs=[input_text, ai_mode, auto_break, font_size], outputs=[output_text, output_html, char_count], api_name=False)btn_clr.click(fn=clear_all, outputs=[input_text, output_text, output_html, char_count], api_name=False)btn_copy.click(fn=None, inputs=[output_text], outputs=None, js="(text) => { if(text) { navigator.clipboard.writeText(text); alert('β λ³΅μ¬ μλ£!'); } }", api_name=False)font_size.change(fn=process_text, inputs=[input_text, ai_mode, auto_break, font_size], outputs=[output_text, output_html, char_count], api_name=False)ai_mode.change(fn=process_text, inputs=[input_text, ai_mode, auto_break, font_size], outputs=[output_text, output_html, char_count], api_name=False)auto_break.change(fn=process_text, inputs=[input_text, ai_mode, auto_break, font_size], outputs=[output_text, output_html, char_count], api_name=False)btn_add.click(fn=add_and_update, inputs=[nw, np, input_text, ai_mode, auto_break, font_size], outputs=[status, output_text, output_html, char_count], api_name=False)btn_clear_dict_inputs.click(fn=lambda: ("", ""), outputs=[nw, np], api_name=False)with gr.Tab("π₯ μλ λ°±μ /μ‘°ν/μμ (λλ λ±λ‘)"):21 unmodified lines2223242526272849 unmodified lines7879808182838420 unmodified lines10510610710810911011111211311411512 unmodified lines1281291301311321331343 unmodified lines13813914014114214314420 unmodified lines16516616716816917017186 unmodified lines25825926026126226378 unmodified lines34234334434534634734834917 unmodified lines36736836937037137237337437537637737837938038121 unmodified linesdict_path = "custom_dict.json"AUTO_MERGE_WORDS = [["GSλ§μ΄μ΅", "μ§μμ€λ§μ΄μ΅"],["GS λ§μ΄μ΅", "μ§μμ€λ§μ΄μ΅"],["GSμ΅", "μ§μμ€μ΅"],["GS μ΅", "μ§μμ€μ΅"],["26SS", "μ΄μμ‘ μμ€μμ€"],["26 SS", "μ΄μμ‘ μμ€μμ€"],["26S/S", "μ΄μμ‘ μμ€μμ€"],["26 S/S", "μ΄μμ‘ μμ€μμ€"],["55", "μ€μ€"],["55μ¬μ΄μ¦", "μ€μ€ μΈμ΄μ¦"],["55 μ¬μ΄μ¦", "μ€μ€ μΈμ΄μ¦"],["66", "μ΅μ‘"],["66μ¬μ΄μ¦", "μ΅μ‘ μΈμ΄μ¦"],["66 μ¬μ΄μ¦", "μ΅μ‘ μΈμ΄μ¦"],["77", "μΉ μΉ "],["77μ¬μ΄μ¦", "μΉ μΉ μΈμ΄μ¦"],["77 μ¬μ΄μ¦", "μΉ μΉ μΈμ΄μ¦"],["88", "νν"],["88μ¬μ΄μ¦", "νν μΈμ΄μ¦"],["88 μ¬μ΄μ¦", "νν μΈμ΄μ¦"],["100%", "λ°±νλ‘"],["100 %", "λ°±νλ‘"],["100νλ‘", "λ°±νλ‘"],["59,900μ", "μ€λ§ ꡬμ²κ΅¬λ°± μ"],["59,900 μ", "μ€λ§ ꡬμ²κ΅¬λ°± μ"],["59900μ", "μ€λ§ ꡬμ²κ΅¬λ°± μ"],["59900 μ", "μ€λ§ ꡬμ²κ΅¬λ°± μ"],["5λ§ 9μ² 9λ°± μ", "μ€λ§ ꡬμ²κ΅¬λ°± μ"],["3κ°μ", "μΌκ°μ"],["3 κ°μ", "μΌκ°μ"],["1λ§μλ", "λ§μλ"],["1λ§ μλ", "λ§μλ"],["1λ§ μ λ", "λ§μλ"],["1λ§μ λ", "λ§μλ"]]def perform_auto_recovery_and_merge():if not os.path.exists(dict_path):49 unmodified linesreturn "".join(res)return textdef process_text(input_text, ai_mode, auto_break, smart_pause, font_size):if not input_text or not input_text.strip():return "", "", "μ λ ₯ κΈμ μ: 0μ"20 unmodified linesif tail: parts.append(apply_g2p(tail, ai_mode))final_text = "".join(parts)# β 1. μ€λ§νΈ νΈν‘μ μΆκ° (μΌν λ€μ μκ°μ λμ΄μ½κΈ° κΈ°νΈ μ½μ )if smart_pause:final_text = re.sub(r',\s*', ', / ', final_text)# β 2. λ¬Έμ₯ λ μ€λ°κΏif auto_break:final_text = final_text.replace(". ", ".\n\n").replace("? ", "?\n\n")12 unmodified linesdef clear_all():return "", "", "", "μ λ ₯ κΈμ μ: 0μ"def add_and_update(word, pronun, current_input, ai_mode, auto_break, smart_pause, font_size):if not word or not pronun:return "β οΈ κΈ°μ‘΄ λ¨μ΄μ μνλ λ°μμ λͺ¨λ μ λ ₯νμΈμ.", gr.update(), gr.update(), gr.update()3 unmodified linesif len(word) == 1:error_msg = f"π« [λ±λ‘ μ€ν¨] '{word}'μ²λΌ 1κΈμλ§ λ±λ‘νλ©΄ μλ³Έμ΄ νΌμλ©λλ€! 2κΈμ μ΄μμΌλ‘ λ±λ‘ν΄μ£ΌμΈμ."if current_input and current_input.strip():final_text, html_output, char_count = process_text(current_input, ai_mode, auto_break, smart_pause, font_size)return error_msg, final_text, html_output, char_countreturn error_msg, "", "", "μ λ ₯ κΈμ μ: 0μ"20 unmodified linesstatus_msg = f"β μ μ₯ μ€ν¨: {e}"if current_input and current_input.strip():final_text, html_output, char_count = process_text(current_input, ai_mode, auto_break, smart_pause, font_size)return status_msg, final_text, html_output, char_countreturn status_msg, "", "", "μ λ ₯ κΈμ μ: 0μ"86 unmodified lines#prompter_output_div { height: 500px !important; max-height: 500px !important; overflow-y: auto !important; padding: 16px !important; line-height: 1.8 !important; box-sizing: border-box !important; background-color: #333 !important; color: #fff !important; border: 1px solid #ddd !important; border-radius: 8px !important; white-space: pre-wrap !important; word-break: break-word !important; text-align: left !important; margin-top: 0 !important; width: 100% !important; max-width: 100% !important; }"""script_js = """function() {function applyFontSize(size) {78 unmodified linesgr.Markdown("**βοΈ λ³ν λ° νλ©΄ μ€μ **")ai_mode = gr.Radio(choices=["λκΈ° (μλ μ¬μ λ§ μ μ©)", "μν λ§ (λ¨μ΄λ³ λκΈ° - κ³Όλν μ°μ λ°©μ§)", "λ§€μ΄ λ§ (λ¬Έμ₯ ν΅μ§Έλ‘ - μμ°μ€λ¬μ΄ μ°μ)"], value="λκΈ° (μλ μ¬μ λ§ μ μ©)", label="π€ AI λ°μ λ³ν κ°λ μ ν")auto_break = gr.Checkbox(label="π λ¬Έμ₯ λμμ μλμΌλ‘ μ€λ°κΏ νκΈ°", value=False)# β μλ‘ μΆκ°λ νΈν‘μ μ΅μ 체ν¬λ°μ€smart_pause = gr.Checkbox(label="β±οΈ μ€λ§νΈ ν둬νν° νΈν‘μ ( / ) μΆκ°νκΈ° (μΌν λ€)", value=False)font_size = gr.Slider(minimum=16, maximum=40, value=22, step=2, label="π κ²°κ³Όμ°½ κΈμ ν¬κΈ° μ‘°μ ")char_count = gr.Textbox(label="κΈμ μ νμΈ", value="μ λ ₯ κΈμ μ: 0μ", interactive=False)with gr.Row():17 unmodified linesbtn_clear_dict_inputs = gr.Button("π§Ή λ¨μ΄ μ λ ₯μΉΈ λΉμ°κΈ°", variant="secondary")status = gr.Textbox(label="μ μ₯ μν κ²°κ³Όμ°½", interactive=False)# β smart_pause λ³μκ° νλΌλ―Έν°λ‘ μΆκ°λ¨btn_conv.click(fn=process_text, inputs=[input_text, ai_mode, auto_break, smart_pause, font_size], outputs=[output_text, output_html, char_count], api_name=False)btn_clr.click(fn=clear_all, outputs=[input_text, output_text, output_html, char_count], api_name=False)btn_copy.click(fn=None, inputs=[output_text], outputs=None, js="(text) => { if(text) { navigator.clipboard.writeText(text); alert('β λ³΅μ¬ μλ£!'); } }", api_name=False)font_size.change(fn=process_text, inputs=[input_text, ai_mode, auto_break, smart_pause, font_size], outputs=[output_text, output_html, char_count], api_name=False)ai_mode.change(fn=process_text, inputs=[input_text, ai_mode, auto_break, smart_pause, font_size], outputs=[output_text, output_html, char_count], api_name=False)auto_break.change(fn=process_text, inputs=[input_text, ai_mode, auto_break, smart_pause, font_size], outputs=[output_text, output_html, char_count], api_name=False)smart_pause.change(fn=process_text, inputs=[input_text, ai_mode, auto_break, smart_pause, font_size], outputs=[output_text, output_html, char_count], api_name=False)btn_add.click(fn=add_and_update, inputs=[nw, np, input_text, ai_mode, auto_break, smart_pause, font_size], outputs=[status, output_text, output_html, char_count], api_name=False)btn_clear_dict_inputs.click(fn=lambda: ("", ""), outputs=[nw, np], api_name=False)with gr.Tab("π₯ μλ λ°±μ /μ‘°ν/μμ (λλ λ±λ‘)"):
app.py+19-11