Conversation Class Reference
Inherits from | NSObject |
---|---|
Conforms to | SpeechRecognitionProtocol |
Declared in | ConversationBase.mm SpeechRecognitionService.h |
Overview
Base class for speech recognition sessions.
Client applications initiate a session with the speech recognition service using one of the derived classes that best fit the client application needs.
Other Methods
– initWithPrefs:withProtocol:
Initializes a conversation with the specified preferences.
- (void)initWithPrefs:(Preferences *)prefs withProtocol:(id<SpeechRecognitionProtocol>)delegate
Parameters
prefs |
A set of preferences used to configure the speech service. |
---|---|
delegate |
The speech recognition protocol callback |
Return Value
The conversation session object
Discussion
Initializes a conversation with the specified preferences.
Declared In
ConversationBase.mm
– createConversation
Refreshes the conversation context using the existing preferences.
- (void)createConversation
Discussion
Refreshes the conversation context using the existing preferences.
Declared In
ConversationBase.mm
– createStream
Creates a data stream indpendent of the microphose so that audio buffers can be sent to the service.
- (IStream *)createStream
Return Value
The created stream
Discussion
Creates a data stream indpendent of the microphose so that audio buffers can be sent to the service.
Declared In
ConversationBase.mm
– writeAudioFormat:withEncoding:withBytesPerSec:withBitsPerSample:withBlockAlign:withChannelCount:withSamplesPerSec:withFormatData:
Sends an audio format description to the service.
- (int)writeAudioFormat:(IStream *)pStream withEncoding:(short)encodingFormat withBytesPerSec:(int)averageBytesPerSecond withBitsPerSample:(short)bitsPerSample withBlockAlign:(short)blockAlign withChannelCount:(short)channelCount withSamplesPerSec:(int)samplesPerSecond withFormatData:(NSData *)formatSpecificData
Parameters
pStream |
The audio stream |
---|---|
encodingFormat |
The audio encoding format |
averageBytesPerSecond |
The average bytes per second in the audio stream |
bitsPerSample |
The bits per sample of the audio stream |
blockAlign |
The block alignment of the audio stream |
channelCount |
The channel count of the audio stream |
samplesPerSecond |
The samples per second in the audio stream |
formatSpecificData |
Format-specific data for the audio stream |
Return Value
The number of bytes written to the audio stream
Discussion
Sends an audio format description to the service.
If you are not sending up a audio file in wave format, but instead you have just raw data, then before sending up any audio data, you must first send up an [SpeechAudioFormat](../Classes/SpeechAudioFormat.html) descriptor to describe the layout and format of your raw audio data. The audio must be PCM, mono, 16-bit sample, with sample rate of 16000 Hz.
Declared In
ConversationBase.mm
– audioStart
Turns the microphone on and begins streaming data from the microphone to the speech recognition service.
- (OSStatus)audioStart
Discussion
Turns the microphone on and begins streaming data from the microphone to the speech recognition service.
A built in Silence Detector is applied to the microphone data before it is sent to the service.
Declared In
ConversationBase.mm
– audioStop
Turns the microphone off and breaks the connection to the speech recognition service.
- (void)audioStop
Discussion
Turns the microphone off and breaks the connection to the speech recognition service.
Declared In
ConversationBase.mm
– waitForFinalResponse:
Waits the given number of seconds for a speech recognition response. Calling this method blocks the current thread until the response is received or the wait time is exceeded.
- (bool)waitForFinalResponse:(int)timeoutInSeconds
Parameters
timeoutInSeconds |
The response wait timeout, in seconds |
---|
Return Value
true if the final speech recognition result is sent from the speech recognition service or false if the timeout was reached.
Discussion
Waits the given number of seconds for a speech recognition response. Calling this method blocks the current thread until the response is received or the wait time is exceeded.
Declared In
ConversationBase.mm
– onFinalResponseReceived:
Callback invoked when a final recognition response is received from the service
- (void)onFinalResponseReceived:(RecognitionResult *)response
Parameters
response |
The recognition response |
---|
Discussion
Callback invoked when a final recognition response is received from the service
Declared In
ConversationBase.mm
– onIntentReceived:
Callback invoked when an intent response is received from the service
- (void)onIntentReceived:(IntentResult *)intent
Parameters
intent |
The intent payload |
---|
Discussion
Callback invoked when an intent response is received from the service
Declared In
ConversationBase.mm
– onPartialResponseReceived:
Callback invoked when a partial recognition response is received from the service
- (void)onPartialResponseReceived:(NSString *)partialResult
Parameters
partialResult |
The partial recognition response |
---|
Discussion
Callback invoked when a partial recognition response is received from the service
Declared In
ConversationBase.mm
– onError:withErrorCode:
Called when a non-speech error occurs.
Non-speech errors include connection and authorization errors.
- (void)onError:(NSString *)errorMessage withErrorCode:(int)errorCode
Parameters
errorMessage |
A optional error message describing the error. |
---|---|
errorCode |
The error code being signaled. |
Discussion
Called when a non-speech error occurs.
Non-speech errors include connection and authorization errors.
Declared In
ConversationBase.mm
– onMicrophoneStatus:
Callback invoked when the microphone status changes
- (void)onMicrophoneStatus:(Boolean)recording
Parameters
recording |
A flag indicating whether the microphone is recording |
---|
Discussion
Callback invoked when the microphone status changes
Declared In
ConversationBase.mm
– sendText:
Sends a text query to the service if the service supports it.
- (void)sendText:(NSString *)textQuery
Parameters
textQuery |
The text query to send. |
---|
Discussion
Sends a text query to the service if the service supports it.
Declared In
ConversationBase.mm
– synthesizeText:
Begins playing back synthesized text as audio
- (void)synthesizeText:(NSString *)text
Parameters
text |
The text string to send. |
---|
Discussion
Begins playing back synthesized text as audio
Declared In
ConversationBase.mm
– synthesizeText:withMimeType:
Begins playing back synthesized text as audio
- (void)synthesizeText:(NSString *)input withMimeType:(NSString *)mimeType
Parameters
input |
The input string to send. |
---|---|
mimeType |
The mime type of the input string. |
Discussion
Begins playing back synthesized text as audio
Declared In
ConversationBase.mm
– setLocationLatitude:withLongitude:
Sets the current geographic location to improve results.
- (void)setLocationLatitude:(double)latitude withLongitude:(double)longitude
Parameters
latitude |
The geographic latitude coordinate. |
---|---|
longitude |
The geographic longitude coordinate. |
Discussion
Sets the current geographic location to improve results.
Declared In
ConversationBase.mm
– finalize
Terminates the connection with the speech recognition service and finalizes the conversation.
- (void)finalize
Discussion
Terminates the connection with the speech recognition service and finalizes the conversation.
Declared In
ConversationBase.mm
Extension Methods
isFinalResponseSent
Gets or sets a flag that indicates whether the final response has been sent
@property bool isFinalResponseSent
Discussion
Gets or sets a flag that indicates whether the final response has been sent
Declared In
ConversationBase_Protected.h
waitResponseCondVar
Gets or sets the response wait condition variable
@property (strong, nonatomic) NSCondition *waitResponseCondVar
Discussion
Gets or sets the response wait condition variable
Declared In
ConversationBase_Protected.h
recoMode
Gets or sets the speech recognition mode
@property SpeechRecognitionMode recoMode
Discussion
Gets or sets the speech recognition mode
Declared In
ConversationBase_Protected.h
isIntent
Gets or sets a flag that indicates whether intent should be returned
@property bool isIntent
Discussion
Gets or sets a flag that indicates whether intent should be returned
Declared In
ConversationBase_Protected.h
proxyDelegate
Gets or sets the speech recognition protocol proxy delegate
@property id<SpeechRecognitionProtocol> proxyDelegate
Discussion
Gets or sets the speech recognition protocol proxy delegate
Declared In
ConversationBase_Protected.h