2 * Copyright 2002 DFKI GmbH.
3 * Portions Copyright 2002 Sun Microsystems, Inc.
4 * All Rights Reserved. Use is subject to license terms.
6 * See the file "license.terms" for information on usage and
7 * redistribution of this file, and for a DISCLAIMER OF ALL
11 package de.dfki.lt.freetts.en.us;
13 import com.sun.speech.freetts.Validator;
14 import com.sun.speech.freetts.ValidationException;
15 import com.sun.speech.freetts.util.Utilities;
20 * Shows this MbrolaVoice is valid (or usable). It tests for
24 * <li> Check that the "mbrola.base" System property is defined,
25 * and that directory exists.
26 * <li> Check that the $(mbrola.base)/mbrola binary exists.
27 * <li> Check that the transition table exists. It is assumed
28 * to be at $(mbrola.base)/us1/us1mrpa.
29 * <li> Check that its voice database exists.
32 public class MbrolaVoiceValidator implements Validator {
34 private MbrolaVoice mbrolaVoice;
36 public MbrolaVoiceValidator(MbrolaVoice mbrolaVoice) {
37 this.mbrolaVoice = mbrolaVoice;
41 * Validates this MbrolaVoice.
43 * @throws ValidationException if this MbrolaVoice is invalid
45 public void validate() throws ValidationException {
46 String mbrolaBase = Utilities.getProperty("mbrola.base", null);
47 File mbrolaBinary = new File(mbrolaVoice.getMbrolaBinary());
48 File mbrolaVoiceDB = new File(mbrolaVoice.getDatabase());
50 if (mbrolaBase == null || mbrolaBase.length() == 0) {
51 throw new ValidationException
52 ("System property \"mbrola.base\" is undefined. " +
53 "You might need to set the MBROLA_DIR environment variable.");
55 if (!mbrolaBinary.exists()) {
56 throw new ValidationException
57 ("No MBROLA binary at: " + mbrolaVoice.getMbrolaBinary());
59 if (!mbrolaVoiceDB.exists()) {
60 throw new ValidationException
61 ("No voice database for " + mbrolaVoice.getName() +
62 " at: " + mbrolaVoice.getDatabase());
67 * Returns the name of this validator.
69 * @return the name of this validator
71 public String toString() {
72 return (mbrolaVoice.toString() + "Validator");