public interface MaryInterface
MaryInterface marytts = new LocalMaryInterface();
AudioInputStream audio = marytts.generateAudio("This is my text.");
Default voice in a different language:
MaryInterface marytts = new LocalMaryInterface();
marytts.setLocale(Locale.SWEDISH);
AudioInputStream audio = marytts.generateAudio("Välkommen till talsyntesens värld!");
Custom voice:
MaryInterface marytts = new LocalMaryInterface();
marytts.setVoice("dfki-pavoque-neutral"); // a German voice
AudioInputStream audio = marytts.generateAudio("Hallo und willkommen!");
Other input and output types:
MaryInterface marytts = new LocalMaryInterface();
marytts.setInputType("SSML");
marytts.setOutputType("TARGETFEATURES");
marytts.setLocale(Locale.SWEDISH);
Document ssmlDoc = DomUtils.parseDocument("myfile.ssml");
String targetfeatures = marytts.generateText(ssmlDoc);
The exact same syntax should work with the RemoteMaryInterface included in the marytts-client package:
MaryInterface marytts = new RemoteMaryInterface("localhost", 59125);
AudioInputStream audio = marytts.generateAudio("This is my text.");
Some introspection:
MaryInterface marytts = new LocalMaryInterface();
System.out.println("I currently have " + marytts.getAvailableVoices() + " voices in " + marytts.getAvailableLocales() + " languages available.");
System.out.println("Out of these, " + marytts.getAvailableVoices(Locale.US) + " are for US English.");
Modifier and Type | Method and Description |
---|---|
AudioInputStream |
generateAudio(Document doc)
Synthesis from an XML format, such as SSML, to audio.
|
AudioInputStream |
generateAudio(String text)
Synthesis from a text format to audio.
|
String |
generateText(Document doc)
Partial processing command, converting an input XML format such as SSML into an output text format such as TARGETFEATURES.
|
String |
generateText(String text)
Partial processing command, converting an input text format such as TEXT into an output text format such as TARGETFEATURES.
|
Document |
generateXML(Document doc)
Partial processing command, converting one XML format such as RAWMARYXML into another XML format such as TOKENS.
|
Document |
generateXML(String text)
Partial processing command, converting an input text format such as TEXT into an XML format such as ALLOPHONES.
|
String |
getAudioEffects()
Get the currently set audio effects.
|
Set<String> |
getAvailableInputTypes()
List the names of the input types that can be used in
setInputType(String) . |
Set<Locale> |
getAvailableLocales()
List the locales that can be used in
setLocale(Locale) . |
Set<String> |
getAvailableOutputTypes()
List the names of the input types that can be used in
setInputType(String) . |
Set<String> |
getAvailableVoices()
List the names of all the voices that can be used in
setVoice(String) . |
Set<String> |
getAvailableVoices(Locale locale)
List the names of all the voices for the given locale that can be used in
setVoice(String) . |
String |
getInputType()
Get the current input type, either the default ("TEXT") or the value most recently set through
setInputType(String) . |
Locale |
getLocale()
Get the current locale used for processing.
|
String |
getOutputType()
Get the current output type, either the default ("AUDIO") or the value most recently set through
setInputType(String) . |
String |
getOutputTypeParams()
Get the currently set output type parameters.
|
String |
getStyle()
Get the currently speaking style.
|
String |
getVoice()
The name of the current voice, if any.
|
boolean |
isAudioType(String dataType)
Check whether the given data type is an audio type.
|
boolean |
isStreamingAudio()
Whether to stream audio.
|
boolean |
isTextType(String dataType)
Check whether the given data type is a text type.
|
boolean |
isXMLType(String dataType)
Check whether the given data type is an XML type.
|
void |
setAudioEffects(String audioEffects)
Set the audio effects.
|
void |
setInputType(String newInputType)
Set the input type for processing to the new input type.
|
void |
setLocale(Locale newLocale)
Set the locale for processing.
|
void |
setOutputType(String newOutputType)
Set the output type for processing to the new output type.
|
void |
setOutputTypeParams(String params)
Set the output type parameters.
|
void |
setStreamingAudio(boolean newIsStreaming)
Set whether to stream audio.
|
void |
setStyle(String newStyle)
Set the speaking style.
|
void |
setVoice(String voiceName)
Set the voice to be used for processing.
|
void setInputType(String newInputType) throws IllegalArgumentException
newInputType
- a string representation of a MaryDataType.IllegalArgumentException
- if newInputType is not a valid and known input data type.String getInputType()
setInputType(String)
.void setOutputType(String newOutputType) throws IllegalArgumentException
newOutputType
- a string representation of a MaryDataType.IllegalArgumentException
- if newOutputType is not a valid and known output data type.String getOutputType()
setInputType(String)
.void setLocale(Locale newLocale) throws IllegalArgumentException
newLocale
- a supported locale.IllegalArgumentException
- if newLocale is not among the getAvailableLocales()
.Locale getLocale()
setLocale(Locale)
or indirectly through setVoice(String)
.void setVoice(String voiceName) throws IllegalArgumentException
voiceName
- the name of a valid voice.IllegalArgumentException
- if voiceName is not among the getAvailableVoices()
.String getVoice()
void setAudioEffects(String audioEffects)
audioEffects
- audioEffectsString getAudioEffects()
void setStyle(String newStyle)
newStyle
- newStyleString getStyle()
void setOutputTypeParams(String params)
params
- paramsString getOutputTypeParams()
void setStreamingAudio(boolean newIsStreaming)
newIsStreaming
- newIsStreamingboolean isStreamingAudio()
String generateText(String text) throws SynthesisException
text
- textSynthesisException
- SynthesisExceptionString generateText(Document doc) throws SynthesisException
doc
- docSynthesisException
- SynthesisExceptionDocument generateXML(String text) throws SynthesisException
text
- textSynthesisException
- SynthesisExceptionDocument generateXML(Document doc) throws SynthesisException
doc
- docSynthesisException
- SynthesisExceptionAudioInputStream generateAudio(String text) throws SynthesisException
text
- textSynthesisException
- SynthesisExceptionAudioInputStream generateAudio(Document doc) throws SynthesisException
doc
- docSynthesisException
- SynthesisExceptionSet<String> getAvailableVoices()
setVoice(String)
.Set<String> getAvailableVoices(Locale locale)
setVoice(String)
.locale
- localeSet<Locale> getAvailableLocales()
setLocale(Locale)
.Set<String> getAvailableInputTypes()
setInputType(String)
.Set<String> getAvailableOutputTypes()
setInputType(String)
.boolean isTextType(String dataType)
getAvailableInputTypes()
) that are text types, the synthesis methods generateText(String)
,
generateXML(String)
and generateAudio(String)
can be used; for output types that are text types, the
synthesis methods generateText(String)
and generateText(Document)
can be used.dataType
- an input or output data type.boolean isXMLType(String dataType)
getAvailableInputTypes()
) that are XML types, the synthesis methods generateText(Document)
,
generateXML(Document)
and generateAudio(Document)
can be used; for output types that are XML types, the
synthesis methods generateXML(String)
and generateXML(Document)
can be used.dataType
- an input or output data type.boolean isAudioType(String dataType)
generateAudio(String)
and generateAudio(Document)
can be used.dataType
- an input or output data typeCopyright © 2000–2016 DFKI GmbH. All rights reserved.