public class SynthesisRequest extends Object
A simple wrapper class comprising the options available when making a synthesis request.
This class is designed with a request to the Spokestack TTS server in mind,
but its metadata
field should make it adaptable to other services.
SSML
is an XML-based markup language; the root element must be <speak>
.
Aside from speak
, Spokestack supports the following elements, a
subset of the SSML spec:
s
break
say-as
with an interpret-as
attribute
of "characters"
, "spell-out"
,
or "digits"
phoneme
with the alphabet
attribute
set to "ipa"
Because SSML is based on XML, any characters invalid in XML, such as
<
, >
, and &
, must be escaped as HTML entities to be
valid.
Currently, Spokestack is focused on pronunciation of English words and loan
words/foreign words common in spoken English and thus restricts its
character set from the full range of
IPA characters. Characters valid for an IPA ph
attribute
are:
[' ', ',', 'a', 'b', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'w', 'z', 'æ', 'ð', 'ŋ', 'ɑ', 'ɔ', 'ə', 'ɛ', 'ɝ', 'ɪ', 'ʃ', 'ʊ', 'ʌ', 'ʒ', 'ˈ', 'ˌ', 'ː', 'θ', 'ɡ', 'x', 'y', 'ɹ', 'ʰ', 'ɜ', 'ɒ', 'ɚ', 'ɱ', 'ʔ', 'ɨ', 'ɾ', 'ɐ', 'ʁ', 'ɵ', 'χ']
and the emphasis symbols ˈ
, ,
, ˌ
, and ː
.
Using invalid characters will not cause an error, but it might result in unexpected pronunciation.
Failing to enclose SSML text in speak
tags will
cause an error, but not until the request reaches the synthesis server.
Spokestack also supports a subset of Speech Markdown syntax; please see the Speech Markdown syntax documentation for more details.
Currently, the only elements relevant to Spokestack are
break
,
characters
,
ipa
,
and
number
.
Modifier and Type | Class and Description |
---|---|
static class |
SynthesisRequest.Builder
A fluent interface for constructing a
TTSInput object piecemeal. |
static class |
SynthesisRequest.Mode
The types of input available for synthesized speech.
|
Modifier and Type | Field and Description |
---|---|
Map<String,String> |
metadata
Any additional data that should be included along with the TTS request.
|
SynthesisRequest.Mode |
mode
The synthesis mode, either
TEXT or SSML . |
CharSequence |
text
The text to be synthesized.
|
String |
voice
The voice in which the text should be synthesized.
|
Constructor and Description |
---|
SynthesisRequest(CharSequence textToSynthesize,
SynthesisRequest.Mode synthesisMode,
String ttsVoice,
Map<String,String> requestData)
Construct a fully specified synthesis request object.
|
public final CharSequence text
public final SynthesisRequest.Mode mode
TEXT
or SSML
.public final String voice
public SynthesisRequest(CharSequence textToSynthesize, SynthesisRequest.Mode synthesisMode, String ttsVoice, Map<String,String> requestData)
textToSynthesize
- The text to be synthesized.synthesisMode
- The synthesis mode, either TEXT
or SSML
. If using SSML mode, ensure that textToSynthesize
contains valid SSML, including
the root <speak>
tags.ttsVoice
- The voice in which the text should be
synthesized.requestData
- Any additional data that should be included along
with the TTS request.Copyright © 2021. All rights reserved.