()
| 141 | return f"{INDEX}/cu126" |
| 142 | |
| 143 | def main(): |
| 144 | install_package("requests", "rich", "ruamel.yaml", "InquirerPy") |
| 145 | from rich.console import Console |
| 146 | from rich.panel import Panel |
| 147 | from rich.box import DOUBLE |
| 148 | from InquirerPy import inquirer |
| 149 | from translations.translations import translate as t |
| 150 | from translations.translations import DISPLAY_LANGUAGES |
| 151 | from core.utils.config_utils import load_key, update_key |
| 152 | from core.utils.decorator import except_handler |
| 153 | |
| 154 | console = Console() |
| 155 | |
| 156 | width = max(len(line) for line in ascii_logo.splitlines()) + 4 |
| 157 | welcome_panel = Panel( |
| 158 | ascii_logo, |
| 159 | width=width, |
| 160 | box=DOUBLE, |
| 161 | title="[bold green]🌏[/bold green]", |
| 162 | border_style="bright_blue" |
| 163 | ) |
| 164 | console.print(welcome_panel) |
| 165 | # Language selection |
| 166 | current_language = load_key("display_language") |
| 167 | # Find the display name for current language code |
| 168 | current_display = next((k for k, v in DISPLAY_LANGUAGES.items() if v == current_language), "🇬🇧 English") |
| 169 | selected_language = DISPLAY_LANGUAGES[inquirer.select( |
| 170 | message="Select language / 选择语言 / 選擇語言 / 言語を選択 / Seleccionar idioma / Sélectionner la langue / Выберите язык:", |
| 171 | choices=list(DISPLAY_LANGUAGES.keys()), |
| 172 | default=current_display |
| 173 | ).execute()] |
| 174 | update_key("display_language", selected_language) |
| 175 | |
| 176 | console.print(Panel.fit(t("🚀 Starting Installation"), style="bold magenta")) |
| 177 | |
| 178 | # Configure mirrors |
| 179 | # add a check to ask user if they want to configure mirrors |
| 180 | if inquirer.confirm( |
| 181 | message=t("Do you need to auto-configure PyPI mirrors? (Recommended if you have difficulty accessing pypi.org)"), |
| 182 | default=True |
| 183 | ).execute(): |
| 184 | from core.utils.pypi_autochoose import main as choose_mirror |
| 185 | choose_mirror() |
| 186 | |
| 187 | # Detect system and GPU |
| 188 | has_gpu = platform.system() != 'Darwin' and check_nvidia_gpu() |
| 189 | if has_gpu: |
| 190 | console.print(Panel(t("🎮 NVIDIA GPU detected, installing CUDA version of PyTorch..."), style="cyan")) |
| 191 | cuda_index = _detect_cuda_index() |
| 192 | console.print(f"[cyan]📦 Using PyTorch index:[/cyan] {cuda_index}") |
| 193 | subprocess.check_call([sys.executable, "-m", "pip", "install", "torch==2.8.0", "torchaudio==2.8.0", "--index-url", cuda_index]) |
| 194 | else: |
| 195 | system_name = "🍎 MacOS" if platform.system() == 'Darwin' else "💻 No NVIDIA GPU" |
| 196 | console.print(Panel(t(f"{system_name} detected, installing CPU version of PyTorch... Note: it might be slow during whisperX transcription."), style="cyan")) |
| 197 | subprocess.check_call([sys.executable, "-m", "pip", "install", "torch==2.8.0", "torchaudio==2.8.0"]) |
| 198 | |
| 199 | @except_handler("Failed to install project") |
| 200 | def install_requirements(): |
no test coverage detected