🎥 See it live.
This is a Voice Search Widget. It is using the Chrome API when running on Chrome but it is using the Google Cloud Platform Speech-To-Text API when running on any other browsers.
Table of Contents
This widget comes with JavaScript but also pre-defined CSS.
You can copy and paste the JavaScript code from the repository itself, grab the full voice-widget folder in public/.
The simplest usage is:
var socket = io.connect("http://....:port/");
const search = instantsearch({
indexName: "...",
searchClient: algoliasearch("...", "..."),
});
search.addWiget(instantsearch.widgets.hits({ container: '#hits' }));
search.addWidget(
new VoiceWidget({
container: "#voice-search",
placeholder: "Search for ....",
socket: socket,
processor: "gcp" // gcp ||
})
);To use this widget, you need to create an account on GCP to get credentials and then:
- Base64 encode the credentials (the Javascript Object)
- Define a new environement variable called SPEECH_GCP_CREDENTIALS with the value of the base64 encoded
- You're good to go!
It would not work on old browsers: https://caniuse.com/#search=getUserMedia
This widget is implemented using a custom widget.
To contribute to the project, clone this repository, add your credentials to the congif file (based on the credentials-example) and then run:
npm install
npm startTHIS CUSTOM CODE IS PROVIDED “AS IS” AND “AS AVAILABLE” WITHOUT ANY WARRANTY OF ANY KIND. ALGOLIA DISCLAIMS ALL OBLIGATION AND LIABILITY UNDER THE APPLICABLE SUBSCRIPTION DOCUMENTS FOR ANY HARM OR DAMAGE ARISING OUT OF OR IN CONNECTION WITH CUSTOM CODE.
