public final class SpeechContext extends Object
This class maintains global state for the speech pipeline, allowing pipeline components to communicate information among themselves and event handlers.
Modifier and Type | Class and Description |
---|---|
static class |
SpeechContext.Event
speech event types.
|
Constructor and Description |
---|
SpeechContext(SpeechConfig config)
initializes a new configuration instance.
|
Modifier and Type | Method and Description |
---|---|
SpeechContext |
addOnSpeechEventListener(OnSpeechEventListener listener)
attaches a speech listener.
|
SpeechContext |
attachBuffer(Deque<ByteBuffer> value)
attaches a frame buffer to the context.
|
boolean |
canTrace(EventTracer.Level level)
indicates whether a message will be traced at a level.
|
SpeechContext |
detachBuffer()
removes the attached frame buffer.
|
SpeechContext |
dispatch(SpeechContext.Event event)
dispatches a speech event.
|
android.content.Context |
getAndroidContext() |
Deque<ByteBuffer> |
getBuffer() |
double |
getConfidence() |
Throwable |
getError() |
String |
getMessage() |
String |
getTranscript() |
boolean |
isActive() |
boolean |
isManaged() |
boolean |
isSpeech() |
SpeechContext |
removeOnSpeechEventListener(OnSpeechEventListener listener)
detaches a speech listener.
|
SpeechContext |
reset()
resets the context to the default state.
|
SpeechContext |
setActive(boolean value)
activates speech recognition.
|
void |
setAndroidContext(android.content.Context androidContext)
sets the Android context.
|
SpeechContext |
setConfidence(double value)
updates the current speech confidence level.
|
SpeechContext |
setError(Throwable value)
raises an error with the speech context.
|
void |
setManaged(boolean value)
signals whether the speech context is being externally managed (audio is
not being read from the microphone by Spokestack's speech pipeline).
|
SpeechContext |
setSpeech(boolean value)
sets speech detected indicator.
|
SpeechContext |
setTranscript(String value)
updates the current speech transcript.
|
SpeechContext |
trace(EventTracer.Level level,
String format,
Object... params)
raises a trace event.
|
SpeechContext |
traceDebug(String format,
Object... params)
traces a debug level message.
|
SpeechContext |
traceInfo(String format,
Object... params)
traces an informational level message.
|
SpeechContext |
tracePerf(String format,
Object... params)
traces a performance level message.
|
public SpeechContext(SpeechConfig config)
config
- speech configuration@Nullable public android.content.Context getAndroidContext()
public void setAndroidContext(@Nullable android.content.Context androidContext)
androidContext
- The Android contextpublic Deque<ByteBuffer> getBuffer()
public SpeechContext attachBuffer(Deque<ByteBuffer> value)
value
- frame buffer to attachpublic SpeechContext detachBuffer()
public boolean isSpeech()
public SpeechContext setSpeech(boolean value)
value
- value to assignpublic boolean isActive()
public SpeechContext setActive(boolean value)
value
- value to assignpublic boolean isManaged()
public void setManaged(boolean value)
value
- true
if audio is being managed by an external
component.public String getTranscript()
public SpeechContext setTranscript(String value)
value
- speech text value to assignpublic double getConfidence()
public SpeechContext setConfidence(double value)
value
- speech confidence to assignpublic Throwable getError()
public SpeechContext setError(Throwable value)
value
- the exception to attachpublic String getMessage()
public SpeechContext reset()
public SpeechContext traceDebug(String format, Object... params)
format
- trace message format stringparams
- trace message format parameterspublic SpeechContext tracePerf(String format, Object... params)
format
- trace message format stringparams
- trace message format parameterspublic SpeechContext traceInfo(String format, Object... params)
format
- trace message format stringparams
- trace message format parameterspublic boolean canTrace(EventTracer.Level level)
level
- tracing levelpublic SpeechContext trace(EventTracer.Level level, String format, Object... params)
level
- tracing levelformat
- trace message format stringparams
- trace message format parameterspublic SpeechContext dispatch(SpeechContext.Event event)
event
- the event to publishpublic SpeechContext addOnSpeechEventListener(OnSpeechEventListener listener)
listener
- listener callback to attachpublic SpeechContext removeOnSpeechEventListener(OnSpeechEventListener listener)
listener
- listener callback to removeCopyright © 2020. All rights reserved.