List<MaryModule> candidates = getPreferredModulesForInputType(sourceType); candidates = voice.getPreferredModulesAcceptingType(sourceType); if (candidates == null || candidates.isEmpty()) { // default: use all available modules candidates = get(sourceType, locale, voice); + " (locale " + locale + ", voice " + voice + ")"); LinkedList<MaryModule> path = modulesRequiredForProcessing(outputType, targetType, locale, voice, seenTypes); if (path != null) {
private static void startModules() throws ClassNotFoundException, InstantiationException, Exception { for (String moduleClassName : MaryProperties.moduleInitInfo()) { MaryModule m = ModuleRegistry.instantiateModule(moduleClassName); ModuleRegistry.registerModule(m, m.getLocale(), null); ModuleRegistry.setRegistrationComplete(); for (MaryModule m : ModuleRegistry.getAllModules()) {
/** * Indicate that the registration is now complete. No further calls to registerModules() will be possible. * * @throws IllegalStateException * if called when registration was already completed before. */ public static void setRegistrationComplete() throws IllegalStateException { if (registrationComplete) throw new IllegalStateException("Registration has already completed, cannot do that a second time"); // Set registration complete lockup registrationComplete = true; MaryDataType.setRegistrationComplete(); // Define system preferred modules List<String> preferredModulesClasses = MaryProperties.getList("modules.preferred.classes.list"); if ((preferredModulesClasses == null) || (preferredModulesClasses.isEmpty())) return; preferredModules = new ArrayList<MaryModule>(); for (String moduleInfo : preferredModulesClasses) { try { MaryModule mm = null; if (!moduleInfo.contains("(")) { // no constructor info mm = ModuleRegistry.getModule(Class.forName(moduleInfo)); } preferredModules.add(mm); } catch (ClassNotFoundException e) { logger.warn("Cannot initialise preferred module " + moduleInfo + " -- skipping.", e); } } }
MaryModule mm = null; if (!moduleInfo.contains("(")) { // no constructor info mm = ModuleRegistry.getModule(Class.forName(moduleInfo)); + moduleInfo + " is not in the standard list of modules -- will start our own, but will not be able to shut it down at the end."); mm = ModuleRegistry.instantiateModule(moduleInfo); mm.startup();
/** * A method for determining the list of modules required to transform the given source data type into the requested target * data type. * * @param sourceType * sourceType * @param targetType * targetType * @param locale * locale * @return the (ordered) list of modules required, or null if no such list could be found. * @throws IllegalStateException * if called while registration is not yet complete. * @throws NullPointerException * if source data type, target data type or locale is null. */ public static LinkedList<MaryModule> modulesRequiredForProcessing(MaryDataType sourceType, MaryDataType targetType, Locale locale) { return modulesRequiredForProcessing(sourceType, targetType, locale, null); }
@Test public void testSystemPreferredModuleOverride() throws Exception { List<MaryModule> mod = ModuleRegistry.getPreferredModulesForInputType(MaryDataType.TEXT); assertNotNull(mod); assert (!mod.isEmpty()); assertEquals(mod.get(0).name(), "Dummy"); } }
@Before public void setUp() throws Exception { Properties props = System.getProperties(); props.setProperty("modules.preferred.classes.list", "marytts.modules.DummyModule"); ModuleRegistry.registerModule(new DummyModule(), null, null); mary = new LocalMaryInterface(); }
/** * Orderly shut down the MARY system. * * @throws IllegalStateException * if the MARY system is not running. */ public static void shutdown() { if (currentState != STATE_RUNNING) throw new IllegalStateException("MARY system is not running"); currentState = STATE_SHUTTING_DOWN; logger.info("Shutting down modules..."); // Shut down modules: for (MaryModule m : ModuleRegistry.getAllModules()) { if (m.getState() == MaryModule.MODULE_RUNNING) m.shutdown(); } if (MaryCache.haveCache()) { MaryCache cache = MaryCache.getCache(); try { cache.shutdown(); } catch (SQLException e) { logger.warn("Cannot shutdown cache: ", e); } } logger.info("Shutdown complete."); currentState = STATE_OFF; }
/** * A method for determining the list of modules required to transform the given source data type into the requested target * data type. * * @param sourceType * sourceType * @param targetType * targetType * @param locale * locale * @return the (ordered) list of modules required, or null if no such list could be found. * @throws IllegalStateException * if called while registration is not yet complete. * @throws NullPointerException * if source data type, target data type or locale is null. */ public static LinkedList<MaryModule> modulesRequiredForProcessing(MaryDataType sourceType, MaryDataType targetType, Locale locale) { return modulesRequiredForProcessing(sourceType, targetType, locale, null); }
MaryModule mm = null; if (!moduleInfo.contains("(")) { // no constructor info mm = ModuleRegistry.getModule(Class.forName(moduleInfo)); + moduleInfo + " is not in the standard list of modules -- will start our own, but will not be able to shut it down at the end."); mm = ModuleRegistry.instantiateModule(moduleInfo); mm.startup();
@Test public void testSystemPreferredModuleOverride() throws Exception { List<MaryModule> mod = ModuleRegistry.getPreferredModulesForInputType(MaryDataType.TEXT); assertNotNull(mod); assert (!mod.isEmpty()); assertEquals(mod.get(0).name(), "Dummy"); } }
@Before public void setUp() throws Exception { Properties props = System.getProperties(); props.setProperty("modules.preferred.classes.list", "marytts.modules.DummyModule"); ModuleRegistry.registerModule(new DummyModule(), null, null); mary = new LocalMaryInterface(); }
/** * Orderly shut down the MARY system. * * @throws IllegalStateException * if the MARY system is not running. */ public static void shutdown() { if (currentState != STATE_RUNNING) throw new IllegalStateException("MARY system is not running"); currentState = STATE_SHUTTING_DOWN; logger.info("Shutting down modules..."); // Shut down modules: for (MaryModule m : ModuleRegistry.getAllModules()) { if (m.getState() == MaryModule.MODULE_RUNNING) m.shutdown(); } if (MaryCache.haveCache()) { MaryCache cache = MaryCache.getCache(); try { cache.shutdown(); } catch (SQLException e) { logger.warn("Cannot shutdown cache: ", e); } } logger.info("Shutdown complete."); currentState = STATE_OFF; }
private static void startModules() throws ClassNotFoundException, InstantiationException, Exception { for (String moduleClassName : MaryProperties.moduleInitInfo()) { MaryModule m = ModuleRegistry.instantiateModule(moduleClassName); ModuleRegistry.registerModule(m, m.getLocale(), null); ModuleRegistry.setRegistrationComplete(); for (MaryModule m : ModuleRegistry.getAllModules()) {
List<MaryModule> candidates = getPreferredModulesForInputType(sourceType); candidates = voice.getPreferredModulesAcceptingType(sourceType); if (candidates == null || candidates.isEmpty()) { // default: use all available modules candidates = get(sourceType, locale, voice); + " (locale " + locale + ", voice " + voice + ")"); LinkedList<MaryModule> path = modulesRequiredForProcessing(outputType, targetType, locale, voice, seenTypes); if (path != null) {
/** * Indicate that the registration is now complete. No further calls to registerModules() will be possible. * * @throws IllegalStateException * if called when registration was already completed before. */ public static void setRegistrationComplete() throws IllegalStateException { if (registrationComplete) throw new IllegalStateException("Registration has already completed, cannot do that a second time"); // Set registration complete lockup registrationComplete = true; MaryDataType.setRegistrationComplete(); // Define system preferred modules List<String> preferredModulesClasses = MaryProperties.getList("modules.preferred.classes.list"); if ((preferredModulesClasses == null) || (preferredModulesClasses.isEmpty())) return; preferredModules = new ArrayList<MaryModule>(); for (String moduleInfo : preferredModulesClasses) { try { MaryModule mm = null; if (!moduleInfo.contains("(")) { // no constructor info mm = ModuleRegistry.getModule(Class.forName(moduleInfo)); } preferredModules.add(mm); } catch (ClassNotFoundException e) { logger.warn("Cannot initialise preferred module " + moduleInfo + " -- skipping.", e); } } }
return modulesRequiredForProcessing(sourceType, targetType, locale, voice, seenTypes);
MaryModule mm = null; if (!moduleInfo.contains("(")) { // no constructor info mm = ModuleRegistry.getModule(Class.forName(moduleInfo)); + moduleInfo + " is not in the standard list of modules -- will start our own, but will not be able to shut it down at the end."); mm = ModuleRegistry.instantiateModule(moduleInfo); mm.startup();
/** * Orderly shut down the MARY system. * * @throws IllegalStateException * if the MARY system is not running. */ public static void shutdown() { if (currentState != STATE_RUNNING) throw new IllegalStateException("MARY system is not running"); currentState = STATE_SHUTTING_DOWN; logger.info("Shutting down modules..."); // Shut down modules: for (MaryModule m : ModuleRegistry.getAllModules()) { if (m.getState() == MaryModule.MODULE_RUNNING) m.shutdown(); } if (MaryCache.haveCache()) { MaryCache cache = MaryCache.getCache(); try { cache.shutdown(); } catch (SQLException e) { logger.warn("Cannot shutdown cache: ", e); } } logger.info("Shutdown complete."); currentState = STATE_OFF; }
private static void startModules() throws ClassNotFoundException, InstantiationException, Exception { for (String moduleClassName : MaryProperties.moduleInitInfo()) { MaryModule m = ModuleRegistry.instantiateModule(moduleClassName); ModuleRegistry.registerModule(m, m.getLocale(), null); ModuleRegistry.setRegistrationComplete(); for (MaryModule m : ModuleRegistry.getAllModules()) {