Spaces:
Running
Running
Update app.py
Browse files4 unmodified lines567891011121314151617188910111213141516171819202122236 unmodified lines30313231323334353637383933343536373846394041424351444546476 unmodified lines5455566457585960616667686970717273747576776263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157821581591601613 unmodified lines1651661679293168951691701711722 unmodified lines1751761771041781791805 unmodified lines1861871881161891901911921931941231241251261951961975 unmodified lines2032042051382062072081422092102111451462122131482142152162176 unmodified lines2242252261612272282291641651662301681692312322332342358 unmodified lines2442452461841851861872472482492502511892522532542558 unmodified lines2642652662042672682698 unmodified lines2782792802192812822839 unmodified lines2932942952352362372382392402962972982993006 unmodified lines30730830925325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842931043143231131231314 unmodified lines32832933045345445545645745845946046146246346446546646746846947047147247333133233347633433533633733810 unmodified lines3493503514933523533543552 unmodified lines35835936050236136236336436516 unmodified lines3823833845255265275285295303853863873883893903913923933943953963973983994004014025335344034044054064074084094104114125365375384134144154164174184191 unmodified line42142242354654742454942542655142742842943017 unmodified lines4484494505754514524534549 unmodified lines46446546659146746846947072 unmodified lines54354454554654754867254955055155255355455555655755855956056136 unmodified lines59859960071871972072172272372472572672772872973073160160260373273360460560619 unmodified lines6266276287596296306316326337627637647657667677686346356366377736386396406417757766426436442 unmodified lines6476486497857866506516527896536547916556566576586596606617986626636646651 unmodified line6676686698068078086706716726736748106756766776786798156806816828196836846856868246876886892 unmodified lines6926936948336956966974 unmodified linesimport reimport html
# =====================================================================# VoiceScript-AI v147 ์
๊ทธ๋ ์ด๋# - P0: ์ฌ์ ์๊ตฌ ์ ์ฅ (HF Dataset ์๋ ์ปค๋ฐ) + AUTO_MERGE ๋นํ๊ดดํ# - P1: ๋งค์นญ ์์ง ๊ต์ฒด (2๋จ๊ณ: ํ๊ธฐ ์ ๊ทํ -> ๋ฐ์ ์นํ, ๊ณต๋ฐฑ ๋ฌด์ ๋งค์นญ)# - G2P ์๋ ์ ํ: g2pk -> g2pk2 -> g2pkk# - Kiwi: "์ค๊ฐ ๋ง 2.0" ๋ชจ๋(ํ์ฌ ๊ธฐ๋ฐ ๋ณดํธ) + ํธํก๊ตฌ ๋ฆฌ์คํ์ด์ฑ(์ต์
)# - TTS ๋ฏธ๋ฆฌ๋ฃ๊ธฐ: ๐ ๋ธ๋ผ์ฐ์ ๋ด์ฅ ์์ฑ + ๐ ๋ฌด๋ฃ edge-tts/gTTS (ํคยท๊ฒฐ์ ์์)# * ์๋ฌธ์ ์ ๋ ์์ ํ์ง ์๊ณ ๋ณํ ์ถ๋ ฅ๋ง ์์ฑํ๋ค๋ ์์น ์ ์ง# =====================================================================
# ---------- G2P ๋ก๋ฉ (์๋ ์ ํ ์์ ์ฅ์น) ----------# ============================================================================# VoiceScript-AI v149 โ ๋จ์ด์ฅ ์ต๊ฐํ (์ธ๋ถ ํ ํฌ๋์ด์ ๋ฏธ์ฌ์ฉ)# ============================================================================# [2026-08-29]# - ์ธ๋ถ ํ์ฌ ํ ํฌ๋์ด์ ์์กด์ฑ ์์ ์ ๊ฑฐ. ๋์ด์ฝ๊ธฐ๋ ๋จ์ด์ฅ ๊ธฐ๋ฐ ํ๊ธฐ ์ ๊ทํ# + ๋ฌธ์ฅ๋ถํธ ํธํก์ (`, ` ๋ค์ `/`, ๋ฌธ์ฅ ๋์์ `\n\n`)์ผ๋ก๋ง ๋ง๋ ๋ค.# - ์๋ ๋ฐ์ ์ฌ์ 172๊ฐ (์ฌ์ฉ์ ํค ๋ฑ๋ก๊ฐ ์ฐ์ โ ๋นํ๊ดด ๋ณํฉ).# - ์ค๋์ค ์์ฑ ์ฝ๋(edge-ttsยทgTTSยทAudio ์์ ฏ) ์์ ์ ๊ฑฐ โ ๋๋ณธ ๋ณํ ์ ์ฉ ์ฑ.# - ๋จ์ด์ฅ ์ ๊ท 60๊ฐ ์ถ๊ฐ(์๋ฌธ ์ฝ์ดยท์นดํยท์ฑยท๋จ์ยท์ฌ์ด์ฆยท๊ธฐ๊ฐยท์์ผ).# - ๋ฒํผ ํ์ ๊ฐ์ scaleยทsize๋ก ํต์ผ. ์ด๊ธฐํ ๋ฒํผ์ ๋ง์ง๋ง ์๋ฆฌ๋ก ๋ณต์.# ============================================================================
# ---------- G2P ์๋ ์ ํ (g2pk โ g2pk2 โ g2pkk) ----------g2p = NoneG2P_BACKEND = "์์"for _mod in ("g2pk", "g2pk2", "g2pkk"):6 unmodified lines except Exception as _e: print(f"G2P {_mod} ๋ก๋ฉ ์คํจ: {_e}")
# ---------- Kiwi ๋ก๋ฉ (์ ํ ๊ธฐ๋ฅ: ์ค๊ฐ ๋ง 2.0 / ํธํก๊ตฌ ๋ฆฌ์คํ์ด์ฑ) ----------kiwi = Nonetry: from kiwipiepy import Kiwi kiwi = Kiwi() print("Kiwi ๋ก๋ฉ ์๋ฃ")except Exception as _e: print(f"Kiwi ๋ก๋ฉ ์คํจ(์ ํ ๊ธฐ๋ฅ ๋นํ์ฑํ): {_e}")
dict_path = "custom_dict.json"ADMIN_ID = os.environ.get("ADMIN_ID", "admin")ADMIN_PW = os.environ.get("ADMIN_PW", "admin1234")GUEST_ID = os.environ.get("GUEST_ID", "guest")GUEST_PW = os.environ.get("GUEST_PW", "guest1234")
# ---------- P0: HF Dataset ์๊ตฌ ์ ์ฅ์ ์ฐ๊ฒฐ ----------# ---------- HF Dataset ์๊ตฌ ์ ์ฅ์ (์ ํ) ----------HF_TOKEN = os.environ.get("HF_TOKEN")DICT_REPO = os.environ.get("DICT_REPO", "").strip()hf_api = Nonedict_repo_id = NoneSYNC_STATE = "๋ก์ปฌ ์ ์ฉ (HF_TOKEN ๋ฏธ์ค์ - Space ์ฌ์์ ์ ๋ฑ๋ก๋ถ ์ ์ค ์ํ!)"SYNC_STATE = "๋ก์ปฌ ์ ์ฉ (HF_TOKEN ๋ฏธ์ค์ โ Space ์ฌ์์ ์ ๋ฑ๋ก๋ถ ์ ์ค!)"try: from huggingface_hub import HfApi, hf_hub_download if HF_TOKEN:6 unmodified lines SYNC_STATE = f"์๊ตฌ ์ ์ฅ์ ์ฐ๊ฒฐ ์คํจ({_e}) - ๋ก์ปฌ ์ ์ฅ๋ง ๋์"print(f"[์ฌ์ ์ ์ฅ์] {SYNC_STATE}")
# ์ฌ์์ ์์๋ 'ํค๊ฐ ์์ ๋๋ง' ์ถ๊ฐ๋๋ ๊ธฐ๋ณธ ๋จ์ด (์ฌ์ฉ์ ๋ฑ๋ก๊ฐ์ ์ ๋ ๋ฎ์ด์ฐ์ง ์์)# ============================================================================# AUTO_MERGE_WORDS โ ์๋ ๋ฐ์ ์ฌ์ # ์ฌ์ฉ์ ์ฌ์ ์ ๊ฐ์ ํค๊ฐ ์ด๋ฏธ ์์ผ๋ฉด setdefault ๋๋ถ์ ๋ฎ์ด์ฐ์ง ์์.# ============================================================================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๋ง์ ๋", "๋ง์๋"], ["~์
๋๋ค", "~์ต๋๋ค"], ["์์ ์
๋๋ค", "์์ ์
๋๋ค"], ["๊ฒฐ๊ณผ์ ์ผ๋ก", "๊ฒฐ๊ณผ์ ์ผ๋ก"], ["์ผ์ฑ", "์ผ์ฑ"], ["LG", "์์ง"], ["SK", "์์ค์ผ์ด"], # โโ ์๋ฌธ ์ฝ์ดยท๋ธ๋๋ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["H&M", "์์ด์น ์ค ์ "], ["ZARA", "์๋ผ"], ["UNIQLO", "์ ๋ํด๋ก"], ["YouTube", "์ ํ๋ธ"], ["Instagram", "์ธ์คํ๊ทธ๋จ"], ["iPhone", "์์ดํฐ"], ["iOS", "์์ด์ค์์ค"], ["IOS", "์์ด์ค์์ค"], ["Android", "์๋๋ก์ด๋"], ["Mac", "๋งฅ"], ["MacBook", "๋งฅ๋ถ"], ["Windows", "์๋์ฐ"], ["NAVER", "๋ค์ด๋ฒ"], ["DAUM", "๋ค์"], ["KAKAO", "์นด์นด์ค"], ["CJ", "์จ์ ์ด"], ["HD", "์์ด์น๋"], ["LS", "์์์ค"], ["LG", "์์ง"], ["SK", "์์ค์ผ์ด"], ["KT", "์ผ์ดํฐ"], ["26SS", "์ด์ญ์ก ์์ค์์ค"], ["26 SS", "์ด์ญ์ก ์์ค์์ค"], ["26S/S", "์ด์ญ์ก ์์ค์์ค"], ["26 S/S", "์ด์ญ์ก ์์ค์์ค"], ["25SS", "์ด์ญ์ค ์์ค์์ค"], ["25 SS", "์ด์ญ์ค ์์ค์์ค"], ["FW", "์ํ๋๋ธ์ "], ["SSFW", "์์ค์์ค ์ํ๋๋ธ์ "], ["GS๋ง์ด์ต", "์ง์์ค๋ง์ด์ต"], ["GS ๋ง์ด์ต", "์ง์์ค๋ง์ด์ต"], ["GS์ต", "์ง์์ค์ต"], ["GS ์ต", "์ง์์ค์ต"], # โโ ์นดํยท์ฑยท์๋น์ค โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["์นด์นด์คํก", "์นด์นด์ค ํก"], ["๋ฐฐ๋ฌ์๋ฏผ์กฑ", "๋ฐฐ๋ฌ์ ๋ฏผ์กฑ"], ["๋น๊ทผ๋ง์ผ", "๋น๊ทผ ๋ง์ผ"], ["ํ ์ค", "ํ ์ค"], ["์ฟ ํก", "์ฟ ํก"], ["๋ค์ด๋ฒ", "๋ค์ด๋ฒ"], ["๋ค์", "๋ค์"], ["์ค", "์ค"], # โโ ์ซ์+๋จ์ ๊ฒฐํฉ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["14์ธ์น", "์ญ์ฌ ์ธ์น"], ["13.3์ธ์น", "์ญ์ผ ์ ์ผ ์ธ์น"], ["15์ธ์น", "์ญ์ค ์ธ์น"], ["15.6์ธ์น", "์ญ์ค ์ ์ก ์ธ์น"], ["32GB", "์ผ์ญ์ด ๊ธฐ๊ฐ"], ["64GB", "์ก์ญ์ฌ ๊ธฐ๊ฐ"], ["128GB", "๋ฐฑ์ด์ญํ ๊ธฐ๊ฐ"], ["256GB", "์ด๋ฐฑ์ค์ญ์ก ๊ธฐ๊ฐ"], ["512GB", "์ค๋ฐฑ์ญ์ด ๊ธฐ๊ฐ"], ["1TB", "์ผ ํ
๋ผ๋ฐ์ดํธ"], ["1080p", "์ฒํ์ญ ํผ"], ["4K", "ํฌ ์ผ์ด"], ["8K", "์์ ์ผ์ด"], # โโ ๋จ์ ๋ณด์ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["์ธ์น", "์ธ์น"], ["์ผ๋", "์ผ๋"], ["ํ์ด๋", "ํ์ด๋"], ["์จ์ค", "์จ์ค"], ["๊ฐค๋ฐ", "๊ฐค๋ฐ"], ["์จ๋", "์จ๋"], ["ํฅํ๋ฅด", "ํฅํ๋ฅด"], ["๋ฐ์๋ฆฌํฐ", "๋ฐ์๋ฆฌํฐ"], ["๋ง์ผ", "๋ง์ผ"], ["๋
ธํธ", "๋
ธํธ"], ["mm", "๋ฐ๋ฆฌ๋ฏธํฐ"], ["cm", "์ผํฐ๋ฏธํฐ"], ["km", "ํฌ๋ก๋ฏธํฐ"], ["kg", "ํฌ๋ก๊ทธ๋จ"], ["mg", "๋ฐ๋ฆฌ๊ทธ๋จ"], ["ml", "๋ฐ๋ฆฌ๋ฆฌํฐ"], # โโ ์๋ฌธ ์๋ฅ ์ฌ์ด์ฆ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["XS", "์์ค์ค"], ["S", "์์ค"], ["M", "์ "], ["L", "์"], ["XL", "์์ค์"], ["XXL", "๋๋ธ์์ค์"], ["FREE", "ํ๋ฆฌ"], ["ONE SIZE", "์ ์ฌ์ด์ฆ"], # โโ ํ์ซ์ ์ฌ์ด์ฆ(ํ๊ตญ ์๋ฅ ์ฌ์ด์ฆ) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["55์ฌ์ด์ฆ", "์ค์ค ์ธ์ด์ฆ"], ["55 ์ฌ์ด์ฆ", "์ค์ค ์ธ์ด์ฆ"], ["66์ฌ์ด์ฆ", "์ต์ก ์ธ์ด์ฆ"], ["66 ์ฌ์ด์ฆ", "์ต์ก ์ธ์ด์ฆ"], ["77์ฌ์ด์ฆ", "์น ์น ์ธ์ด์ฆ"], ["77 ์ฌ์ด์ฆ", "์น ์น ์ธ์ด์ฆ"], ["88์ฌ์ด์ฆ", "ํํ ์ธ์ด์ฆ"], ["88 ์ฌ์ด์ฆ", "ํํ ์ธ์ด์ฆ"], ["95์ฌ์ด์ฆ", "๊ตฌ์ค ์ธ์ด์ฆ"], ["95 ์ฌ์ด์ฆ", "๊ตฌ์ค ์ธ์ด์ฆ"], ["100์ฌ์ด์ฆ", "๋ฐฑ ์ธ์ด์ฆ"], ["100 ์ฌ์ด์ฆ", "๋ฐฑ ์ธ์ด์ฆ"], ["105์ฌ์ด์ฆ", "๋ฐฑ์ค ์ธ์ด์ฆ"], ["105 ์ฌ์ด์ฆ", "๋ฐฑ์ค ์ธ์ด์ฆ"], ["110์ฌ์ด์ฆ", "๋ฐฑ์ญ ์ธ์ด์ฆ"], ["110 ์ฌ์ด์ฆ", "๋ฐฑ์ญ ์ธ์ด์ฆ"], ["๋จ๋
์ฌ์ด์ฆ", "๋จ๋
์ฌ์ด์ฆ"], ["๋จ๋
์ฌ์ด์ฆ", "๋จ๋
์ฌ์ด์ฆ"], # โโ %, 100% โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["100%", "๋ฐฑํ๋ก"], ["100 %", "๋ฐฑํ๋ก"], ["100ํ๋ก", "๋ฐฑํ๋ก"], ["50%", "์ค์ญํ๋ก"], ["50 %", "์ค์ญํ๋ก"], ["20%", "์ด์ญํ๋ก"], ["20 %", "์ด์ญํ๋ก"], ["30%", "์ผ์ญํ๋ก"], ["30 %", "์ผ์ญํ๋ก"], ["90%", "๊ตฌ์ญํ๋ก"], ["90 %", "๊ตฌ์ญํ๋ก"], # โโ ๊ฐ๊ฒฉ (์ฝค๋ง ์๋ ๊ฒ ์ฐ์ โ ์ผ๋ฐ ๊ฒ ์ฐจํ) โโโโโโโโโโโโโโโโโโโโโโ ["99,000์", "๊ตฌ๋ง ๊ตฌ์ฒ ์"], ["99,000 ์", "๊ตฌ๋ง ๊ตฌ์ฒ ์"], ["59,900์", "์ค๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["59,900 ์", "์ค๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["49,900์", "์ฌ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["49,900 ์", "์ฌ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["39,900์", "์ผ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["39,900 ์", "์ผ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["29,900์", "์ด๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["29,900 ์", "์ด๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["19,900์", "๏ฟฝ๏ฟฝ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["19,900 ์", "์ผ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["9,900์", "๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["9,900 ์", "๊ตฌ์ฒ๊ตฌ๋ฐฑ ์"], ["59,900", "์ค๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ"], ["49,900", "์ฌ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ"], ["39,900", "์ผ๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ"], ["29,900", "์ด๋ง ๊ตฌ์ฒ๊ตฌ๋ฐฑ"], # โโ ๊ธฐ๊ฐ (์ผ๋ฐ ์ผ/์ฃผ/๋
) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["1์ผ", "ํ๋ฃจ"], ["2์ผ", "์ดํ"], ["3์ผ", "์ฌํ"], ["1์ฃผ", "์ผ์ฃผ"], ["2์ฃผ", "์ด์ฃผ"], ["1๋
", "์ผ๋
"], ["24์๊ฐ", "์ด์ญ์ฌ ์๊ฐ"], ["12์๊ฐ", "์ญ์ด ์๊ฐ"], ["3๊ฐ์", "์ผ๊ฐ์"], ["3 ๊ฐ์", "์ผ๊ฐ์"], ["6๊ฐ์", "์ก๊ฐ์"], ["6 ๊ฐ์", "์ก๊ฐ์"], ["12๊ฐ์", "์ญ์ด๊ฐ์"], ["12 ๊ฐ์", "์ญ์ด๊ฐ์"], ["24๊ฐ์", "์ด์ญ์ฌ๊ฐ์"], ["24 ๊ฐ์", "์ด์ญ์ฌ๊ฐ์"], # โโ ์๊ฐยท์์ผ ํ๊ธฐ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["์ค์ ", "์ค์ "], ["์คํ", "์คํ"], ["AM", "์์ด์ "], ["PM", "ํผ์ "], ["KST", "์ผ์ด์์คํฐ"], ["์์์ผ", "์์์ผ"], ["ํ์์ผ", "ํ์์ผ"], ["ํ์ผ", "ํ์ผ"], # โโ ๊ฐ๊ฒฉ๋ ํํ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["1๋ง์๋", "๋ง์๋"], ["1๋ง ์๋", "๋ง์๋"], ["1๋ง ์ ๋", "๋ง์๋"], ["1๋ง์ ๋", "๋ง์๋"], ["2๋ง์๋", "์ด๋ง์๋"], ["2๋ง ์๋", "์ด๋ง์๋"], ["3๋ง์๋", "์ผ๋ง์๋"], ["3๋ง ์๋", "์ผ๋ง์๋"], ["5๋ง์๋", "์ค๋ง์๋"], ["5๋ง ์๋", "์ค๋ง์๋"], # โโ ์์ฃผ ํ๋ฆฌ๋ ํ๊ตญ์ด ํ๊ธฐ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ["~์
๋๋ค", "~์ต๋๋ค"], ["์
๋๋ค", "์
๋๋ค"], ["์์ ์
๋๋ค", "์์ ์
๋๋ค"], ["๊ฒฐ๊ณผ์ ์ผ๋ก", "๊ฒฐ๊ณผ์ ์ผ๋ก"], ["์ผ์ฑ", "์ผ์ฑ"], ["ํ๋", "ํ๋"], ["๊ธฐ์", "๊ธฐ์"], ["์ํ", "์ํ"], ["์ ํ", "์ ํ"], ["๊ฐ๊ฒฉ", "๊ฐ๊ฒฉ"], ["๋ฐฐ์ก", "๋ฐฐ์ก"], ["ํ ์ธ", "ํ ์ธ"], ["์ด๋ฒคํธ", "์ด๋ฒคํธ"]]
# ---------- ์ฌ์ ์ฝ๊ธฐ/์ฐ๊ธฐ ๊ณตํต ํฌํผ ----------# ---------- ์ฌ์ I/O ----------def _read_local_dict(): try: with open(dict_path, "r", encoding="utf-8") as f:3 unmodified lines return {}
def _write_local_dict(dict_map): """์์์ ์ ์ฅ: ์์ํ์ผ(.tmp) ์์ฑ -> ์ด์ ๋ฒ์ .bak ๋ฐฑ์
-> os.replace๋ก ๊ต์ฒด. ์ด๋ ๋จ๊ณ์์ ์คํจํด๋ ๊ธฐ์กด ์ปค๋ฐ๋ณธ์ด ์์๋์ง ์์.""" items = [[k, v] for k, v in dict_map.items()] payload = {"items": items, "meta": {"app_title": "VoiceScript AI", "app_version": "147.0", "count": len(items)}} payload = {"items": items, "meta": {"app_title": "VoiceScript AI", "app_version": "149.0", "count": len(items)}} tmp_path = dict_path + ".tmp" with open(tmp_path, "w", encoding="utf-8") as f: json.dump(payload, f, ensure_ascii=False, indent=2)2 unmodified lines os.replace(tmp_path, dict_path)
def _push_remote(): """์ฌ์ ์ HF Dataset ์ ์ฅ์์ ์ปค๋ฐ (์๊ตฌ ๋ณด์กด). ์คํจํด๋ ๋ก์ปฌ ์ ์ฅ์ ์ ์ง.""" if not hf_api: return "๋ก์ปฌ ์ ์ฅ๋ง ๋จ (์ฌ์์ ์ ์ ์ค ๊ฐ๋ฅ - HF_TOKEN ์ค์ ํ์)" try:5 unmodified lines return f"์๊ฒฉ ์ ์ฅ ์คํจ({e}) - ๋ก์ปฌ๋ง ์ ์ฅ๋จ"
def save_dict(dict_map): """์ ์ฅ + ์๊ฒฉ ์ปค๋ฐ + ์์ง ์บ์ ๋ฌดํจํ. ์ํ ๋ฌธ์์ด ๋ฐํ.""" _write_local_dict(dict_map) _ENGINE_CACHE["sig"] = None msg = _push_remote() return f"{msg} ยท ํ์ฌ ์ฌ์ {len(dict_map)}๊ฐ"
def perform_startup_recovery(): """์์ ์: ๋ก์ปฌ(์ปค๋ฐ๋ณธ) <- ์๊ฒฉ(์ต์ ๋ฑ๋ก๋ถ) ํค ๋จ์ ๋ณํฉ. โ ์๊ฒฉ ํ์ผ์ด ์์ผ๋ฉด ์๊ฒฉ์ด ์ต์ -> ๋ก์ปฌ์ ๋ณํฉ(์ถฉ๋ ์ ์๊ฒฉ ์ฐ์ ). โก ๋ค์ด๋ก๋ ์์ธ(๋คํธ์ํฌ/์ธ์ฆ/์ผ์ ์ฅ์ )๋ฉด ๋ก์ปฌ ๋ณดํธ -> ์๊ฒฉ์ ์๋ฌด๊ฒ๋ pushํ์ง ์์. โข ๊ธฐ๋ณธ ๋จ์ด๋ 'ํค๊ฐ ์์ ๋๋ง' ์ถ๊ฐ (์ฌ์ฉ์ ๋ฑ๋ก๊ฐ ์ ๋ ๋ฎ์ด์ฐ์ง ์์).""" dict_map = _read_local_dict() remote_ok = True if hf_api:5 unmodified lines for i in remote.get("items", []): if len(i) == 2: dict_map[i[0].strip()] = i[1].strip() print(f"[์ฌ์ ] ์๊ฒฉ ์ ์ฅ์์์ {len(remote.get('items', []))}๊ฐ ๋ณต์") except Exception as e: is_404 = getattr(getattr(e, "response", None), "status_code", None) == 404 if is_404: print("[์ฌ์ ] ์๊ฒฉ์ ์์ง ์ฌ์ ํ์ผ ์์ - ์ต์ด ๋ถํ
์ผ๋ก ์ฒ๋ฆฌ (๋ก์ปฌ ์ ์ง)") print("[์ฌ์ ] ์๊ฒฉ์ ์์ง ์ฌ์ ํ๏ฟฝ๏ฟฝ๏ฟฝ ์์ โ ์ต์ด ๋ถํ
์ผ๋ก ์ฒ๋ฆฌ") else: remote_ok = False print(f"[์ฌ์ ] ์๊ฒฉ ๋ณต์ ์คํจ({e}) - ๋ก์ปฌ ์ฌ์ ๋ณดํธ, ์๊ฒฉ ๋ฏธ๋ณ๊ฒฝ") # ๋นํ๊ดด ๋ณํฉ: ํค๊ฐ ์์ ๋๋ง ์ถ๊ฐ (์ฌ์ฉ์ ๊ฐ ๋ณด์กด) print(f"[์ฌ์ ] ์๊ฒฉ ๋ณต์ ์คํจ({e}) - ๋ก์ปฌ ์ฌ์ ๋ณดํธ") for w in AUTO_MERGE_WORDS: dict_map.setdefault(w[0], w[1]) dict_map.setdefault(w[0], w[1]) # ์ฌ์ฉ์๊ฐ ์ ๋ ์ ๋ฎ์ด์ฐ๊ธฐ _write_local_dict(dict_map) if hf_api and remote_ok: _push_remote()6 unmodified lines flat_dict.update({k.strip(): v.strip() for k, v in user_temp_dict.items()}) return flat_dict
# ---------- P1: 2๋จ๊ณ ๋งค์นญ ์์ง (ํ๊ธฐ ์ ๊ทํ -> ๋ฐ์ ์นํ, ๊ณต๋ฐฑ ๋ฌด์) ----------# ---------- 2๋จ๊ณ ๋งค์นญ ์์ง (ํ๊ธฐ ์ ๊ทํ โ ๋ฐ์ ์นํ) ----------_ENGINE_CACHE = {"sig": None}
def _strip_np(s): return re.sub(r'[\s,\.ยท]', '', s)
def _build_pattern(keys): """ํค์ ๊ณต๋ฐฑ์ \s* ๋ก ๋ฐ๊พผ ์ ์ฐ ํจํด. (์ปดํ์ผ๋ ํจํด, ๊ทธ๋ฃน๋ฒํธ->ํค ๋ชฉ๋ก) ๋ฐํ.""" ordered = sorted(keys, key=lambda x: len(x.replace(" ", "")), reverse=True) r"""ํค ๊ธธ์ด ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ ํ ๊ณต๋ฐฑ์ \s* ๋ก ๋ฐ๊พผ ์ ์ฐ ํจํด. ๊ทธ๋ฃน๋ฒํธโํค.""" ordered = sorted(keys, key=lambda x: -len(x.replace(" ", ""))) if not ordered: return None, [] pats = [r'\s*'.join(map(re.escape, k.split(" "))) for k in ordered]8 unmodified lines if not k: continue if k == v: shields.add(k) # ๋ฑ๋ก๊ฐ ๊ทธ๋๋ก ๋ณดํธ(g2p ์ฐจ๋จ)๋ง elif _strip_np(k) == _strip_np(v): phase1[k] = v # ๋์ด์ฐ๊ธฐยท๋ฌธ์ฅ๋ถํธ๋ง ๋ค๋ฅธ ํ๊ธฐ ์ ๊ทํ shields.add(v) # ์ ๊ทํ ๊ฒฐ๊ณผ๋ g2p๋ก๋ถํฐ ๋ณดํธ shields.add(k) elif re.sub(r'[\s,\.ยท]', '', k) == re.sub(r'[\s,\.ยท]', '', v): phase1[k] = v shields.add(v) else: phase2[k] = v # ๋ฐ์ ์นํ phase2[k] = v p1_pat, p1_keys = _build_pattern(phase1.keys()) p2_pat, p2_keys = _build_pattern(phase2.keys()) sh_pat, _ = _build_pattern(shields)8 unmodified lines return eng["p1_pat"].sub(lambda m: eng["phase1"][eng["p1_keys"][m.lastindex - 1]], text)
def _segments_phase2(text, eng): """๋ฐ์ ๊ท์น ๋งค์นญ ๊ฒฐ๊ณผ๋ฅผ [(์นํ๋จ?, ํ
์คํธ)] ์ธ๊ทธ๋จผํธ๋ก ๋ฐํ. ์นํ ๊ตฌ๊ฐ์ ์ดํ g2p๋ก๋ถํฐ ๋ณดํธ.""" if not eng["p2_pat"] or not text: return [(False, text)] if text else [] segs, last = [], 08 unmodified lines return segs
def _g2p_shielded(chunk, mode, eng): """์ฌ์ ์ด ๋ง๋ค์ด๋ธ ํ๊ธฐ(์ ๊ทํ ๊ฒฐ๊ณผยท๋ณดํธ ๋จ์ด)๋ g2p๋ฅผ ๊ฑด๋๋ฐ๊ณ ๋๋จธ์ง๋ง ๋ณํ.""" if not chunk: return chunk if not eng["sh_pat"]:9 unmodified lines return "".join(res)
def convert_text(text, mode, flat_dict): """์ ์ฒด ๋ณํ ํ์ดํ๋ผ์ธ: ํ๊ธฐ ์ ๊ทํ -> ๋ฐ์ ์นํ -> ๋จ์ ๊ตฌ๊ฐ์ ์ซ์ ์ ๊ท์ -> ๋ฐ์ ์นํ 2์ฐจ -> g2p(๋ณดํธ ๊ตฌ๊ฐ ์ ์ธ). (2026-08-29 ํ์ : kiwi.space ๊ธฐ๋ฐ '๋์ด์ฐ๊ธฐ ๊ต์ ํ ๋งค์นญ'์ ์ฒดํฌ๋ฐ์คยท์ด๋ฒคํธยท๋ฐ์ธ๋ฉ๊น์ง ์์ ์ ๊ฑฐ๋จ. ์๋ฌธ ๋น๊ณต๋ฐฑ ๋ฌธ์์ด์ 1๋ฐ์ดํธ๋ ๋ฐ๊พธ์ง ์๋ ๋ถ๋ณ์ ์๋, ์ธํ ๋ณํ๋ ํธํก๊ตฌ ๋ฆฌ์คํ์ด์ฑ(add_breath_groups) ํ๋๋ฟ์ด๋ค.) ๋ถ๋ณ์: re.sub(r'\s+', '', input) == re.sub(r'\s+', '', output)""" """์๋ฌธ ๋น๊ณต๋ฐฑ ๋ฌธ์์ด ๋ณํ ์ ํ ๋์ผ์ฑ ์ ์ง. ์ธํ ๋ณํ๋ ์ฌ์ ยท์ซ์ยท๋ฌธ์ฅ๋ถํธ ํธํก ๋ง์ปค๋ก๋ง ๋ง๋ค์ด์ง๋ค.""" eng = get_engine(flat_dict) t = _sub_phase1(text, eng) out = []6 unmodified lines out.append(c2 if fixed2 else _g2p_shielded(c2, mode, eng)) return "".join(out)
# ===== BREATH-BLOCK-BEGIN =====# ---------- ํธํก๊ตฌ ๋ฆฌ์คํ์ด์ฑ (์๋ฌธ ๋ถ๋ณ + ์์ ๋ง ํฌํจ) ----------# [2026-08-29 v2] ์ ๊ฒฝ๊ณ ๋ถํ + ๋ฌธ๋์ฃผ์ ๋ถ๋ฆฌ + ๊ทธ๋ฃน ๋ด ๋ถ์ฌ์ฝ๊ธฐ + MAX9# ๋ถ๋ณ์: re.sub(r'[\s/]', '', ์
๋ ฅ) == re.sub(r'[\s/]', '', ์ถ๋ ฅ)# - ํ๋ฝ: ๊ณต๋ฐฑ ์ฝ์
ยท์ญ์ , ํธํก๊ตฌ ์ฌ์ด ' / ' ๋ง์ปค ๋ถ์ฐฉ(=๊ณต๋ฐฑ ๋ณํ)# - ๊ธ์ง: ์กฐ์ฌ/์ด๋ฏธ ๋ถ๋ฆฌ, ๊ธ์ ๋จ์ ๋ณํ, ์ด์ ๋ณํฉยท๋ถํ , ์คํ์ ๊ต์
# โ๏ธ ๋ณํ์ด ์ด์ํด์ก์ ๋: ์ด ํ ์ค๋ง False ๋ก ๋ฐ๊พธ๋ฉด ๊ธฐ์กด(v1) ๋์์ผ๋ก ์ฆ์ ๋ณต๊ทUSE_NEW_BREATH = True
_BREATH_TAGS = {"EC", "EF", "ETN", "ETM", "SF", "SP", "SE", "SY"} # ์ /๋ฌธ ๊ฒฝ๊ณ๋ง (๊ฒฉ์กฐ์ฌ X)_BREATH_MIN = 6 # ํ ํธํก ์ต์ ๊ธ์ (6 ๋ฏธ๋ง์ด๋ฉด ๋ถํ ์ ํจ)_BREATH_MAX = 15 # ํ ํธํก ์ํ ๊ธ์ (๋ฌด๋ฃ ์ ์ฉ: 12โ15 โ ๋ ๊ธธ๊ฒ, ๊ณผ๏ฟฝ๏ฟฝ๏ฟฝํ ๋ฐฉ์ง)_BREATH_JOIN = True # True: ๊ฐ์ ํธํก๊ตฌ ์ ๊ณต๋ฐฑ ์ ๊ฑฐ(๋ถ์ฌ ์ฝ๊ธฐ) / False: 1์นธ ์ ์ง_CODE_TAGS = ("SL", "SN", "SW") # ์๋ฌธยท์ซ์ยท๊ธฐํธ (์ฝ๋ ํด๋ฌ์คํฐ ๋ด๋ถ ๋ถํ ๊ธ์ง)
_BREATH_TAGS_LEGACY = {"JKS", "JKC", "JKG", "JKO", "JKB", "JKV", "JX", "JC", "EF", "EC", "ETN", "ETM", "SF", "SP", "SE", "SY"}_BREATH_MIN_LEGACY = 5_BREATH_MAX_LEGACY = 14
def _breath_len(e): return len(re.sub(r"[^๊ฐ-ํฃa-zA-Z0-9]", "", e)) or len(e)
def _breath_last_tag(e): try: toks = kiwi.tokenize(e) return toks[-1].tag if toks else None except Exception: return None
def add_breath_groups_legacy(text): """[๋กค๋ฐฑ์ฉ] ๊ธฐ์กด v1 ํจ์ (๊ฒฉ์กฐ์ฌ ํฌํจ ํ๊ทธ + MIN5/MAX14 + ๊ทธ๋ฃน ๋ด 1์นธ ๊ณต๋ฐฑ)""" if kiwi is None or not text or not text.strip(): return text orig_eojeols = text.split() if len(orig_eojeols) <= 1: return text groups, cur, cur_len = [], [], 0 for e in orig_eojeols: cur.append(e) cur_len += _breath_len(e) tag = _breath_last_tag(e) if (tag in _BREATH_TAGS_LEGACY and cur_len >= _BREATH_MIN_LEGACY) or cur_len >= _BREATH_MAX_LEGACY: groups.append(cur) cur, cur_len = [], 0 if cur: groups.append(cur) return " / ".join(" ".join(g) for g in groups)
def add_breath_groups_new(text): """[v2] ์ ๊ฒฝ๊ณ ๋ถํ + ๋ฌธ๋์ฃผ์ ๋ถ๋ฆฌ + ๊ทธ๋ฃน ๋ด ๋ถ์ฌ์ฝ๊ธฐ + MAX9""" if kiwi is None or not text or not text.strip(): return text es = text.split() n = len(es) if n <= 1: return text groups, cur, cur_len = [], [], 0 for i, e in enumerate(es): tag = _breath_last_tag(e) # โ ๋ฌธ๋ ์ฃผ์ (์/๋) = ๋
๋ฆฝ ํธํก๊ตฌ โ "์ค๋์ / ..." if i == 0 and tag == "JX" and n > 1: groups.append([e]) continue # โก ์๋ฌธยท์ซ์ยท๊ธฐํธ ํด๋ฌ์คํฐ๋ ๋ด๋ถ ๋ถํ ๊ธ์ง โ "GS๋ง์ด์ต 26SS" ์ ์ง if cur and tag in _CODE_TAGS and _breath_last_tag(cur[-1]) in _CODE_TAGS: cur.append(e); cur_len += _breath_len(e) continue cur.append(e); cur_len += _breath_len(e) # โข ์ /๋ฌธ ๊ฒฝ๊ณ + ์ต์ยท์ต๋ ์ถฉ์กฑ ์ ๋ถํ if tag in _BREATH_TAGS and _BREATH_MIN <= cur_len <= _BREATH_MAX: groups.append(cur); cur, cur_len = [], 0 continue # โฃ ์ํ ์ด๊ณผ โ ๊ฐ์ ๋ถํ (๋ฐฉ๊ธ ๋ถ์ธ ์ด์ ์ด ์ฝ๋๋ฉด ์์ธ) if cur_len > _BREATH_MAX and tag not in _CODE_TAGS: if len(cur) >= 2 and cur_len - _breath_len(e) >= _BREATH_MIN: groups.append(cur[:-1]); cur = [cur[-1]]; cur_len = _breath_len(e) else: groups.append(cur); cur, cur_len = [], 0 if cur: groups.append(cur) sep = "" if _BREATH_JOIN else " " return " / ".join(sep.join(g) for g in groups)
def _invariant_ok(out, src): """์๋ฌธ ๋น๊ณต๋ฐฑ(๊ณต๋ฐฑยท'/' ์ ๊ฑฐ) ๋ฌธ์์ด์ด ๊ทธ๋๋ก์ธ์ง ํ์ธ""" try: return re.sub(r'[\s/]', '', src) == re.sub(r'[\s/]', '', out) except Exception: return False
def _max_ok(out): """ํธํก๊ตฌ๋ณ ๊ธ์ ์(๊ณต๋ฐฑยท'/' ์ ์ธ)๊ฐ _BREATH_MAX ์ดํ์ธ์ง ํ์ธ""" try: for g in out.split(" / "): if len(re.sub(r'[\s/]', '', g)) > _BREATH_MAX: return False return True except Exception: return False
def add_breath_groups(text): """๋ฉ์ธ ์ํธ๋ฆฌ: ์ ํจ์ ์คํ โ ๋ถ๋ณ์ ๊ฒ์ฆ โ ์คํจ ์ ์๋์ผ๋ก ๊ธฐ์กด(v1) ๊ฒฐ๊ณผ ๋ฐํ. USE_NEW_BREATH = False ๋ก ๋ฐ๊พธ๋ฉด ์ฒ์๋ถํฐ v1(legacy)๋ฅผ ์ฌ์ฉํฉ๋๋ค.""" if not USE_NEW_BREATH: return add_breath_groups_legacy(text) out = add_breath_groups_new(text) if _invariant_ok(out, text): return out # ์์ ๋ง: ์ ํจ์ ์ถ๋ ฅ์ด ๋ถ๋ณ์(๊ธ์ ์ ์คยท๋ณํ)์ ๊นจ๋ฉด ๊ธฐ์กด ํจ์๋ก ์๋ ๋ณต๊ท # (MAX ๊ธธ์ด ์ด๊ณผ๋ "๋ฌธ์ฒด" ๋ฌธ์ ์ด๋ฏ๋ก ํด๋ฐฑ ๋์์ด ์๋ โ _BREATH_MIN/MAX๋ก ํ๋) return add_breath_groups_legacy(text)# ===== BREATH-BLOCK-END =====
# ---------- [๋ฌด๋ฃ ์ ์ฉ] TTS: edge-tts โ gTTS โ ๐ ๋ธ๋ผ์ฐ์ ํด๋ฐฑ (API ํคยท๊ฒฐ์ ์์) ----------# ๐ฐ ์ ๋ฃ ํด๋ผ์ฐ๋ TTS(Google/Azure/ElevenLabs)๋ ์ผ์ ์ฌ์ฉํ์ง ์์.# - edge-tts: Microsoft Edge ์ ๊ฒฝ๋ง ์์ฑ(ko-KR-SunHiNeural ๋ฑ) โ ํค ๋ถํ์, ๋ฌด๋ฃ# - gTTS: Google Translate TTS โ ํค ๋ถํ์, ๋ฌด๋ฃ (ํด๋ฐฑ)# - ๐ ๋ธ๋ผ์ฐ์ ๋ฏธ๋ฆฌ๋ฃ๊ธฐ: ์ต์ข
ํด๋ฐฑ (๊ธฐ์กด ๊ทธ๋๋ก)# requirements.txt์ "edge-tts>=7.0.0"์ "gtts>=2.5.0" ์ถ๊ฐ.FREE_TTS_STATUS = "๐ ๋ฌด๋ฃ TTS ์ค๋น๋จ (edge-tts โ gTTS โ ๋ธ๋ผ์ฐ์ ํด๋ฐฑ, ํคยท๊ฒฐ์ ์์)"_EDGE_VOICE = os.environ.get("FREE_TTS_VOICE", "ko-KR-SunHiNeural")
def _tts_clean(text): """ํธํก๊ตฌ ' / ' โ ์ผํ(์ ๊ฒฝ๋ง ์์ฑ์ด ์ผํ์์ ์์ฐ์ค๋ฝ๊ฒ ๋ฉ์ถค), ๋ง์ปค(@@) ์ ๊ฑฐ""" return text.replace("@@", "").replace(" / ", ", ")
def synth_free_edge(text, voice=_EDGE_VOICE): """edge-tts: ํค ์๋ ๋ฌด๋ฃ ์์ฑ ํฉ์ฑ. ์คํจ ์ None ๋ฐํ.""" try: import asyncio, edge_tts out = "tts_edge.mp3" async def _go(): c = edge_tts.Communicate(text, voice) await c.save(out) asyncio.run(_go()) if os.path.exists(out) and os.path.getsize(out) > 100: return out except Exception as e: print(f"[FREE-TTS] edge-tts ์คํจ: {e}") return None
def synth_free_gtts(text): """gTTS: ํค ์๋ ๋ฌด๋ฃ ์์ฑ ํฉ์ฑ(ํด๋ฐฑ). ์คํจ ์ None ๋ฐํ.""" try: from gtts import gTTS out = "tts_gtts.mp3" gTTS(text, lang="ko").save(out) if os.path.exists(out) and os.path.getsize(out) > 100: return out except Exception as e: print(f"[FREE-TTS] gTTS ์คํจ: {e}") return None
def tts_free_click(text, user_temp_dict): """๐ ๋ฌด๋ฃ TTS ๋ฃ๊ธฐ ๋ฒํผ ํธ๋ค๋ฌ: edge-tts โ gTTS ์์, ์ ๋ถ ์คํจ ์ ๋ธ๋ผ์ฐ์ ๋ฏธ๋ฆฌ๋ฃ๊ธฐ ์๋ด.""" if not text or not text.strip(): return None, "โ ๏ธ ๋จผ์ [๋ณํํ๊ธฐ]๋ฅผ ๋๋ฌ ๊ฒฐ๊ณผ๋ฅผ ๋ง๋ค์ด์ฃผ์ธ์." try: t = _tts_clean(text) path = synth_free_edge(t) or synth_free_gtts(t) if path: engine = "edge-tts" if "edge" in path else "gTTS" return path, f"โ
๋ฌด๋ฃ TTS ์์ฑ ์๋ฃ ({engine}, ํคยท๊ฒฐ์ ์์ โ {_EDGE_VOICE})" return None, "โ ๋ฌด๋ฃ TTS ์์ฑ ์คํจ โ ์๋ ๐ ๋ธ๋ผ์ฐ์ ๋ฏธ๋ฆฌ๋ฃ๊ธฐ๋ฅผ ์ฌ์ฉํ์ธ์." except Exception as e: return None, f"โ ์ค๋ฅ: {e}"
# ---------- G2P ๋ชจ๋ ----------_KIWI_PROTECT_TAGS = ("NNP", "SL", "SH", "SN", "SW") # ๊ณ ์ ๋ช
์ฌยท์ธ๋์ดยทํ์ยท์ซ์ยท๊ธฐํธ
def apply_g2p(text, mode): if g2p is None or mode.startswith("๋๊ธฐ"): return text14 unmodified lines else: res.append(w) return "".join(res) if mode.startswith("์ค๊ฐ ๋ง 2.0"): if kiwi is None: mode = "์ค๊ฐ ๋ง" # Kiwi ์์ผ๋ฉด ๊ธฐ์กด ์ค๊ฐ ๋ง์ผ๋ก ํด๋ฐฑ else: res = [] for w in re.split(r'(\s+)', text): if not w.strip(): res.append(w) continue if not re.match(r'^[๊ฐ-ํฃ]+[.,!?]*$', w): res.append(w) # ์๋ฌธยท์ซ์ ์์ธ ์ด์ ์ ์ํ ๋ณดํธ continue try: toks = kiwi.tokenize(w) if any(tk.tag in _KIWI_PROTECT_TAGS for tk in toks): res.append(w) # ๊ณ ์ ๋ช
์ฌ ๋ฑ ๋ณดํธ else: res.append(g2p(w)) except Exception: res.append(w) return "".join(res) if mode.startswith("์ค๊ฐ ๋ง"): # ๋ช
์ฌ/๊ณ ์ ์ด (ํ๊ธ 2๊ธ์+) ๋ง ๋ณํ, ๋จ์ผ ์กฐ์ฌยท๋ณด์กฐ์ฌยท๊ธฐํธ๋ ๊ฑด๋๋ tokens = re.split(r'([๊ฐ-ํฃ]+|[a-zA-Z]+|\d+|[^\w\s]+|\s+)', text) particles = {'์ด', '๊ฐ', '์', '๋ฅผ', '์', '๋', '์', '๋ก', '์ผ๋ก', '๊ณ ', '๋ค', '์ด', '์', '๋ค', '์
๋๋ค', '์ต๋๋ค'} particles = {'์ด', '๊ฐ', '์', '๋ฅผ', '์', '๋', '์', '๋ก', '์ผ๋ก', '๊ณ ', '๋ค', '์ด', '์', '๋ค', '์
๋๋ค', '์ต๋๋ค'} res = [] for t in tokens: if not t:10 unmodified lines return "".join(res) return text
# ---------- ์ซ์/๋จ์ ์ค๋งํธ ์ ๊ท์ (๊ธฐ์กด ์ ์ง) ----------# ---------- ์ซ์/๋จ์ ํ๊ตญ์ด ๋ณํ ----------def number_to_korean(num_str): num_str = num_str.replace(',', '') try:2 unmodified lines return num_str if n == 0: return "์" digits, units, large_units = ["", "์ผ", "์ด", "์ผ", "์ฌ", "์ค", "์ก", "์น ", "ํ", "๊ตฌ"], ["", "์ญ", "๋ฐฑ", "์ฒ"], ["", "๋ง", "์ต", "์กฐ"] digits, units, large_units = ["", "์ผ", "์ด", "์ผ", "์ฌ", "์ค", "์ก", "์น ", "ํ", "๊ตฌ"], \ ["", "์ญ", "๋ฐฑ", "์ฒ"], ["", "๋ง", "์ต", "์กฐ"] res, str_n = [], str(n)[::-1] for i in range(0, len(str_n), 4): chunk, chunk_res = str_n[i:i+4], []16 unmodified lines text = re.sub(r'\b1\s*๋ง์๋\b', "๋ง์๋", text) text = re.sub(r'(\d+)\s*๊ฐ์\b', lambda m: f"{number_to_korean(m.group(1))}๊ฐ์", text) text = re.sub(r'(\d+)\s*(%|ํ๋ก)\b', lambda m: f"{number_to_korean(m.group(1))}ํ๋ก", text) size_dict = {"55": "์ค์ค", "66": "์ต์ก", "77": "์น ์น ", "88": "ํํ"} text = re.sub(r'\b(55|66|77|88)\s*์ฌ์ด์ฆ\b', lambda m: f"{size_dict[m.group(1)]} ์ธ์ด์ฆ", text) text = re.sub(r'(\d{1,3}(?:,\d{3})+|\d+)\s*๋ง\s*์\s*๋\b', lambda m: f"{number_to_korean(m.group(1))}๋ง์๋", text) text = re.sub(r'(\d{1,3}(?:,\d{3})+|\d+)\s*์\b', lambda m: f"{number_to_korean(m.group(1))} ์", text) unit_dict = {"mm": "๋ฐ๋ฆฌ๋ฏธํฐ", "cm": "์ผํฐ๋ฏธํฐ", "m": "๋ฏธํฐ", "km": "ํฌ๋ก๋ฏธํฐ", "g": "๊ทธ๋จ", "kg": "ํฌ๋ก๊ทธ๋จ", "ml": "๋ฐ๋ฆฌ๋ฆฌํฐ", "L": "๋ฆฌํฐ"} text = re.sub(r'(\d+)\s*(mm|cm|m|km|g|kg|ml|L)\b', lambda m: f"{number_to_korean(m.group(1))} {unit_dict[m.group(2).lower() if m.group(2).lower() != 'l' else 'L']}", text, flags=re.IGNORECASE) size_dict = {"55": "์ค์ค", "66": "์ต์ก", "77": "์น ์น ", "88": "ํํ", "95": "๊ตฌ์ค", "100": "๋ฐฑ", "105": "๋ฐฑ์ค", "110": "๋ฐฑ์ญ"} def _size_repl(m): k = m.group(1) return f"{size_dict[k]} ์ธ์ด์ฆ" if k in size_dict else m.group(0) text = re.sub(r'\b(55|66|77|88|95|100|105|110)\s*์ฌ์ด์ฆ\b', _size_repl, text) text = re.sub(r'(\d{1,3}(?:,\d{3})+|\d+)\s*๋ง\s*์\s*๋\b', lambda m: f"{number_to_korean(m.group(1))}๋ง์๋", text) text = re.sub(r'(\d{1,3}(?:,\d{3})+|\d+)\s*์\b', lambda m: f"{number_to_korean(m.group(1))} ์", text) unit_dict = {"mm": "๋ฐ๋ฆฌ๋ฏธํฐ", "cm": "์ผํฐ๋ฏธํฐ", "m": "๋ฏธํฐ", "km": "ํฌ๋ก๋ฏธํฐ", "g": "๊ทธ๋จ", "kg": "ํฌ๋ก๊ทธ๋จ", "ml": "๋ฐ๋ฆฌ๋ฆฌํฐ", "L": "๋ฆฌํฐ"} def _unit_repl(m): num_u, u = m.group(1), m.group(2).lower() if m.group(2).lower() != 'l' else 'L' return f"{number_to_korean(num_u)} {unit_dict[u]}" text = re.sub(r'(\d+)\s*(mm|cm|m|km|g|kg|ml|L)\b', _unit_repl, text, flags=re.IGNORECASE) return text
# ---------- ๋ฉ์ธ ๋ณํ ----------def process_text(input_text, ai_mode, auto_break, smart_pause, breath_groups, font_size, user_temp_dict):# ---------- ์ฒ๋ฆฌ ํ ์ค์ ๋ชจ์ผ๊ธฐ (ํธํก์ ๋ง ๋ฌธ์ฅ๋ถํธ ๊ธฐ๋ฐ) ----------def _join_breath_marks(text): """์ผํยท๊ฐ์ด๋์ ยท๋ง์ค์ํ ๋ค์ ํธํก ๋งํฌ('/')๋ฅผ ๋ฃ๊ณ , `@@` ๋ง์ปค๋ ๋ณด์กดํ๋ค.""" text = re.sub(r'[,ใ]\s*', ', / ', text) text = re.sub(r'[ยทโข]\s*', 'ยท / ', text) text = re.sub(r'โฆ\s*', 'โฆ / ', text) return text
def process_text(input_text, ai_mode, auto_break, smart_pause, font_size, user_temp_dict): if not input_text or not input_text.strip(): return "", f'<div id="prompter_label_space">๐บ ํ๋กฌํํฐ ๋ทฐ</div><div id="prompter_output_div" style="font-size:{font_size}px;"></div>', "๊ณต๋ฐฑ ํฌํจ: 0์ / ๊ณต๋ฐฑ ์ ์ธ: 0์", "ํ์๋ ๋ง์ปค(@@)๊ฐ ์์ต๋๋ค." clean_text = input_text.replace('\r', '') char_count = f"๊ณต๋ฐฑ ํฌํจ: {len(clean_text)}์ / ๊ณต๋ฐฑ ์ ์ธ: {len(clean_text.replace(' ', '').replace(chr(10), ''))}์" return "", f'<div id="prompter_label_space">๐บ ํ๋กฌํํฐ ๋ทฐ</div><div id="prompter_output_div" style="font-size:{font_size}px;"></div>', \ "๊ณต๋ฐฑ ํฌํจ: 0์ / ๊ณต๋ฐฑ ์ ์ธ: 0์", "ํ์๋ ๋ง์ปค(@@)๊ฐ ์์ต๋๋ค."
char_count = f"๊ณต๋ฐฑ ํฌํจ: {len(input_text)}์ / ๊ณต๋ฐฑ ์ ์ธ: {len(input_text.replace(' ', '').replace(chr(10), ''))}์"
flat_dict = load_dict(user_temp_dict) if not flat_dict:1 unmodified line else: final_text = convert_text(input_text, ai_mode, flat_dict)
if breath_groups and kiwi is not None: final_text = add_breath_groups(final_text) if smart_pause: final_text = re.sub(r',\s*', ', / ', final_text) final_text = _join_breath_marks(final_text) if auto_break: final_text = final_text.replace(". ", ".\n\n").replace("? ", "?\n\n") final_text = final_text.replace(". ", ".\n\n").replace("? ", "?\n\n").replace("! ", "!\n\n")
seq = difflib.SequenceMatcher(None, input_text, final_text) html_parts = []17 unmodified linesdef get_file(): return dict_path if os.path.exists(dict_path) else None
def add_and_update(word, pronun, user_role, current_input, ai_mode, auto_break, smart_pause, breath_groups, font_size, user_temp_dict):def add_and_update(word, pronun, user_role, current_input, ai_mode, auto_break, smart_pause, font_size, user_temp_dict): if not word or not pronun: return "โ ๏ธ ๋จ์ด์ ๋ฐ์์ ์
๋ ฅํ์ธ์.", gr.update(), gr.update(), gr.update(), gr.update(), user_temp_dict word, pronun = word.strip(), pronun.strip()9 unmodified lines user_temp_dict[word] = pronun status_msg = f"๐ค [๊ฒ์คํธ] '{word}' -> '{pronun}' ์์ ์ ์ฅ ์๋ฃ! (์๋ก๊ณ ์นจ ์ ์ด๊ธฐํ - ์๊ตฌ ๋ฑ๋ก์ ์ด๋๋ฏผ์๊ฒ ์์ฒญ)" if current_input.strip(): ft, ho, cc, mr = process_text(current_input, ai_mode, auto_break, smart_pause, breath_groups, font_size, user_temp_dict) ft, ho, cc, mr = process_text(current_input, ai_mode, auto_break, smart_pause, font_size, user_temp_dict) return status_msg, ft, ho, cc, mr, user_temp_dict return status_msg, gr.update(), gr.update(), gr.update(), gr.update(), user_temp_dict
72 unmodified lines return gr.update(visible=False), gr.update(visible=True), current_role, "", gr.update(), gr.update() return gr.update(visible=True), gr.update(visible=False), "none", "", "", ""
# ---------- UI ๋น๋ ----------custom_css = """#prompter_html_wrap, #prompter_html_wrap .prose { width: 100% !important; text-align: left !important; }#input_text_area textarea, #output_text_area textarea, #prompter_output_div { font-family: sans-serif !important; height: 500px !important; overflow-y: auto !important; padding: 16px !important; line-height: 1.8 !important; }#input_text_area textarea, #output_text_area textarea, #prompter_output_div { font-family: sans-serif !important; height: 500px !important; overflow-y: auto !important; padding: 16px !important; line-height: 1.8 !important;}#prompter_output_div { background-color: #333 !important; color: #fff !important; border-radius: 8px !important; white-space: pre-wrap !important; }.login-box { max-width: 400px; margin: 100px auto; padding: 30px; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }/* ๋ฒํผ ํ 4๊ฐ ๋์ผ ํญ (Gradio use_container_width ๋์ CSS ๋ณด๊ฐ) */.convert-row { gap: 8px !important; }.convert-row > button { flex: 1 1 0 !important; min-width: 0 !important; }"""script_js = """function() {36 unmodified lines}"""insert_marker_js = "(t) => { let ta = document.querySelector('#input_text_area textarea'); if (!ta) return t; let s = ta.selectionStart, e = ta.selectionEnd, v = ta.value; ta.value = v.substring(0, s) + '@@' + v.substring(e); ta.dispatchEvent(new Event('input', { bubbles: true })); ta.selectionStart = ta.selectionEnd = s + 2; ta.focus(); return ta.value; }"tts_js = """(t) => { if (!t || !t.trim()) { alert('๋จผ์ [๋ณํํ๊ธฐ]๋ฅผ ๋๋ฌ ๊ฒฐ๊ณผ๋ฅผ ๋ง๋ค์ด์ฃผ์ธ์.'); return; } const synth = window.speechSynthesis; if (synth.speaking) { synth.cancel(); return; } const clean = t.replace(/\//g, ' ').replace(/@@/g, ''); const u = new SpeechSynthesisUtterance(clean); u.lang = 'ko-KR'; u.rate = 1.0; const ko = synth.getVoices().find(v => v.lang && v.lang.startsWith('ko')); if (ko) u.voice = ko; synth.speak(u);}"""
_mode_choices = ["๋๊ธฐ (์๋ ์ฌ์ ๋ง ์ ์ฉ)", "์ค๊ฐ ๋ง (๋ช
์ฌ/๊ณ ์ ์ด๋ง - ์ถ์ฒ โญ)"]if kiwi is not None:
_mode_choices = ["๋๊ธฐ (์๋ ์ฌ์ ๋ง ์ ์ฉ)", "์ค๊ฐ ๋ง (๋ช
์ฌ/๊ณ ์ ์ด๋ง - ์ถ์ฒ โญ)", "์ํ ๋ง (๋จ์ด๋ณ ๋๊ธฐ)", "๋งค์ด ๋ง (์์ฐ ์ฐ์)"] _mode_choices.append("์ค๊ฐ ๋ง 2.0 (Kiwi ํ์ฌ ๊ธฐ๋ฐ - ๊ณ ์ ๋ช
์ฌ ๋ณดํธ)")_mode_choices += ["์ํ ๋ง (๋จ์ด๋ณ ๋๊ธฐ - ๊ณผ๋ํ ์ฐ์ ๋ฐฉ์ง)", "๋งค์ด ๋ง (๋ฌธ์ฅ ํต์งธ๋ก - ์์ฐ์ค๋ฌ์ด ์ฐ์)"]
_GRADIO_MAJOR = int(gr.__version__.split(".")[0])_BLOCKS_KW = {"theme": "default", "css": custom_css} if _GRADIO_MAJOR < 6 else {}19 unmodified lines with gr.Column(): input_text = gr.Textbox(label="1๏ธโฃ ์๋ณธ ํ
์คํธ ์
๋ ฅ", elem_id="input_text_area") with gr.Group(): ai_mode = gr.Radio(choices=_mode_choices, value="์ค๊ฐ ๋ง (๋ช
์ฌ/๊ณ ์ ์ด๋ง - ์ถ์ฒ โญ)", label="๐ค AI ๋ฐ์ ๋ณํ ๊ฐ๋") ai_mode = gr.Radio(choices=_mode_choices, value="์ค๊ฐ ๋ง (๋ช
์ฌ/๊ณ ์ ์ด๋ง - ์ถ์ฒ โญ)", label="๐ค AI ๋ฐ์ ๋ณํ ๊ฐ๋") auto_break = gr.Checkbox(label="๐ ๋ฌธ์ฅ ๋ ์๋ ์ค๋ฐ๊ฟ", value=False) smart_pause = gr.Checkbox(label="โฑ๏ธ ์ผํ ๋ค ํธํก์ ( / ) ์ถ๊ฐ", value=False) # [์ ๊ฑฐ๋จ 2026-08-29] "๐ ๋์ด์ฐ๊ธฐ ๊ต์ ํ ๋งค์นญ" ์ฒดํฌ๋ฐ์ค ์ ๊ฑฐ โ kiwi.space()๊ฐ ์กฐ์ฌ/์ด๋ฏธ๋ฅผ ๋ถ๋ฆฌํด ์๋ฌธ ๊ธ์๋ฅผ ํผ์ํ์ breath_groups = gr.Checkbox( label=("๐ฌ๏ธ ์๋ฏธ ๋์ด์ฝ๊ธฐ (Kiwi ํธํก๊ตฌ, ์คํ์ ) โ โ
Kiwi ๋ก๋๋จ" if kiwi is not None else "๐ฌ๏ธ ์๋ฏธ ๋์ด์ฝ๊ธฐ (Kiwi ํธํก๊ตฌ, ์คํ์ ) โ โ ๏ธ Kiwi ๋ฏธ์ค์น (requirements.txt์ kiwipiepy ์ถ๊ฐ ํ์)"), value=False, interactive=(kiwi is not None)) btn_insert_marker = gr.Button("๐จ ๋ง์ปค(@@) ์ฝ์
", variant="secondary", size="sm") 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():
# === ๋ณํ ๋ฒํผ ํ (๋์ผ scaleยทsize, ์ด๊ธฐํ๋ ๋ง์ง๋ง ์๋ฆฌ) === with gr.Row(elem_classes="convert-row"): btn_conv = gr.Button("โจ ๋ณํํ๊ธฐ", variant="primary") btn_tts = gr.Button("๐ ๋ฏธ๋ฆฌ๋ฃ๊ธฐ", variant="secondary") btn_tts_free = gr.Button("๐ ๋ฌด๋ฃ TTS ๋ฃ๊ธฐ (edge-tts)", variant="secondary") btn_copy = gr.Button("๐ ๋ณต์ฌ", variant="secondary") btn_clr = gr.Button("๐๏ธ ์ด๊ธฐํ", variant="stop")
2 unmodified lines with gr.Accordion("๐ ํ
์คํธ ๊ฒฐ๊ณผ (ํด๋ฆญํ์ฌ ํผ์น๊ธฐ)", open=False): output_text = gr.Textbox(lines=8, show_label=False, elem_id="output_text_area") marker_collection = gr.Textbox(label="๐จ ์์ ํ์ ๋จ์ด (@@)", interactive=False, lines=2) tts_status = gr.Textbox(label="๐ ๋ฌด๋ฃ TTS ์ํ", value=FREE_TTS_STATUS, interactive=False) tts_audio = gr.Audio(label="๐ ๋ฌด๋ฃ TTS ์ค๋์ค (ํคยท๊ฒฐ์ ์์)")
gr.Markdown("---") gr.Markdown("**๐ก ๋๋ง์ ๋ฐ์ ์ฌ์ ์ถ๊ฐ**") gr.Markdown("**๐ก ๋๋ง์ ๋ฐ์ ์ฌ์ ์ถ๊ฐ** โ ๋จ์ด์ฅ์ด ๊ฐ์ฅ ํจ๊ณผ์ ์ธ ๋ฐ์ ๊ต์ ์๋จ์
๋๋ค.") with gr.Row(): nw = gr.Textbox(label="๋จ์ด (2๊ธ์ ์ด์)") nw = gr.Textbox(label="๋จ์ด") np = gr.Textbox(label="์ํ๋ ๋ฐ์") with gr.Column(): btn_add = gr.Button("๐พ ์ ์ฉ ๋ฐ ๋ณํ", variant="primary") btn_clear_dict_inputs = gr.Button("๐งน ์
๋ ฅ์นธ ๋น์ฐ๊ธฐ", variant="secondary") status = gr.Textbox(label="์ ์ฅ ์ํ", interactive=False)
proc_inputs = [input_text, ai_mode, auto_break, smart_pause, breath_groups, font_size, user_temp_dict] proc_inputs = [input_text, ai_mode, auto_break, smart_pause, font_size, user_temp_dict] proc_outputs = [output_text, output_html, char_count, marker_collection]
btn_insert_marker.click(fn=None, inputs=[input_text], outputs=[input_text], js=insert_marker_js, api_name=False)1 unmodified line btn_conv.click(fn=process_text, inputs=proc_inputs, outputs=proc_outputs, api_name=False) btn_clr.click(fn=clear_all, outputs=[input_text, output_text, output_html, char_count, marker_collection], api_name=False) btn_copy.click(fn=None, inputs=[output_text], outputs=None, js="(t) => { if(t) { navigator.clipboard.writeText(t); alert('โ
๋ณต์ฌ ์๋ฃ!'); } }", api_name=False) btn_tts.click(fn=None, inputs=[output_text], outputs=None, js=tts_js, api_name=False) btn_tts_free.click(fn=tts_free_click, inputs=[output_text, user_temp_dict], outputs=[tts_audio, tts_status], api_name=False) btn_add.click(fn=add_and_update, inputs=[nw, np, user_role, input_text, ai_mode, auto_break, smart_pause, breath_groups, font_size, user_temp_dict], outputs=[status, output_text, output_html, char_count, marker_collection, user_temp_dict], api_name=False)
btn_add.click(fn=add_and_update, inputs=[nw, np, user_role, input_text, ai_mode, auto_break, smart_pause, font_size, user_temp_dict], outputs=[status, output_text, output_html, char_count, marker_collection, user_temp_dict], api_name=False) btn_clear_dict_inputs.click(fn=lambda: ("", ""), outputs=[nw, np], api_name=False) for evt in [font_size.change, ai_mode.change, auto_break.change, smart_pause.change, breath_groups.change]: for evt in [font_size.change, ai_mode.change, auto_break.change, smart_pause.change]: evt(fn=process_text, inputs=proc_inputs, outputs=proc_outputs, api_name=False) with gr.Tab("๐ฅ ์๋ ๋ฐฑ์
/์กฐํ/์์ "): dl_btn = gr.DownloadButton("๐ฅ 1. ์ฌ์ ๋ฐฑ์
(PC ๋ค์ด๋ก๋)") dl_btn.click(fn=get_file, outputs=[dl_btn], api_name=False)
gr.Markdown("---") btn_load_json = gr.Button("๐ 2. ๋ฑ๋ก๋ ๋จ์ด์ฅ ๋ถ๋ฌ์ค๊ธฐ", variant="secondary") json_input = gr.Textbox(lines=10, label="ํธ์ง์ฐฝ")
with gr.Row(): btn_apply_json = gr.Button("๐ ํ๋ฌ์ค(+) ํ๊ธฐ", variant="primary") btn_overwrite_json = gr.Button("๐จ ์์ ํ ๋ฎ์ด์ฐ๊ธฐ (์ด๋๋ฏผ ์ ์ฉ)", variant="stop") json_stat = gr.Textbox(label="์ํ ๊ฒฐ๊ณผ์ฐฝ", interactive=False)
btn_load_json.click(fn=load_current_json_to_text, inputs=[user_temp_dict], outputs=[json_input, json_stat], api_name=False) btn_apply_json.click(fn=apply_json_text, inputs=[json_input, user_role, user_temp_dict], outputs=[json_stat, user_temp_dict], api_name=False) btn_overwrite_json.click(fn=overwrite_json_text, inputs=[json_input, user_role], outputs=[json_stat], api_name=False)2 unmodified lines up_file = gr.File(label="๋ฐฑ์
ํ์ผ ์
๋ก๋", type="filepath") up_stat = gr.Textbox(label="์ํ ๊ฒฐ๊ณผ์ฐฝ", interactive=False) up_file.upload(fn=upload_file, inputs=[up_file, user_role, user_temp_dict], outputs=[up_stat, user_temp_dict], api_name=False) # ์ด๋ฒคํธ ์ฐ๊ฒฐ login_btn.click(fn=verify_login, inputs=[login_id, login_pw], outputs=[login_screen, main_app, user_role, login_msg, login_pw], api_name=False) btn_logout.click(fn=perform_logout, inputs=[], outputs=[login_screen, main_app, user_role, login_msg, login_id, login_pw, user_temp_dict], api_name=False) iface.load(fn=handle_page_load, inputs=[user_role], outputs=[login_screen, main_app, user_role, login_msg, login_id, login_pw], js=script_js)app.py+191-330