Skip to content

Commit

Permalink
stop using gradio-i18n using i18n instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddycrack864 committed Jan 4, 2025
1 parent fb2a37b commit 51a0d43
Show file tree
Hide file tree
Showing 21 changed files with 1,807 additions and 1,630 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ You can donate to the original UVR5 project here:

## Credits
* python-audio-separator by [beveradb](https://github.com/beveradb).
* gradio-i18n by [hoveychen](https://github.com/hoveychen)
* Special thanks to [Ilaria](https://github.com/TheStingerX) for hosting this space and help 💖
* Thanks to [Mikus](https://github.com/cappuch) for the help with the code.
* Thanks to [Nick088](https://github.com/Nick088Official) for the help to fix roformers.
Expand Down
1,403 changes: 701 additions & 702 deletions app.py

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions assets/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"theme": {
"file": null,
"class": "NoCrypt/miku"
}
{
"theme": {
"file": null,
"class": "NoCrypt/miku"
},
"lang": {
"override": false,
"selected_lang": "en_US"
}
}
52 changes: 52 additions & 0 deletions assets/i18n/i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os, sys
import json
from pathlib import Path
from locale import getdefaultlocale

now_dir = os.getcwd()
sys.path.append(now_dir)


class I18nAuto:
LANGUAGE_PATH = os.path.join(now_dir, "assets", "i18n", "languages")

def __init__(self, language=None):
with open(
os.path.join(now_dir, "assets", "config.json"), "r", encoding="utf8"
) as file:
config = json.load(file)
override = config["lang"]["override"]
lang_prefix = config["lang"]["selected_lang"]

self.language = lang_prefix

if override == False:
language = language or getdefaultlocale()[0]
lang_prefix = language[:2] if language is not None else "en"
available_languages = self._get_available_languages()
matching_languages = [
lang for lang in available_languages if lang.startswith(lang_prefix)
]
self.language = matching_languages[0] if matching_languages else "en_US"

self.language_map = self._load_language_list()

def _load_language_list(self):
try:
file_path = Path(self.LANGUAGE_PATH) / f"{self.language}.json"
with open(file_path, "r", encoding="utf-8") as file:
return json.load(file)
except FileNotFoundError:
raise FileNotFoundError(
f"Failed to load language file for {self.language}. Check if the correct .json file exists."
)

def _get_available_languages(self):
language_files = [path.stem for path in Path(self.LANGUAGE_PATH).glob("*.json")]
return language_files

def _language_exists(self, language):
return (Path(self.LANGUAGE_PATH) / f"{language}.json").exists()

def __call__(self, key):
return self.language_map.get(key, key)
70 changes: 70 additions & 0 deletions assets/i18n/languages/en_US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"If you like UVR5 UI you can star my repo on [GitHub](https://github.com/Eddycrack864/UVR5-UI)": "If you like UVR5 UI you can star my repo on [GitHub](https://github.com/Eddycrack864/UVR5-UI)",
"Try UVR5 UI on Hugging Face with A100 [here](https://huggingface.co/spaces/TheStinger/UVR5_UI)": "Try UVR5 UI on Hugging Face with A100 [here](https://huggingface.co/spaces/TheStinger/UVR5_UI)",
"Select the model": "Select the model",
"Select the output format": "Select the output format",
"Overlap": "Overlap",
"Amount of overlap between prediction windows": "Amount of overlap between prediction windows",
"Segment size": "Segment size",
"Larger consumes more resources, but may give better results": "Larger consumes more resources, but may give better results",
"Input audio": "Input audio",
"Separation by link": "Separation by link",
"Link": "Link",
"Paste the link here": "Paste the link here",
"You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)": "You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)",
"Download!": "Download!",
"Batch separation": "Batch separation",
"Input path": "Input path",
"Place the input path here": "Place the input path here",
"Output path": "Output path",
"Place the output path here": "Place the output path here",
"Separate!": "Separate!",
"Output information": "Output information",
"Stem 1": "Stem 1",
"Stem 2": "Stem 2",
"Denoise": "Denoise",
"Enable denoising during separation": "Enable denoising during separation",
"Window size": "Window size",
"Agression": "Agression",
"Intensity of primary stem extraction": "Intensity of primary stem extraction",
"TTA": "TTA",
"Enable Test-Time-Augmentation; slow but improves quality": "Enable Test-Time-Augmentation; slow but improves quality",
"High end process": "High end process",
"Mirror the missing frequency range of the output": "Mirror the missing frequency range of the output",
"Shifts": "Shifts",
"Number of predictions with random shifts, higher = slower but better quality": "Number of predictions with random shifts, higher = slower but better quality",
"Stem 3": "Stem 3",
"Stem 4": "Stem 4",
"Themes": "Themes",
"Theme": "Theme",
"Select the theme you want to use. (Requires restarting the App)": "Select the theme you want to use. (Requires restarting the App)",
"Credits": "Credits",
"Language": "Language",
"Advanced settings": "Advanced settings",
"Override model default segment size instead of using the model default value": "Override model default segment size instead of using the model default value",
"Override segment size": "Override segment size",
"Batch size": "Batch size",
"Larger consumes more RAM but may process slightly faster": "Larger consumes more RAM but may process slightly faster",
"Normalization threshold": "Normalization threshold",
"The threshold for audio normalization": "The threshold for audio normalization",
"Amplification threshold": "Amplification threshold",
"The threshold for audio amplification": "The threshold for audio amplification",
"Hop length": "Hop length",
"Usually called stride in neural networks; only change if you know what you're doing": "Usually called stride in neural networks; only change if you know what you're doing",
"Balance quality and speed. 1024 = fast but lower, 320 = slower but better quality": "Balance quality and speed. 1024 = fast but lower, 320 = slower but better quality",
"Identify leftover artifacts within vocal output; may improve separation for some songs": "Identify leftover artifacts within vocal output; may improve separation for some songs",
"Post process": "Post process",
"Post process threshold": "Post process threshold",
"Threshold for post-processing": "Threshold for post-processing",
"Size of segments into which the audio is split. Higher = slower but better quality": "Size of segments into which the audio is split. Higher = slower but better quality",
"Enable segment-wise processing": "Enable segment-wise processing",
"Segment-wise processing": "Segment-wise processing",
"Stem 5": "Stem 5",
"Stem 6": "Stem 6",
"Output only single stem": "Output only single stem",
"Write the stem you want, check the stems of each model on Leaderboard. e.g. Instrumental": "Write the stem you want, check the stems of each model on Leaderboard. e.g. Instrumental",
"Leaderboard": "Leaderboard",
"List filter": "List filter",
"Filter and sort the model list by stem": "Filter and sort the model list by stem",
"Show list!": "Show list!"
}
70 changes: 70 additions & 0 deletions assets/i18n/languages/es_ES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"If you like UVR5 UI you can star my repo on [GitHub](https://github.com/Eddycrack864/UVR5-UI)": "Si te gusta UVR5 UI puedes darle una estrella a mi repo en [GitHub](https://github.com/Eddycrack864/UVR5-UI)",
"Try UVR5 UI on Hugging Face with A100 [here](https://huggingface.co/spaces/TheStinger/UVR5_UI)": "Prueba UVR5 UI en Hugging Face con una A100 [aquí](https://huggingface.co/spaces/TheStinger/UVR5_UI)",
"Select the model": "Selecciona el modelo",
"Select the output format": "Selecciona el formato de salida",
"Overlap": "Superposición",
"Amount of overlap between prediction windows": "Cantidad de superposición entre ventanas de predicción",
"Segment size": "Tamaño del segmento",
"Larger consumes more resources, but may give better results": "Un tamaño más grande consume más recursos, pero puede dar mejores resultados",
"Input audio": "Audio de entrada",
"Separation by link": "Separación por link",
"Link": "Link",
"Paste the link here": "Pega el link aquí",
"You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)": "Puedes pegar el enlace al video/audio desde muchos sitios, revisa la lista completa [aquí](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)",
"Download!": "Descargar!",
"Batch separation": "Separación por lotes",
"Input path": "Ruta de entrada",
"Place the input path here": "Coloca la ruta de entrada aquí",
"Output path": "Ruta de salida",
"Place the output path here": "Coloca la ruta de salida aquí",
"Separate!": "Separar!",
"Output information": "Información de la salida",
"Stem 1": "Pista 1",
"Stem 2": "Pista 2",
"Denoise": "Eliminación de ruido",
"Enable denoising during separation": "Habilitar la eliminación de ruido durante la separación",
"Window size": "Tamaño de la ventana",
"Agression": "Agresión",
"Intensity of primary stem extraction": "Intensidad de extracción de la pista primaria",
"TTA": "TTA",
"Enable Test-Time-Augmentation; slow but improves quality": "Habilitar Aumento del Tiempo de Prueba; lento pero mejora la calidad",
"High end process": "Procesamiento de alto rendimiento",
"Mirror the missing frequency range of the output": "Reflejar el rango de frecuencia faltante de la salida",
"Shifts": "Desplazamientos temporales",
"Number of predictions with random shifts, higher = slower but better quality": "Número de predicciones con desplazamientos temporales, mayor = más lento pero mejor calidad",
"Stem 3": "Pista 3",
"Stem 4": "Pista 4",
"Themes": "Temas",
"Theme": "Tema",
"Select the theme you want to use. (Requires restarting the App)": "Selecciona el tema que deseas utilizar. (Requiere reiniciar la aplicación)",
"Credits": "Créditos",
"Language": "Idioma",
"Advanced settings": "Configuración avanzada",
"Override model default segment size instead of using the model default value": "Anular el tamaño del segmento predeterminado del modelo en lugar de usar el valor predeterminado del modelo",
"Override segment size": "Anular tamaño del segmento",
"Batch size": "Tamaño del lote",
"Larger consumes more RAM but may process slightly faster": "Más grande consume más RAM pero puede procesar un poco más rápido",
"Normalization threshold": "Umbral de normalización",
"The threshold for audio normalization": "El umbral para la normalización del audio",
"Amplification threshold": "Umbral de amplificación",
"The threshold for audio amplification": "El umbral para la amplificación de audio",
"Hop length": "Longitud del salto",
"Usually called stride in neural networks; only change if you know what you're doing" : "Generalmente llamado paso en redes neuronales; solo cambialo si sabes lo que estás haciendo",
"Balance quality and speed. 1024 = fast but lower, 320 = slower but better quality": "Equilibra la calidad y la velocidad. 1024 = más rápido pero de menor calidad, 320 = más lento pero de mejor calidad",
"Identify leftover artifacts within vocal output; may improve separation for some songs": "Identifica artefactos sobrantes en la salida vocal; puede mejorar la separación de algunas canciones",
"Post process": "Posproceso",
"Post process threshold": "Umbral de posproceso",
"Threshold for post-processing": "Umbral para el posprocesamiento",
"Size of segments into which the audio is split. Higher = slower but better quality": "Tamaño de los segmentos en los que se divide el audio. Más alto = más lento pero de mejor calidad",
"Enable segment-wise processing": "Habilitar el procesamiento por segmentos",
"Segment-wise processing": "Procesamiento por segmentos",
"Stem 5": "Pista 5",
"Stem 6": "Pista 6",
"Output only single stem": "Salida de única pista",
"Write the stem you want, check the stems of each model on Leaderboard. e.g. Instrumental": "Escribe la pista que quieres, consulta las pistas de cada modelo en la tabla de clasificación. Por ejemplo, Instrumental",
"Leaderboard": "Tabla de clasificación",
"List filter": "Lista de filtros",
"Filter and sort the model list by stem": "Filtra y ordena la lista de modelos por pista",
"Show list!": "Mostrar lista!"
}
Loading

0 comments on commit 51a0d43

Please sign in to comment.