Create Audio Query
Before you start streaming audio to Voysis, you need to create an Audio Query entity that is used to represent the query. (See General Concepts for a description on conversations and queries)
You create an new audio query by calling createAudioQuery
on VoysisSession
and passing in:
locale
: (mandatory) A string representing the locale of the querycontext
: (optional) An object representing the current context under which the query is being performed.conversationId
: (optional) A string value of the identifier of the conversation that this query will be part of.audioContext
: (optional) AnAudioContext
instance that will be used to stream audio from.
For example:
var locale = 'en-US';
var context = {
"keywords": [
"sprinting",
"sneakers"
],
"attributes": {
"color": "red"
}
};
var conversationId = previousQueryResults.conversationId
voysisSession.createAudioQuery(locale, context, conversationId).then(function (createdAudioQuery) {
console.log('Created audio query: ' + createdAudioQuery.id);
}).catch(function (error) {
console.log('Problem creating audio query: ' + JSON.stringify(error));
});
The object passed into to the callback is the created audio query. For example:
{
"id": "173f19f2-cb86-4bb5-8dc0-fe472d3e9b5e",
"queryType": "audio",
"audioQuery": {
"mimeType": "audio/pcm;bits=16;rate=16000"
},
"_links": {
"self": {
"href": "/conversations/4827d6f2-bd53-4c95-b094-1561f0776b70/queries/173f19f2-cb86-4bb5-8dc0-fe472d3e9b5e"
},
"audio": {
"href": "/conversations/4827d6f2-bd53-4c95-b094-1561f0776b70/queries/173f19f2-cb86-4bb5-8dc0-fe472d3e9b5e/audio"
},
"conversation": {
"href": "/conversations/4827d6f2-bd53-4c95-b094-1561f0776b70"
}
},
"_embedded": {}
}
Updated about 7 years ago