API reference
API reference
Select your platform
No SDKs available
No versions available

WitRequest Class

Manages a single request lifecycle when sending/receiving data from Wit.ai.
Note: This is not intended to be instantiated directly. Requests should be created with the WitRequestFactory

Constructors

WitRequest ( newConfiguration , newPath , newOptions , newEvents )
Initialize wit request with configuration & path to endpoint
Signature
Meta.WitAi.WitRequest.WitRequest(WitConfiguration newConfiguration, string newPath, WitRequestOptions newOptions, VoiceServiceRequestEvents newEvents)
Parameters
newConfiguration: WitConfiguration
newPath: string
newOptions: WitRequestOptions

Protected Fields

DecodeRawResponses : override bool
Signature
override bool Meta.WitAi.WitRequest.DecodeRawResponses

Fields

audioDurationTracker : AudioDurationTracker
Signature
AudioDurationTracker Meta.WitAi.WitRequest.audioDurationTracker
forcedHttpMethodType : string
Signature
string Meta.WitAi.WitRequest.forcedHttpMethodType
IsRequestStreamActive : bool
Returns true if the request is being performed
Signature
bool Meta.WitAi.WitRequest.IsRequestStreamActive
onCustomizeUri : OnCustomizeUriEvent
Provides an opportunity to customize the url just before a request executed
Signature
OnCustomizeUriEvent Meta.WitAi.WitRequest.onCustomizeUri
onRawResponse : Action< string >
Returns the raw string response that was received before converting it to a JSON object.
NOTE: This response comes back on a different thread. Do not attempt ot set UI control values or other interactions from this callback. This is intended to be used for demo and test UI, not for regular use.
Signature
Action<string> Meta.WitAi.WitRequest.onRawResponse
postContentType : string
Signature
string Meta.WitAi.WitRequest.postContentType
postData : byte []
Signature
byte [] Meta.WitAi.WitRequest.postData

Static Fields

onPreSendRequest : PreSendRequestDelegate
Allows customization of the request before it is sent out.
Note: This is for devs who are routing requests to their servers before sending data to Wit.ai. This allows adding any additional headers, url modifications, or customization of the request.
Signature
PreSendRequestDelegate Meta.WitAi.WitRequest.onPreSendRequest

Properties

AudioEncoding : AudioEncoding
[Get][Set]
Encoding settings for audio based requests
Signature
AudioEncoding Meta.WitAi.WitRequest.AudioEncoding
audioEncoding : AudioEncoding
[Get][Set]
Signature
AudioEncoding Meta.WitAi.WitRequest.audioEncoding
Command : string
[Get]
Final portion of the endpoint Path
Signature
string Meta.WitAi.WitRequest.Command
Configuration : WitConfiguration
[Get]
The wit Configuration to be used with this request
Signature
WitConfiguration Meta.WitAi.WitRequest.Configuration
HasResponseStarted : bool
[Get]
Returns true if the response had begun
Signature
bool Meta.WitAi.WitRequest.HasResponseStarted
IsInputStreamReady : bool
[Get]
Returns true if the response had begun
Signature
bool Meta.WitAi.WitRequest.IsInputStreamReady
IsPost : bool
[Get]
Whether a post command should be called
Signature
bool Meta.WitAi.WitRequest.IsPost
OnInputStreamReady : Action
[Get][Set]
Callback called when the server is ready to receive audio data from WitRequest's input stream.
Signature
Action Meta.WitAi.WitRequest.OnInputStreamReady
Path : string
[Get][Set]
Endpoint to be used for this request
Signature
string Meta.WitAi.WitRequest.Path
queryParams : VoiceServiceRequestOptions.QueryParam []
[Get]
Key value pair that is sent as a query param in the Wit.ai uri
Signature
VoiceServiceRequestOptions.QueryParam [] Meta.WitAi.WitRequest.queryParams
TimeoutMs : int
[Get]
The request timeout in ms
Signature
int Meta.WitAi.WitRequest.TimeoutMs

Events

onFullTranscription : Action< string >
Returns a full utterance from a completed request
NOTE: This response comes back on a different thread.
Signature
Action<string> Meta.WitAi.WitRequest.onFullTranscription
onInputStreamReady : Action< WitRequest >
Callback called when the server is ready to receive data from the WitRequest's input stream. See WitRequest.Write()
Signature
Action<WitRequest> Meta.WitAi.WitRequest.onInputStreamReady
onPartialResponse : Action< WitRequest >
Callback called when a response is received from the server off a partial transcription
Signature
Action<WitRequest> Meta.WitAi.WitRequest.onPartialResponse
onPartialTranscription : Action< string >
Returns a partial utterance from an in process request
NOTE: This response comes back on a different thread.
Signature
Action<string> Meta.WitAi.WitRequest.onPartialTranscription
onProvideCustomHeaders : OnProvideCustomHeadersEvent
Provides an opportunity to provide custom headers for the request just before it is executed.
Signature
OnProvideCustomHeadersEvent Meta.WitAi.WitRequest.onProvideCustomHeaders
onResponse : Action< WitRequest >
Callback called when a response is received from the server
Signature
Action<WitRequest> Meta.WitAi.WitRequest.onResponse

Protected Methods

GetSendError ()
Signature
override string Meta.WitAi.WitRequest.GetSendError()
Returns
override string
HandleAudioActivation ()
Signature
override void Meta.WitAi.WitRequest.HandleAudioActivation()
Returns
override void
HandleAudioDeactivation ()
Signature
override void Meta.WitAi.WitRequest.HandleAudioDeactivation()
Returns
override void
HandleCancel ()
Signature
override void Meta.WitAi.WitRequest.HandleCancel()
Returns
override void
HandleSend ()
Start the async request for data from the Wit.ai servers
Signature
override void Meta.WitAi.WitRequest.HandleSend()
Returns
override void
HasSentAudio ()
Signature
override bool Meta.WitAi.WitRequest.HasSentAudio()
Returns
override bool
OnComplete ()
Signature
override void Meta.WitAi.WitRequest.OnComplete()
Returns
override void
OnFullTranscription ()
Signature
override void Meta.WitAi.WitRequest.OnFullTranscription()
Returns
override void
OnInit ()
Finalize initialization
Signature
override void Meta.WitAi.WitRequest.OnInit()
Returns
override void
OnPartialResponse ( responseNode )
Signature
override void Meta.WitAi.WitRequest.OnPartialResponse(WitResponseNode responseNode)
Parameters
responseNode: WitResponseNode
Returns
override void
OnPartialTranscription ()
Signature
override void Meta.WitAi.WitRequest.OnPartialTranscription()
Returns
override void
OnRawResponse ( rawResponse )
Called when raw response data has been received
Signature
override void Meta.WitAi.WitRequest.OnRawResponse(string rawResponse)
Parameters
rawResponse: string
Returns
override void
SetState ( newState )
Signature
override void Meta.WitAi.WitRequest.SetState(VoiceRequestState newState)
Parameters
Returns
override void

Methods

OnCustomizeUriEvent ( uriBuilder )
Signature
delegate Uri Meta.WitAi.WitRequest.OnCustomizeUriEvent(UriBuilder uriBuilder)
Parameters
uriBuilder: UriBuilder
Returns
delegate Uri
OnProvideCustomHeadersEvent ()
Signature
delegate Dictionary<string, string> Meta.WitAi.WitRequest.OnProvideCustomHeadersEvent()
Returns
delegate Dictionary< string, string >
PreSendRequestDelegate ( src_uri , headers )
Signature
delegate void Meta.WitAi.WitRequest.PreSendRequestDelegate(ref Uri src_uri, out Dictionary< string, string > headers)
Parameters
src_uri: ref Uri
headers: out Dictionary< string, string >
Returns
delegate void
ToString ()
Simply return the Path to be called
Signature
override string Meta.WitAi.WitRequest.ToString()
Returns
override string
Write ( data , offset , length )
Write request data to the Wit.ai post's body input stream
Note: If the stream is not open (IsActive) this will throw an IOException. Data will be written synchronously. This should not be called from the main thread.
Signature
void Meta.WitAi.WitRequest.Write(byte[] data, int offset, int length)
Parameters
data: byte []
offset: int
length: int
Returns
void