()
| 11 | return val |
| 12 | |
| 13 | def page_setting(): |
| 14 | |
| 15 | display_language = st.selectbox("Display Language 🌐", |
| 16 | options=list(DISPLAY_LANGUAGES.keys()), |
| 17 | index=list(DISPLAY_LANGUAGES.values()).index(load_key("display_language"))) |
| 18 | if DISPLAY_LANGUAGES[display_language] != load_key("display_language"): |
| 19 | update_key("display_language", DISPLAY_LANGUAGES[display_language]) |
| 20 | st.rerun() |
| 21 | |
| 22 | # with st.expander(t("Youtube Settings"), expanded=True): |
| 23 | # config_input(t("Cookies Path"), "youtube.cookies_path") |
| 24 | |
| 25 | with st.expander(t("LLM Configuration"), expanded=True): |
| 26 | config_input(t("API_KEY"), "api.key") |
| 27 | config_input(t("BASE_URL"), "api.base_url", help=t("Openai format, will add /v1/chat/completions automatically")) |
| 28 | |
| 29 | c1, c2 = st.columns([4, 1]) |
| 30 | with c1: |
| 31 | config_input(t("MODEL"), "api.model", help=t("click to check API validity")+ " 👉") |
| 32 | with c2: |
| 33 | if st.button("📡", key="api"): |
| 34 | st.toast(t("API Key is valid") if check_api() else t("API Key is invalid"), |
| 35 | icon="✅" if check_api() else "❌") |
| 36 | llm_support_json = st.toggle(t("LLM JSON Format Support"), value=load_key("api.llm_support_json"), help=t("Enable if your LLM supports JSON mode output")) |
| 37 | if llm_support_json != load_key("api.llm_support_json"): |
| 38 | update_key("api.llm_support_json", llm_support_json) |
| 39 | st.rerun() |
| 40 | with st.expander(t("Subtitles Settings"), expanded=True): |
| 41 | c1, c2 = st.columns(2) |
| 42 | with c1: |
| 43 | langs = { |
| 44 | "🇺🇸 English": "en", |
| 45 | "🇨🇳 简体中文": "zh", |
| 46 | "🇪🇸 Español": "es", |
| 47 | "🇷🇺 Русский": "ru", |
| 48 | "🇫🇷 Français": "fr", |
| 49 | "🇩🇪 Deutsch": "de", |
| 50 | "🇮🇹 Italiano": "it", |
| 51 | "🇯🇵 日本語": "ja" |
| 52 | } |
| 53 | lang = st.selectbox( |
| 54 | t("Recog Lang"), |
| 55 | options=list(langs.keys()), |
| 56 | index=list(langs.values()).index(load_key("whisper.language")) |
| 57 | ) |
| 58 | if langs[lang] != load_key("whisper.language"): |
| 59 | update_key("whisper.language", langs[lang]) |
| 60 | st.rerun() |
| 61 | |
| 62 | runtime = st.selectbox(t("WhisperX Runtime"), options=["local", "cloud", "elevenlabs"], index=["local", "cloud", "elevenlabs"].index(load_key("whisper.runtime")), help=t("Local runtime requires >8GB GPU, cloud runtime requires 302ai API key, elevenlabs runtime requires ElevenLabs API key")) |
| 63 | if runtime != load_key("whisper.runtime"): |
| 64 | update_key("whisper.runtime", runtime) |
| 65 | st.rerun() |
| 66 | if runtime == "cloud": |
| 67 | config_input(t("WhisperX 302ai API"), "whisper.whisperX_302_api_key") |
| 68 | if runtime == "elevenlabs": |
| 69 | config_input(("ElevenLabs API"), "whisper.elevenlabs_api_key") |
| 70 |
no test coverage detected