[mary-dev] Improving Mary TTS for use as a component in larger systems

H.vanWelbergen at ewi.utwente.nl H.vanWelbergen at ewi.utwente.nl
Tue Jun 1 17:37:21 CEST 2010


We are currently using Mary TTS as one of the speech synthesis systems
within our BML realizer Elckerlyc
(http://hmi.ewi.utwente.nl/showcase/Elckerlyc). It would be very nice if
you could make the following changes to startup and logging to
accommodate such embedding of Mary TTS in a better way:
- Create a Mary.startup() that does not call addJarsToClasspath(), in
larger systems, this method is jar file clash prone. I'd prefer to keep
track of my own jar files. 
- I'd prefer the logging to write to "marytts.main",
"marytts.ModuleRegistry" etc, rather than to "main", "ModuleRegistry",
... This would help me to embed the Mary logs in the Elckerlyc logs and
to easily set log properties on all marytts logging.
- I'd prefer it if the logger as setup in Mary.startup() does not
enforce a hard-coded log destination and format on me. This could be set
up using log4j properties instead. Getting rid of the PatternLayout
there allowed me to redirect Mary logs to SLF4J.

I've updated my Mary.startup to support some of these points:
public static void simpleStartup() throws Exception
{
    		if (currentState != STATE_OFF) throw new
IllegalStateException("Cannot start system: it is not offline");
        currentState = STATE_STARTING;

        MaryProperties.readProperties();

        // Configure Logging:
        logger = Logger.getLogger("dfki.marytts");
        logger.info("Mary starting up...");
        logger.info("Specification version " +
Version.specificationVersion());
        logger.info("Implementation version " +
Version.implementationVersion());
        logger.info("Running on a Java " +
System.getProperty("java.version")
                + " implementation by " +
System.getProperty("java.vendor")
                + ", on a " + System.getProperty("os.name") + " platform
("
                + System.getProperty("os.arch") + ", " +
System.getProperty("os.version")
                + ")");
        logger.debug("MARY_BASE: "+MaryProperties.maryBase());
        
        StringBuilder installedMsg = new StringBuilder();
        for (String filename : new
File(MaryProperties.maryBase()+"/installed").list()) {
            if (installedMsg.length() > 0) {
                installedMsg.append(", ");
            }
            installedMsg.append(filename);
        }
        logger.debug("Content of installed/ folder: "+installedMsg);
        StringBuilder confMsg = new StringBuilder();
        for (String filename : new
File(MaryProperties.maryBase()+"/conf").list()) {
            if (confMsg.length() > 0) {
                confMsg.append(", ");
            }
            confMsg.append(filename);
        }
        logger.debug("Content of conf/ folder: "+confMsg);
        logger.debug("Full dump of system properties:");
        for (Object key : new
TreeSet<Object>(System.getProperties().keySet())) {
            logger.debug(key + " = " + System.getProperties().get(key));
        }
        logger.debug("XML libraries used:");
        logger.debug("DocumentBuilderFactory: " +
DocumentBuilderFactory.newInstance().getClass());
        try {
            Class xercesVersion =
Class.forName("org.apache.xerces.impl.Version");
 
logger.debug(xercesVersion.getMethod("getVersion").invoke(null));
        } catch (Exception e) {
            // Not xerces, no version number
        }
        logger.debug("TransformerFactory:     " +
TransformerFactory.newInstance().getClass());
        try {
            // Nov 2009, Marc: This causes "[Deprecated] Xalan:
org.apache.xalan.Version" to be written to the console.
            //Class xalanVersion =
Class.forName("org.apache.xalan.Version");
 
//logger.debug(xalanVersion.getMethod("getVersion").invoke(null));
        } catch (Exception e) {
            // Not xalan, no version number
        }

        // Essential environment checks:
        EnvironmentChecks.check();
        
        Runtime.getRuntime().addShutdownHook(new Thread() {
            public void run() {
                shutdown();
            }
        });


        setupFeatureProcessors();
        
        // Instantiate module classes and startup modules:
        startModules();

        logger.info("Startup complete.");
        currentState = STATE_RUNNING;
    }

Regards,
Herwin van Welbergen


More information about the Mary-dev mailing list