public static class Spokestack.Builder extends Object
Spokestack
,
Builder#Builder()
Constructor and Description |
---|
Builder()
Create a Spokestack builder with a default configuration.
|
Modifier and Type | Method and Description |
---|---|
Spokestack.Builder |
addListener(SpokestackAdapter listener)
Add a listener that receives events from all modules.
|
Spokestack |
build()
Use the current state of the builder to construct a full Spokestack
system.
|
DialogueManager.Builder |
getDialogueBuilder() |
NLUManager.Builder |
getNluBuilder() |
SpeechPipeline.Builder |
getPipelineBuilder() |
TTSManager.Builder |
getTtsBuilder() |
Spokestack.Builder |
setConfig(SpeechConfig config)
Sets configuration for all module builders.
|
Spokestack.Builder |
setProperty(String key,
Object value)
Sets a configuration value.
|
Spokestack.Builder |
useRasaOpenSource(String rasaCoreUrl)
Use the Rasa Open Source NLU and dialogue policy components to
handle user utterances.
|
Spokestack.Builder |
withAndroidContext(android.content.Context androidContext)
Sets the Android Context for the pipeline.
|
Spokestack.Builder |
withoutAutoClassification()
Signal that Spokestack's NLU module should not be automatically run
on ASR transcripts.
|
Spokestack.Builder |
withoutAutoPlayback()
Signal that Spokestack should not automatically manage TTS playback.
|
Spokestack.Builder |
withoutDialogueManagement()
Signal that Spokestack's dialogue management module should not be
used.
|
Spokestack.Builder |
withoutNlu()
Signal that Spokestack's NLU module should not be used.
|
Spokestack.Builder |
withoutSpeechPipeline()
Signal that Spokestack's speech pipeline should not be used to
recognize speech.
|
Spokestack.Builder |
withoutTts()
Signal that Spokestack's TTS module should not be used.
|
Spokestack.Builder |
withoutWakeword()
Signal that Spokestack's TensorFlow Lite wakeword detector should not
be used.
|
Spokestack.Builder |
withPipelineProfile(String profileClass)
Uses a
PipelineProfile to configure the speech pipeline,
returning the modified builder. |
Spokestack.Builder |
withTranscriptEditor(TranscriptEditor editor)
Sets a transcript editor used to alter ASR transcripts before they
are classified by the NLU module.
|
public Builder()
TFWakewordAndroidASR
profile, and all features will be enabled.
Internally, this builder delegates to the builder APIs of individual
modules. These individual builders can be retrieved and customized as
desired. Calls to setProperty(String, Object)
are propagated
to all modules.
Some modules require additional configuration that cannot be set
automatically. Properties are set via setProperty(String,
Object)
; other configuration is listed by method:
Note that NLU properties are not required if Rasa NLU and
dialogue management are in use
(see useRasaOpenSource(String)
),
but other properties are required to configure the Rasa
integration.
withAndroidContext(android.content.Context)
:
Android Application context used to manage the audio session
for automatic playback.
Dialogue management is an optional feature that will be
disabled by default. To use it, one of the following
properties is required. If both are included,
dialogue-policy-class
will take precedence.
Like NLU, these properties are not required if Rasa NLU and
dialogue management are in use via
useRasaOpenSource(String)
.
public SpeechPipeline.Builder getPipelineBuilder()
public NLUManager.Builder getNluBuilder()
public TTSManager.Builder getTtsBuilder()
public DialogueManager.Builder getDialogueBuilder()
public Spokestack.Builder setConfig(SpeechConfig config)
Note that the following low-level properties are set to default values at builder construction time; these properties must have values in order for Spokestack to start properly:
Other module builders may set their own default values; builders for the modules in use should be consulted before overwriting their configuration.
config
- configuration to attachpublic Spokestack.Builder withPipelineProfile(String profileClass) throws IllegalArgumentException
PipelineProfile
to configure the speech pipeline,
returning the modified builder. Subsequent calls to withPipelineProfile
or setProperty
can override
configuration set by a profile.profileClass
- class name of the profile to apply.IllegalArgumentException
- if the specified profile does not
existpublic Spokestack.Builder setProperty(String key, Object value)
key
- Configuration property namevalue
- Property valuepublic Spokestack.Builder useRasaOpenSource(String rasaCoreUrl)
This method sets the rasa-oss-url
property automatically;
(see RasaOpenSourceNLU
and RasaDialoguePolicy
for
other relevant properties).
rasaCoreUrl
- URL to the Rasa Open Source server.
The Rasa Open Source component is designed to use
Rasa's REST channel.public Spokestack.Builder withTranscriptEditor(TranscriptEditor editor)
This can be used to alter ASR results that frequently contain a spelling for a homophone that's incorrect for the domain; for example, an app used to summon a genie whose ASR transcripts tend to contain "Jen" instead of "djinn".
If a transcript editor is in use, registered listeners will receive
RECOGNIZE
events from the speech pipeline with the unedited
transcripts, but the editor will automatically run on those
transcripts before the NLU module operates on them. Thus, the utterance
inside the NLUResult
returned by classification
will reflect the edited version of the transcript.
Transcript editors are not run automatically on inputs to the
Spokestack.classify(String)
convenience method.
editor
- A transcript editor used to alter ASR results before
NLU classification.public Spokestack.Builder withAndroidContext(android.content.Context androidContext)
androidContext
- the Android Application Context.public Spokestack.Builder withoutSpeechPipeline()
public Spokestack.Builder withoutWakeword()
builder.withPipelineProfile( "io.spokestack.spokestack.profile.PushToTalkAndroidASR");
If a different profile is specified using the above approach, or if
the speech pipeline is disabled altogether with withoutSpeechPipeline()
, this method should not be called.
public Spokestack.Builder withoutNlu()
public Spokestack.Builder withoutAutoClassification()
Spokestack
instance unless explicitly disabled via withoutNlu()
.public Spokestack.Builder withoutTts()
public Spokestack.Builder withoutAutoPlayback()
withoutTts()
; calling both
is unnecessary.public Spokestack.Builder withoutDialogueManagement()
public Spokestack.Builder addListener(SpokestackAdapter listener)
listener
- A listener that will receive events from all
Spokestack modules.public Spokestack build() throws Exception
Exception
- if required configuration is missing, or there is
an error during Spokestack initialization.Copyright © 2021. All rights reserved.