|
| 1 | +import os |
| 2 | +import sys |
| 3 | +from pathlib import Path |
| 4 | +import random |
| 5 | +import requests |
| 6 | + |
| 7 | + |
| 8 | +current_dir = os.path.dirname(os.path.abspath(__file__)) |
| 9 | +parent_dir = os.path.dirname(current_dir) |
| 10 | +sys.path.append(parent_dir) |
| 11 | + |
| 12 | +matcha_dir = os.path.join(parent_dir, 'third_party', 'Matcha-TTS') |
| 13 | +sys.path.append(matcha_dir) |
| 14 | + |
| 15 | + |
| 16 | +import platform |
| 17 | +import torch |
| 18 | +import gradio as gr |
| 19 | +from src.config import UserConfig |
| 20 | + |
| 21 | +import src.ui as ui |
| 22 | +from src.i18n.i18n import I18nAuto |
| 23 | +i18n = I18nAuto() |
| 24 | + |
| 25 | +import structlog |
| 26 | +import logging |
| 27 | + |
| 28 | +logging.getLogger("httpx").setLevel(logging.WARNING) |
| 29 | +logging.getLogger("httpcore").setLevel(logging.WARNING) |
| 30 | +logging.getLogger("fairseq").setLevel(logging.WARNING) |
| 31 | +logging.getLogger("azure.core").setLevel(logging.WARNING) |
| 32 | +logging.getLogger("faster_whisper").setLevel(logging.DEBUG) |
| 33 | + |
| 34 | +logging.getLogger('matplotlib').setLevel(logging.WARNING) |
| 35 | + |
| 36 | + |
| 37 | +level = os.environ.get("LOG_LEVEL", "INFO").upper() |
| 38 | +LOG_LEVEL = getattr(logging, level) |
| 39 | +structlog.configure( |
| 40 | + wrapper_class=structlog.make_filtering_bound_logger(logging.DEBUG) |
| 41 | +) |
| 42 | +logger = structlog.get_logger() |
| 43 | + |
| 44 | + |
| 45 | +from app.abus_genuine import * |
| 46 | +from app.tab_gulliver import gulliver_tab |
| 47 | +from app.tab_subtitle import subtitle_tab |
| 48 | +from app.tab_tts_edge import tts_edge_tab |
| 49 | +from app.tab_tts_f5_single import tts_f5_single_tab |
| 50 | +from app.tab_tts_f5_multi import tts_f5_multi_tab |
| 51 | +from app.tab_tts_cosyvoice import tts_cosyvoice_tab |
| 52 | +from app.tab_tts_kokoro import tts_kokoro_tab |
| 53 | +from app.tab_translate import translate_tab |
| 54 | +from app.tab_live_translate import live_translate_tab |
| 55 | +from app.tab_vsr import vsr_tab |
| 56 | +from app.tab_aicover import aicover_tab |
| 57 | +from app.tab_demixing import demixing_tab |
| 58 | +from app.tab_tts_rvc import tts_rvc_tab |
| 59 | +from app.tab_rvc import rvc_tab |
| 60 | +from app.tab_batch_tts import batch_tts_tab |
| 61 | + |
| 62 | + |
| 63 | +############################################################################################## |
| 64 | +# Gradio |
| 65 | +############################################################################################## |
| 66 | + |
| 67 | + |
| 68 | +def create_ui(user_config: UserConfig): |
| 69 | + # css/js strings |
| 70 | + css = ui.css |
| 71 | + js = ui.js |
| 72 | + |
| 73 | + with gr.Blocks(title='Voice Gulliver', css=css, theme=ui.theme) as gradio_interface: |
| 74 | + gr.HTML(f'<center><h6>{i18n("")}</h6></center>') |
| 75 | + |
| 76 | + with gr.Tab(i18n("Dubbing Studio")): |
| 77 | + gulliver_tab(user_config) |
| 78 | + |
| 79 | + with gr.Tab(i18n("Whisper subtitles")): |
| 80 | + subtitle_tab(user_config) |
| 81 | + |
| 82 | + with gr.Tab(i18n("Translation")): |
| 83 | + with gr.Tabs(): |
| 84 | + with gr.Tab(i18n("VOD")): |
| 85 | + translate_tab(user_config) |
| 86 | + with gr.Tab(i18n("Live")): |
| 87 | + live_translate_tab(user_config) |
| 88 | + |
| 89 | + with gr.Tab(i18n("Speech Generation")): |
| 90 | + with gr.Tabs(): |
| 91 | + tab_name = i18n('Azure-TTS') if azure_text_api_working() else i18n('Edge-TTS') |
| 92 | + with gr.Tab(tab_name): |
| 93 | + tts_edge_tab(user_config) |
| 94 | + with gr.Tab(i18n("F5-TTS (Single)")): |
| 95 | + tts_f5_single_tab(user_config) |
| 96 | + with gr.Tab(i18n("F5-TTS (Multi)")): |
| 97 | + tts_f5_multi_tab(user_config) |
| 98 | + with gr.Tab(i18n("CosyVoice")): |
| 99 | + tts_cosyvoice_tab(user_config) |
| 100 | + with gr.Tab(i18n("kokoro")): |
| 101 | + tts_kokoro_tab(user_config) |
| 102 | + |
| 103 | + with gr.Tab(i18n("AI Cover")): |
| 104 | + with gr.Tabs(): |
| 105 | + with gr.Tab(i18n("Cover Studio")): |
| 106 | + aicover_tab(user_config) |
| 107 | + with gr.Tab(i18n("Demixing")): |
| 108 | + demixing_tab(user_config) |
| 109 | + |
| 110 | + with gr.Tab(i18n("Batch processing")): |
| 111 | + batch_tts_tab(user_config) |
| 112 | + |
| 113 | + with gr.Tab(i18n("RVC")): |
| 114 | + rvc_tab(user_config) |
| 115 | + |
| 116 | + with gr.Tab(i18n("TTS + RVC")): |
| 117 | + tts_rvc_tab(user_config) |
| 118 | + |
| 119 | + with gr.Tab(i18n("NVIDIA RTX")): |
| 120 | + vsr_tab(user_config) |
| 121 | + |
| 122 | + create_app_footer() |
| 123 | + |
| 124 | + gradio_interface.load(None, None, None, js="() => document.getElementsByTagName('body')[0].classList.add('dark')") |
| 125 | + gradio_interface.load(None, None, None, js=f"() => {{{js}}}") |
| 126 | + |
| 127 | + |
| 128 | + gradio_interface.launch( |
| 129 | + share=False, |
| 130 | + server_name=None, |
| 131 | + server_port=7860, |
| 132 | + inbrowser=True |
| 133 | + ) |
| 134 | + |
| 135 | +def create_app_footer(): |
| 136 | + gradio_version = gr.__version__ |
| 137 | + python_version = platform.python_version() |
| 138 | + torch_version = torch.__version__ |
| 139 | + |
| 140 | + footer_items = ["🔊 [voice-gulliver](https://github.com/abus-aikorea/voice-gulliver)"] |
| 141 | + footer_items.append(f"python: `{python_version}`") |
| 142 | + footer_items.append(f"torch: `{torch_version}`") |
| 143 | + footer_items.append(f"gradio: `{gradio_version}`") |
| 144 | + |
| 145 | + genuine = "activated version" |
| 146 | + footer_items.append(f"{genuine}") |
| 147 | + |
| 148 | + gr.Markdown( |
| 149 | + " | ".join(footer_items), |
| 150 | + elem_classes=["no-translate"], |
| 151 | + ) |
| 152 | + |
| 153 | + |
0 commit comments