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;