public final class GoogleSpeechRecognizer extends Object implements SpeechProcessor
This pipeline component uses the Google Speech API to stream audio samples from spokestack for speech recognition. When the speech context is triggered, the recognizer begins streaming buffered frames to the API for recognition. Once the speech context becomes inactive, the recognizer completes the API request and raises a RECOGNIZE event along with the audio transcript and confidence.
This pipeline component supports the following configuration properties:
Constructor and Description |
---|
GoogleSpeechRecognizer(SpeechConfig speechConfig)
initializes a new recognizer instance.
|
GoogleSpeechRecognizer(SpeechConfig speechConfig,
com.google.cloud.speech.v1.SpeechClient speechClient)
initializes a new recognizer instance with an existing google client,
for testing/mocking purposes.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
releases the resources associated with the recognizer.
|
void |
process(SpeechContext context,
ByteBuffer frame)
processes a frame of audio.
|
void |
reset()
resets all state internal to the stage.
|
public GoogleSpeechRecognizer(SpeechConfig speechConfig) throws Exception
speechConfig
- spokestack pipeline configurationException
- on errorpublic GoogleSpeechRecognizer(SpeechConfig speechConfig, com.google.cloud.speech.v1.SpeechClient speechClient) throws Exception
speechConfig
- spokestack pipeline configurationspeechClient
- google speech api clientException
- on errorpublic void reset()
SpeechProcessor
reset
in interface SpeechProcessor
public void close()
close
in interface AutoCloseable
public void process(SpeechContext context, ByteBuffer frame) throws Exception
process
in interface SpeechProcessor
context
- the current speech contextframe
- the audio frame to detectException
- on errorCopyright © 2021. All rights reserved.