Adds WhisperX, reworks UI (still needs some work), theoretically usable

This commit is contained in:
Guillaume Tâche
2024-08-17 22:05:04 +02:00
parent 7bddf53bab
commit 3fa51eb95b
204 changed files with 4787 additions and 1321 deletions
@@ -1,35 +1,52 @@
package com.github.gtache.autosubtitle.gui.impl;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
/**
* Combines multiple resource bundles
*/
public class CombinedResourceBundle extends ResourceBundle {
private static final Logger logger = LogManager.getLogger(CombinedResourceBundle.class);
private final Map<String, String> resources;
private final Locale locale;
public CombinedResourceBundle(final ResourceBundle... bundles) {
this(Arrays.asList(bundles));
public CombinedResourceBundle(final ResourceBundle... resourceBundles) {
this(Arrays.asList(resourceBundles));
}
public CombinedResourceBundle(final Iterable<ResourceBundle> bundles) {
public CombinedResourceBundle(final List<ResourceBundle> resourceBundles) {
final var filteredBundles = resourceBundles.stream().filter(Objects::nonNull).toList();
if (filteredBundles.size() != resourceBundles.size()) {
logger.warn("There was one or more null bundles in the inner bundles");
}
if (filteredBundles.isEmpty()) {
throw new IllegalArgumentException("The bundle should contain at least one bundle");
}
this.resources = new HashMap<>();
bundles.forEach(rb -> rb.getKeys().asIterator().forEachRemaining(key -> resources.put(key, rb.getString(key))));
filteredBundles.forEach(r -> r.keySet().forEach(s -> resources.put(s, r.getString(s))));
this.locale = filteredBundles.getFirst().getLocale();
}
@Override
protected Object handleGetObject(final String key) {
return resources.get(key);
public Object handleGetObject(final String key) {
if (resources.containsKey(key)) {
return resources.get(key);
} else {
throw new MissingResourceException(key + " not found", "CombinedResourceBundle", key);
}
}
@Override
public Enumeration<String> getKeys() {
return Collections.enumeration(resources.keySet());
}
@Override
public Locale getLocale() {
return locale;
}
}
@@ -0,0 +1,9 @@
package com.github.gtache.autosubtitle.gui.impl.spi;
import java.util.spi.ResourceBundleProvider;
/**
* Provider for SubtitlesBundle
*/
public interface SubtitlesBundleProvider extends ResourceBundleProvider {
}
@@ -0,0 +1,9 @@
package com.github.gtache.autosubtitle.gui.impl.spi;
import java.util.spi.AbstractResourceBundleProvider;
/**
* Implementation of {@link SubtitlesBundleProvider}
*/
public class SubtitlesBundleProviderImpl extends AbstractResourceBundleProvider implements SubtitlesBundleProvider {
}
@@ -23,6 +23,7 @@ public final class GuiCoreModule {
ResourceBundle.getBundle("com.github.gtache.autosubtitle.gui.impl.SetupBundle"),
ResourceBundle.getBundle("com.github.gtache.autosubtitle.gui.impl.WorkBundle"),
ResourceBundle.getBundle("com.github.gtache.autosubtitle.gui.impl.ParametersBundle"),
ResourceBundle.getBundle("com.github.gtache.autosubtitle.gui.impl.SubtitlesBundle"),
ResourceBundle.getBundle("com.github.gtache.autosubtitle.gui.impl.MediaBundle"));
}
+1
View File
@@ -13,6 +13,7 @@ import com.github.gtache.autosubtitle.gui.impl.spi.WorkBundleProviderImpl;
module com.github.gtache.autosubtitle.gui.core {
requires transitive com.github.gtache.autosubtitle.gui.api;
requires transitive com.github.gtache.autosubtitle.core;
requires org.apache.logging.log4j;
exports com.github.gtache.autosubtitle.gui.impl;
exports com.github.gtache.autosubtitle.gui.impl.spi;
exports com.github.gtache.autosubtitle.modules.gui.impl;
@@ -0,0 +1,14 @@
subtitles.button.load.label=Load subtitles...
subtitles.button.reset.label=Reset subtitles
subtitles.button.subtitles.save.label=Save subtitles...
subtitles.export.error.label=Error during the export : {0}
subtitles.export.error.title=Error exporting
subtitles.language.label=Video language
subtitles.load.error.label=Error loading subtitles : {0}
subtitles.load.error.title=Error loading
subtitles.save.error.label=Error saving subtitles : {0}
subtitles.save.error.title=Error saving
subtitles.table.column.from.label=From
subtitles.table.column.text.label=Text
subtitles.table.column.to.label=To
subtitles.translate.label=Automatic translations
@@ -0,0 +1,14 @@
subtitles.button.load.label=Charger des sous-titres...
subtitles.button.reset.label=R\u00E9initialiser les sous-titres
subtitles.button.subtitles.save.label=Sauvegarder les sous-titres...
subtitles.export.error.label=Erreur durant l''export : {0}
subtitles.export.error.title=Erreur d'export
subtitles.language.label=Langage de la vid\u00E9o
subtitles.load.error.label=Erreur de chargement des sous-titres : {0}
subtitles.load.error.title=Erreur de chargement
subtitles.save.error.label=Erreur de sauvegarde des sous-titres : {0}
subtitles.save.error.title=Erreur lors de la sauvegarde
subtitles.table.column.from.label=De
subtitles.table.column.text.label=Texte
subtitles.table.column.to.label=\u00C0
subtitles.translate.label=Traductions
@@ -4,27 +4,13 @@ work.button.export.soft.label=Export video...
work.button.export.soft.tooltip=Adds the subtitles to the video. This allows a video to have multiple subtitles and to enable them at will.
work.button.extract.label=Extract subtitles
work.button.file.label=Open video...
work.button.load.label=Load subtitles...
work.button.reset.label=Reset subtitles
work.button.subtitles.save.label=Save subtitles...
work.export.error.label=Error during the export : {0}
work.export.error.title=Error exporting
work.extract.error.label=Error extracting subtitles : {0}
work.extract.error.title=Error extracting
work.language.label=Video language
work.load.subtitles.error.label=Error loading subtitles : {0}
work.load.subtitles.error.title=Error loading
work.load.video.error.label=Error loading video : {0}
work.load.video.error.title=Error loading
work.save.subtitles.error.label=Error saving subtitles : {0}
work.save.subtitles.error.title=Error saving
work.save.subtitles.missing.converter.label=No converter found for {0}
work.save.subtitles.missing.converter.title=No converter found
work.status.exporting.label=Exporting...
work.status.extracting.label=Extracting...
work.status.idle.label=Idle
work.status.translating.label=Translating...
work.table.column.from.label=From
work.table.column.text.label=Text
work.table.column.to.label=To
work.translate.label=Automatic translations
work.status.translating.label=Translating...
@@ -4,25 +4,13 @@ work.button.export.soft.label=Exporter la vid\u00E9o...
work.button.export.soft.tooltip=Ajoute les sous-titres \u00E0 la vid\u00E9o. Cela permet d'avoir plusieurs pistes de sous-titres dans une m\u00EAme vid\u00E9o et de les activer comme d\u00E9sir\u00E9.
work.button.extract.label=Extraire les sous-titres
work.button.file.label=Ouvrir une vid\u00E9o...
work.button.load.label=Charger des sous-titres...
work.button.reset.label=R\u00E9initialiser les sous-titres
work.button.subtitles.save.label=Sauvegarder les sous-titres...
work.export.error.label=Erreur durant l''export : {0}
work.export.error.title=Erreur d'export
work.extract.error.label=Erreur durant l''extraction des sous-titres : {0}
work.extract.error.title=Erreur d'extraction
work.language.label=Language de la vid\u00E9o
work.load.subtitles.error.label=Erreur de chargement des sous-titres : {0}
work.load.subtitles.error.title=Erreur de chargement
work.load.video.error.label=Erreur lors du chargement de la vid\u00E9o : {0}
work.load.video.error.title=Erreur de chargement
work.save.subtitles.missing.converter.label=Aucun convertisseur trouv\u00E9 pour {0}
work.save.subtitles.missing.converter.title=Aucun convertisseur trouv\u00E9
work.status.exporting.label=Exportation en cours...
work.status.extracting.label=Extraction en cours...
work.status.idle.label=Idle
work.status.translating.label=Traduction en cours...
work.table.column.from.label=De
work.table.column.text.label=Texte
work.table.column.to.label=\u00C0
work.translate.label=Traductions automatiques