de.dfki.lt.mary.modules.synthesis
Class Voice

java.lang.Object
  extended by de.dfki.lt.mary.modules.synthesis.Voice
Direct Known Subclasses:
HMMVoice, InterpolatingVoice, MbrolaVoice, UnitSelectionVoice

public class Voice
extends java.lang.Object

A helper class for the synthesis module; each Voice object represents one available voice database.

Author:
Marc Schröder

Nested Class Summary
static class Voice.Gender
           
 
Field Summary
static javax.sound.sampled.AudioFormat AF16000
          Audio format: 16kHz,16bit,mono, native byte order
static javax.sound.sampled.AudioFormat AF16000BE
          Audio format: 16kHz,16bit,mono, big endian
static javax.sound.sampled.AudioFormat AF22050
          Audio format: 22.05kHz,16bit,mono, native byte order
static Voice.Gender FEMALE
          Gender: female.
static Voice.Gender MALE
          Gender: male.
 
Constructor Summary
Voice(java.lang.String[] nameArray, java.util.Locale locale, javax.sound.sampled.AudioFormat dbAudioFormat, WaveformSynthesizer synthesizer, Voice.Gender gender, int topStart, int topEnd, int baseStart, int baseEnd)
           
Voice(com.sun.speech.freetts.Voice freeTTSVoice, WaveformSynthesizer synthesizer)
          Deprecated. 
 
Method Summary
 int baseEnd()
           
 int baseStart()
           
 java.util.Vector<MBROLAPhoneme> convertSampa(MBROLAPhoneme maryPhoneme)
          Convert the SAMPA dialect used in MARY into the SAMPA version used in this voice.
 javax.sound.sampled.AudioFormat dbAudioFormat()
           
 Voice.Gender gender()
           
static java.util.Collection getAvailableVoices()
          Get the list of all available voices.
static java.util.Collection<Voice> getAvailableVoices(java.util.Locale locale)
          Get the list of all available voices for a given locale.
static java.util.Collection<Voice> getAvailableVoices(WaveformSynthesizer synth)
          Get the list of all available voices for a given waveform synthesizer.
static java.util.Collection<Voice> getAvailableVoices(WaveformSynthesizer synth, java.util.Locale locale)
          Get the list of all available voices for a given waveform synthesizer and locale.
static Voice getDefaultVoice(java.util.Locale locale)
           
 TargetFeatureComputer getHalfphoneTargetFeatureComputer()
          Get the target feature computer to be used in conjunction with this voice when computing target feature vectors, e.g.
 com.sun.speech.freetts.lexicon.Lexicon getLexicon()
          Return the lexicon associated to this voice
 java.util.Locale getLocale()
           
 java.lang.String getName()
          Return the name of this voice.
 java.util.Vector<MaryModule> getPreferredModulesAcceptingType(MaryDataType type)
           
 Phoneme getSampaPhoneme(java.lang.String sampaSymbol)
          If a phoneme set is available, return a Phoneme object for the given sampa symbol.
 PhonemeSet getSampaPhonemeSet()
          Get the SAMPA phoneme set associated with this voice.
static Voice getSuitableVoice(MaryData d)
           
 TargetFeatureComputer getTargetFeatureComputer()
          Get the target feature computer to be used in conjunction with this voice when computing target feature vectors, e.g.
static Voice getVoice(org.w3c.dom.Element voiceElement)
           
static Voice getVoice(java.util.Locale locale, Voice.Gender gender)
           
static Voice getVoice(java.lang.String name)
           
 boolean hasName(java.lang.String name)
           
static void registerVoice(Voice voice)
          Register the given voice.
static void registerVoice(Voice maryVoice, com.sun.speech.freetts.Voice freettsVoice)
          Register the given voice along with the corresponding freetts voice.
 java.lang.String sampa2voice(java.lang.String sampaPhoneme)
          Converts a single phonetic symbol in MARY sampa representation into its equivalent in voice-specific phonetic alphabet representation.
 java.util.List<java.lang.String> sampaString2voicePhonemeList(java.lang.String sampa)
          Converts a full phonetic string including stress markers from MARY sampa into the voice-specific representation.
 javax.sound.sampled.AudioInputStream synthesize(java.util.List<org.w3c.dom.Element> tokensAndBoundaries)
          Synthesize a list of tokens and boundaries with the waveform synthesizer providing this voice.
 WaveformSynthesizer synthesizer()
           
 int topEnd()
           
 int topStart()
           
 java.lang.String toString()
          Returns the return value of getName().
 boolean useVoicePAInOutput()
          Whether to use this voice's phonetic alphabet in the output.
 java.lang.String voice2sampa(java.lang.String voicePhoneme)
          Converts a single phonetic symbol in the voice phonetic alphabet representation representation into its equivalent in MARY sampa representation.
 java.lang.String voicePhonemeArray2sampaString(java.lang.String[] voicePhonemes)
          Converts an array of phoneme symbol strings in voice-specific representation into a single MARY sampa string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MALE

public static final Voice.Gender MALE
Gender: male.


FEMALE

public static final Voice.Gender FEMALE
Gender: female.


AF16000

public static final javax.sound.sampled.AudioFormat AF16000
Audio format: 16kHz,16bit,mono, native byte order


AF16000BE

public static final javax.sound.sampled.AudioFormat AF16000BE
Audio format: 16kHz,16bit,mono, big endian


AF22050

public static final javax.sound.sampled.AudioFormat AF22050
Audio format: 22.05kHz,16bit,mono, native byte order

Constructor Detail

Voice

public Voice(java.lang.String[] nameArray,
             java.util.Locale locale,
             javax.sound.sampled.AudioFormat dbAudioFormat,
             WaveformSynthesizer synthesizer,
             Voice.Gender gender,
             int topStart,
             int topEnd,
             int baseStart,
             int baseEnd)

Voice

@Deprecated
public Voice(com.sun.speech.freetts.Voice freeTTSVoice,
                        WaveformSynthesizer synthesizer)
Deprecated. 

Constructor for creating a MARY voice from a FreeTTS voice.

Parameters:
freeTTSVoice - an existing FreeTTS voice
synthesizer - the freeTTS synthesizer working with this voice.
Method Detail

voice2sampa

public java.lang.String voice2sampa(java.lang.String voicePhoneme)
Converts a single phonetic symbol in the voice phonetic alphabet representation representation into its equivalent in MARY sampa representation.

Returns:
the converted phoneme, or the input string if no known conversion exists.

sampa2voice

public java.lang.String sampa2voice(java.lang.String sampaPhoneme)
Converts a single phonetic symbol in MARY sampa representation into its equivalent in voice-specific phonetic alphabet representation.

Returns:
the converted phoneme, or the input string if no known conversion exists.

sampaString2voicePhonemeList

public java.util.List<java.lang.String> sampaString2voicePhonemeList(java.lang.String sampa)
Converts a full phonetic string including stress markers from MARY sampa into the voice-specific representation. Syllable boundaries, if present, will be ignored. Stress markers, if present, will lead to a "1" appended to the voice-specific versions of the vowels in the syllable.

Returns:
a List of String objects.

voicePhonemeArray2sampaString

public java.lang.String voicePhonemeArray2sampaString(java.lang.String[] voicePhonemes)
Converts an array of phoneme symbol strings in voice-specific representation into a single MARY sampa string. If stress is marked on voice phoneme symbols ("1" appended), a crude syllabification is done on the sampa string.


getSampaPhonemeSet

public PhonemeSet getSampaPhonemeSet()
Get the SAMPA phoneme set associated with this voice.

Returns:

getSampaPhoneme

public Phoneme getSampaPhoneme(java.lang.String sampaSymbol)
If a phoneme set is available, return a Phoneme object for the given sampa symbol.

Parameters:
sampaSymbol - sampa symbol for one phoneme -- use voice2sampa() to create this from a voice phoneme symbol.
Returns:
a Phoneme object, or null.

getPreferredModulesAcceptingType

public java.util.Vector<MaryModule> getPreferredModulesAcceptingType(MaryDataType type)

hasName

public boolean hasName(java.lang.String name)

getName

public java.lang.String getName()
Return the name of this voice. If the voice has several possible names, the first one is returned.


toString

public java.lang.String toString()
Returns the return value of getName().

Overrides:
toString in class java.lang.Object

getLocale

public java.util.Locale getLocale()

dbAudioFormat

public javax.sound.sampled.AudioFormat dbAudioFormat()

synthesizer

public WaveformSynthesizer synthesizer()

gender

public Voice.Gender gender()

topStart

public int topStart()

topEnd

public int topEnd()

baseStart

public int baseStart()

baseEnd

public int baseEnd()

getTargetFeatureComputer

public TargetFeatureComputer getTargetFeatureComputer()
Get the target feature computer to be used in conjunction with this voice when computing target feature vectors, e.g. for unit selection or HMM-based synthesis. This can be voice-specific if there are config settings voice.(voicename).targetfeaturelister.featuremanager and/or voice.(voicename).targetfeaturelister.features, or else this will default to the locale specific versions (locale).targetfeaturelister.featuremanager and (locale).targetfeaturelister.features. If there are no locale-specific versions either, null is returned.

Returns:
a target feature computer object, or null.

getHalfphoneTargetFeatureComputer

public TargetFeatureComputer getHalfphoneTargetFeatureComputer()
Get the target feature computer to be used in conjunction with this voice when computing target feature vectors, e.g. for unit selection or HMM-based synthesis. This can be voice-specific if there are config settings voice.(voicename).halfphone-targetfeaturelister.featuremanager and/or voice.(voicename).halfphone-targetfeaturelister.features, or else this will default to the locale specific versions (locale).halfphone-targetfeaturelister.featuremanager and (locale).halfphone-targetfeaturelister.features. If there are no locale-specific versions either, null is returned.

Returns:
a target feature computer object, or null.

useVoicePAInOutput

public boolean useVoicePAInOutput()
Whether to use this voice's phonetic alphabet in the output.


convertSampa

public java.util.Vector<MBROLAPhoneme> convertSampa(MBROLAPhoneme maryPhoneme)
Convert the SAMPA dialect used in MARY into the SAMPA version used in this voice. Allow for one-to-many translations, taking care of duration and f0 target adjustments.

Returns:
a vector of MBROLAPhoneme objects realising this phoneme for this voice.

synthesize

public javax.sound.sampled.AudioInputStream synthesize(java.util.List<org.w3c.dom.Element> tokensAndBoundaries)
                                                throws SynthesisException
Synthesize a list of tokens and boundaries with the waveform synthesizer providing this voice.

Throws:
SynthesisException

getLexicon

public com.sun.speech.freetts.lexicon.Lexicon getLexicon()
Return the lexicon associated to this voice

Returns:

registerVoice

public static void registerVoice(Voice voice)
Register the given voice. It will be contained in the list of available voices returned by any subsequent calls to getAvailableVoices(). If the voice has the highest value of wantToBeDefault for its locale it will be registered as the default voice for its locale. This value is set in the config file setting voice.(name).want.to.be.default.voice.


registerVoice

public static void registerVoice(Voice maryVoice,
                                 com.sun.speech.freetts.Voice freettsVoice)
Register the given voice along with the corresponding freetts voice. It will be contained in the list of available voices returned by any subsequent calls to getAvailableVoices(). If the voice has the highest value of wantToBeDefault for its locale it will be registered as the default voice for its locale. This value is set in the config file setting voice.(name).want.to.be.default.voice.


getVoice

public static Voice getVoice(java.lang.String name)

getAvailableVoices

public static java.util.Collection getAvailableVoices()
Get the list of all available voices. The iterator of the collection returned will return the voices in decreasing order of their "wantToBeDefault" value.


getAvailableVoices

public static java.util.Collection<Voice> getAvailableVoices(java.util.Locale locale)
Get the list of all available voices for a given locale. The iterator of the collection returned will return the voices in decreasing order of their "wantToBeDefault" value.

Parameters:
locale -
Returns:
a collection of Voice objects, or an empty collection if no voice is available for the given locale.

getAvailableVoices

public static java.util.Collection<Voice> getAvailableVoices(WaveformSynthesizer synth)
Get the list of all available voices for a given waveform synthesizer. The iterator of the collection returned will return the voices in decreasing order of their "wantToBeDefault" value.

Returns:
a collection of Voice objects, or an empty collection if no voice is available for the given waveform synthesizer.

getAvailableVoices

public static java.util.Collection<Voice> getAvailableVoices(WaveformSynthesizer synth,
                                                             java.util.Locale locale)
Get the list of all available voices for a given waveform synthesizer and locale. The iterator of the collection returned will return the voices in decreasing order of their "wantToBeDefault" value.

Returns:
a collection of Voice objects, or an empty collection if no voice is available for the given locale.

getVoice

public static Voice getVoice(java.util.Locale locale,
                             Voice.Gender gender)

getVoice

public static Voice getVoice(org.w3c.dom.Element voiceElement)

getDefaultVoice

public static Voice getDefaultVoice(java.util.Locale locale)

getSuitableVoice

public static Voice getSuitableVoice(MaryData d)