public class SpeechRecognizer extends APIRequestBase
Modifier and Type | Field and Description |
---|---|
static int |
AUDIO_BITS_PER_SAMPLE |
static int |
AUDIO_CHANNELS |
static int |
AUDIO_LENGTH_MILLISECONDS_PER_FRAME |
static int |
AUDIO_SAMPLE_RATE |
static int |
AUDIO_TYPE_PCM_RAW |
static int |
AUDIO_TYPE_PCM_WAVE |
Constructor and Description |
---|
SpeechRecognizer(APIConfiguration configuration)
Speech Recognizer to issue Cloud Speech Recognition API requests.
|
Modifier and Type | Method and Description |
---|---|
int |
appendAudioFramesData(byte[] audioFramesData)
Append audio data contains N frames to wait the upload for speech recognition.
|
APIResponse |
flushToUploadAudio(CookieSet identifier,
boolean isFinalAudio)
Flush all of appended audio data to upload and request for speech recognition.
|
int |
getAppendedAudioSize()
Get size of all appended audio data.
|
int |
getAudioBufferMaxSize()
Get the maximum size in bytes of the audio buffer to append audio frames data.
|
int |
getAudioBufferMinSize()
Get the minimum size in bytes of the audio buffer to append audio frames data.
|
int |
getAudioFrameSize()
Get audio frame size used by the speech recognizer.
|
int |
getBufferedDataSize()
Get size of the buffered data from the appended audio.
|
boolean |
hasBufferedData()
Check if there are still buffered data that has not been flushed yet.
|
void |
releaseAppendedAudio()
Release all of appended audio data.
|
APIResponse |
requestRecognition(CookieSet identifier)
Request to get speech recognition results by specified task identifier.
|
APIResponse |
requestRecognitionWithAll(CookieSet identifier)
Request to get speech recognition results by specified task identifier.
|
APIResponse |
requestRecognitionWithAll(CookieSet identifier,
NLIConfig nliConfig)
Request to get speech recognition results by specified task identifier.
|
APIResponse |
requestRecognitionWithNLI(CookieSet identifier)
Request to get speech recognition results by specified task identifier.
|
APIResponse |
requestRecognitionWithNLI(CookieSet identifier,
NLIConfig nliConfig)
Request to get speech recognition results by specified task identifier.
|
void |
setAudioType(int audioType)
Set and specify the type of the speech audio.
|
APIResponse |
uploadAudio(CookieSet identifier,
byte[] audioData,
boolean isFinalAudio)
Request to upload the specified audio for speech recognition.
|
APIResponse |
uploadAudio(CookieSet identifier,
byte[] audioData,
int audioType,
boolean isFinalAudio)
Request to upload the specified audio for speech recognition.
|
APIResponse |
uploadAudio(CookieSet identifier,
String filePath,
boolean isFinalAudio)
Request to upload the specified audio for speech recognition.
|
APIResponse |
uploadAudio(CookieSet identifier,
String filePath,
int audioType,
boolean isFinalAudio)
Request to upload the specified audio for speech recognition.
|
getConfiguration, getEndUserIdentifier, getSdkType, getTimeout, setConfiguration, setEndUserIdentifier, setSdkType, setTimeout
public static final int AUDIO_TYPE_PCM_RAW
public static final int AUDIO_TYPE_PCM_WAVE
public static final int AUDIO_LENGTH_MILLISECONDS_PER_FRAME
public static final int AUDIO_SAMPLE_RATE
public static final int AUDIO_BITS_PER_SAMPLE
public static final int AUDIO_CHANNELS
public SpeechRecognizer(APIConfiguration configuration)
configuration
- - API configurations.public int getAudioFrameSize()
public APIResponse uploadAudio(CookieSet identifier, String filePath, boolean isFinalAudio) throws IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.filePath
- - The path of the audio file.
Wave Header is required if it is a Wave audio.isFinalAudio
- - TRUE if this is the last audio of a speech input.IOException
- File handling or HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public APIResponse uploadAudio(CookieSet identifier, String filePath, int audioType, boolean isFinalAudio) throws IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.filePath
- - The path of the audio file.
Wave Header is required if it is a Wave audio.audioType
- - Audio type:
AUDIO_TYPE_PCM_RAW for PCM raw data.
AUDIO_TYPE_PCM_WAVE for Wave audio.isFinalAudio
- - TRUE if this is the last audio of a speech input.IOException
- File handling or HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public APIResponse uploadAudio(CookieSet identifier, byte[] audioData, boolean isFinalAudio) throws IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.audioData
- - The audio data.
Wave Header is required if it is a Wave audio.isFinalAudio
- - TRUE if this is the last audio of a speech input.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public APIResponse uploadAudio(CookieSet identifier, byte[] audioData, int audioType, boolean isFinalAudio) throws IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.audioData
- - The audio data.
Wave Header is required if it is a Wave audio.audioType
- - Audio type:
AUDIO_TYPE_PCM_RAW for PCM raw data.
AUDIO_TYPE_PCM_WAVE for Wave audio.isFinalAudio
- - TRUE if this is the last audio of a speech input.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public void setAudioType(int audioType)
audioType
- - Audio type:
AUDIO_TYPE_PCM_RAW for PCM raw data.
AUDIO_TYPE_PCM_WAVE for Wave audio.public int getAudioBufferMaxSize()
public int getAudioBufferMinSize()
public int appendAudioFramesData(byte[] audioFramesData)
audioFramesData
- - The audio frames data. (Contains N frames)public APIResponse flushToUploadAudio(CookieSet identifier, boolean isFinalAudio) throws IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.isFinalAudio
- - TRUE if this is the last audio of a speech input.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public void releaseAppendedAudio()
public int getAppendedAudioSize()
public int getBufferedDataSize()
public boolean hasBufferedData()
public APIResponse requestRecognition(CookieSet identifier) throws IllegalArgumentException, IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.IllegalArgumentException
- Invalid contents of the CookieSet.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public APIResponse requestRecognitionWithNLI(CookieSet identifier) throws IllegalArgumentException, IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.IllegalArgumentException
- Invalid contents of the CookieSet.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public APIResponse requestRecognitionWithNLI(CookieSet identifier, NLIConfig nliConfig) throws IllegalArgumentException, IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.nliConfig
- - NLIConfig object.IllegalArgumentException
- Invalid contents of the CookieSet.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public APIResponse requestRecognitionWithAll(CookieSet identifier) throws IllegalArgumentException, IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.IllegalArgumentException
- Invalid contents of the CookieSet.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.public APIResponse requestRecognitionWithAll(CookieSet identifier, NLIConfig nliConfig) throws IllegalArgumentException, IOException, NoSuchAlgorithmException
identifier
- - Identifier CookieSet.nliConfig
- - NLIConfig object.IllegalArgumentException
- Invalid contents of the CookieSet.IOException
- HTTP connection failed, or other exceptions.NoSuchAlgorithmException
- Failed to create signature.Copyright © 2018. All rights reserved.