JavaScript Library
MIT License
The JavaScript library is made available under the MIT License
To get started, include the JavaScript library on your pages:
<script src="https://cdn.voysis.io/js/voysis.js"></script>
HTTPS Only
Your web page must be loaded using HTTPS, and you must include the JavaScript library using HTTPS. Most modern browsers restrict access to the microphone unless the page (and JS lib) are loaded over HTTPS.
Initialising the Voysis Session
Before you start sending queries, you need to create a VoysisSession
. This session can be created once and be used for the lifetime of your webpage. The 2 pieces of information that you must give are your Voysis endpoint and the audio profile identifier (see the section in general concepts for more information on what this value means).
var voysisSession = new VoysisSession({
host: 'mycompany.voysis.io',
audioProfileId: 'f8338e44-9d48-11e7-abc4-cec278b6b50a'
});
If you are new to the Voysis JavaScript library, the easiest way to get started after creating the Voysis session is to use the all-in-one convenience method sendAudioQuery
.
Asynchronous and Promises
All of the methods available on VoysisSession
are executed asynchronously. What is returned from each of the methods is a JavaScript Promise
object that will resolve when the asynchronous methods completes successfully, or reject if there is a failure.
Microphone Permissions
All browsers require a user to approve access to their microphone before a webpage can start using it. The JavaScript library will prompt the user for permission the first time they try to stream audio from their browser. Note that the prompt will not appear until streaming audio is initiated; loading the JavaScript library and creating a VoysisSession
do not trigger the permission prompt.
Versions
The versioning of the JavaScript library uses the standard MAJOR.MINOR.PATCH
semantic versioning schema (for example, voysis-1.1.4.js
). In short:
- MAJOR version changes when there are incompatible API changes with the previous version.
- MINOR version changes when there is new functionality added in a backwards-compatible manner
- PATCH version changes when there are backwards-compatible bug fixes.
Minified
A minified version of all JavaScript files will be available with the extension .min.js
Latest Version
voysis.js
will always be an alias for the latest library version, so you should use that unless you need a specific version.
Updated over 7 years ago