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 subsystems.
|
Spokestack |
build()
Use the current state of the builder to construct a full Spokestack
system.
|
TensorflowNLU.Builder |
getNluBuilder() |
SpeechPipeline.Builder |
getPipelineBuilder() |
TTSManager.Builder |
getTtsBuilder() |
Spokestack.Builder |
setConfig(SpeechConfig config)
Sets configuration for all subsystem builders.
|
Spokestack.Builder |
setProperty(String key,
Object value)
Sets a configuration value.
|
Spokestack.Builder |
withAndroidContext(android.content.Context androidContext)
Sets the Android Context for the pipeline.
|
Spokestack.Builder |
withLifecycle(androidx.lifecycle.Lifecycle lifecycle)
Sets the Android Lifecycle used for management of TTS playback.
|
Spokestack.Builder |
withoutAutoClassification()
Signal that Spokestack's NLU subsystem should not be automatically
run on ASR transcripts.
|
Spokestack.Builder |
withoutAutoPlayback()
Signal that Spokestack should not automatically manage TTS playback.
|
Spokestack.Builder |
withoutNlu()
Signal that Spokestack's NLU subsystem 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 subsystem should not be used.
|
Spokestack.Builder |
withoutWakeword()
Signal that Spokestack's TensorFlow Lite wakeword detector should not
be used.
|
Spokestack.Builder |
withTranscriptEditor(TranscriptEditor editor)
Sets a transcript editor used to alter ASR transcripts before they
are classified by the NLU subsystem.
|
public Builder()
TFWakewordAndroidASR
profile, and all features will be enabled.
Internally, this builder delegates to the builder APIs of individual
subsystems. These individual builders can be retrieved and customized
as desired. Calls to setProperty(String, Object)
are
propagated to all subsystems.
Some subsystems require additional configuration that cannot be set
automatically. Properties are set via setProperty(String,
Object)
; other configuration is listed by method:
withAndroidContext(android.content.Context)
:
Android Application context used to manage the audio session
for automatic playback.
withLifecycle(androidx.lifecycle.Lifecycle)
:
Android lifecycle context used to manage automatic pausing and
resuming of audio on application lifecycle events.
public SpeechPipeline.Builder getPipelineBuilder()
public TensorflowNLU.Builder getNluBuilder()
public TTSManager.Builder getTtsBuilder()
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:
config
- configuration to attachpublic Spokestack.Builder setProperty(String key, Object value)
key
- Configuration property namevalue
- Property valuepublic 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 subsystem 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 withLifecycle(androidx.lifecycle.Lifecycle lifecycle)
lifecycle
- the Android Lifecycle.public Spokestack.Builder withoutSpeechPipeline()
public Spokestack.Builder withoutWakeword()
builder .getPipelineBuilder() .useProfile( "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 addListener(SpokestackAdapter listener)
listener
- A listener that will receive events from all
Spokestack subsystems.public Spokestack build() throws Exception
Exception
- if required configuration is missing, or there is
an error during Spokestack initialization.Copyright © 2020. All rights reserved.