public abstract class TTSEngine extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
TTSEngine.SynthesisResult |
| Modifier and Type | Field and Description |
|---|---|
protected TTSService |
mProvider |
| Modifier | Constructor and Description |
|---|---|
protected |
TTSEngine(TTSService provider) |
| Modifier and Type | Method and Description |
|---|---|
TTSRegistry.TTSResource |
allocateThreadResources()
This method must be thread-safe.
|
protected static AudioInputStream |
createAudioStream(AudioFormat format,
byte[] data)
Create an
AudioInputStream from an AudioFormat and the audio data. |
protected static AudioInputStream |
createAudioStream(AudioFormat format,
ByteArrayInputStream data) |
protected static AudioInputStream |
createAudioStream(InputStream stream)
Create a
AudioInputStream from a InputStream. |
int |
expectedMillisecPerWord() |
abstract Collection<Voice> |
getAvailableVoices()
Return the list of available voices for this engine.
|
int |
getOverallPriority()
Need not be thread-safe.
|
TTSService |
getProvider() |
boolean |
handlesMarks() |
boolean |
handlesPronunciation()
Whether the TTS engine handles
phoneme elements,
which is required for prununciation lexicons to have an effect. |
boolean |
handlesSpeakingRate()
Whether the TTS engine handles
prosody
elements with a rate attribute. |
void |
interruptCurrentWork(TTSRegistry.TTSResource resource)
Force interruption of the execution of synthesize() when the thread-level
interruption is not enough to make synthesize() finish.
|
void |
releaseThreadResources(TTSRegistry.TTSResource resources)
This method must be thread-safe.
|
int |
reservedThreadNum() |
abstract TTSEngine.SynthesisResult |
synthesize(net.sf.saxon.s9api.XdmNode sentence,
Voice voice,
TTSRegistry.TTSResource threadResources)
This method must be thread-safe.
|
protected String |
transformSsmlNodeToString(net.sf.saxon.s9api.XdmNode ssml,
URL xslt,
Map<String,Object> params)
Transform an SSML node to a string using a given XSLT and parameter map
If this method is called from
synthesize(net.sf.saxon.s9api.XdmNode, org.daisy.pipeline.tts.Voice, org.daisy.pipeline.tts.TTSRegistry.TTSResource), the XSLT should not
assume that the SSML node is a root element. |
protected TTSService mProvider
protected TTSEngine(TTSService provider)
provider - is the service from which the TTSEngine has been
allocated.public TTSService getProvider()
public abstract TTSEngine.SynthesisResult synthesize(net.sf.saxon.s9api.XdmNode sentence, Voice voice, TTSRegistry.TTSResource threadResources) throws TTSService.SynthesisException, InterruptedException
sentence - is the sentence to synthesize, as an SSML node. The node
is expected to be an s element with an
xml:lang attribute. It is however advised that
implementations do not assume this is the case. It can
also not be assumed that the node is a root element.voice - is the voice the synthesizer must use. It is guaranteed to
be one of those returned by getAvailableVoices(). This
parameter can't be null.threadResources - is the object returned by
allocateThreadResource(). It may contain small persistent
buffers, opened file streams, TCP connections and so on. The
boolean field 'released' is guaranteed to be false, i.e. the
resource provided is always valid and will remain so during
the call.TTSEngine.SynthesisResult object containing the audio data and the
mark offsets.TTSService.SynthesisExceptionInterruptedExceptionpublic abstract Collection<Voice> getAvailableVoices() throws TTSService.SynthesisException, InterruptedException
VoiceManager when there are no other discriminating
factors.
Need not be thread-safe. This method is called from the main thread.public TTSRegistry.TTSResource allocateThreadResources() throws TTSService.SynthesisException, InterruptedException
TTSService.SynthesisExceptionInterruptedExceptionpublic void releaseThreadResources(TTSRegistry.TTSResource resources) throws TTSService.SynthesisException, InterruptedException
resources - is the object returned by allocateThreadResource()TTSService.SynthesisExceptionInterruptedExceptionpublic void interruptCurrentWork(TTSRegistry.TTSResource resource)
resource - is the same as the one provided to synthesize()public int getOverallPriority()
public int reservedThreadNum()
public int expectedMillisecPerWord()
public boolean handlesMarks()
true if the TTS engine handles SSML marks, false
otherwise. Must be thread-safe.public boolean handlesSpeakingRate()
prosody
elements with a rate attribute. If this method returns true, the
engine is assumed to support all of the following values:
speech-rate
property.org.daisy.pipeline.tts.speech-rate property.public boolean handlesPronunciation()
phoneme elements,
which is required for prununciation lexicons to have an effect. This method does not say
anyhing about which pronunciation alphabets are supported, which phonemes, and for which
languages.protected String transformSsmlNodeToString(net.sf.saxon.s9api.XdmNode ssml, URL xslt, Map<String,Object> params) throws IOException, net.sf.saxon.s9api.SaxonApiException
synthesize(net.sf.saxon.s9api.XdmNode, org.daisy.pipeline.tts.Voice, org.daisy.pipeline.tts.TTSRegistry.TTSResource), the XSLT should not
assume that the SSML node is a root element.IOExceptionnet.sf.saxon.s9api.SaxonApiExceptionprotected static AudioInputStream createAudioStream(AudioFormat format, byte[] data)
AudioInputStream from an AudioFormat and the audio data.protected static AudioInputStream createAudioStream(AudioFormat format, ByteArrayInputStream data)
protected static AudioInputStream createAudioStream(InputStream stream) throws UnsupportedAudioFileException, IOException
AudioInputStream from a InputStream.
This is to work around a bug in AudioSystem
which may return AudioInputStream with a wrong AudioInputStream.getFrameLength().Copyright © 2010–2025 The DAISY Consortium. All rights reserved.