robaimes / module-voice-search

Adds voice search to Magento 2 global search input

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aimes_VoiceSearch

A simple module that adds voice search capabilities to the Magento 2 global search. An icon will be displayed in the search bar if the module is enabled.

Installation

Installation via composer is recommended.

  • composer require aimes/module-voice-search
  • php bin/magento module:enable Aimes_VoiceSearch
  • php bin/magento setup:upgrade

Alternatively, if for whatever reason you are not using composer, put the contents of this repository in <magento_directory>/app/code/Aimes/VoiceSearch

Configuration

  • Enable Voice Search Default: Yes
    • When disabled this module will have no effect
  • Skip Suggestions Default: No
    • With this value set to No the search autocomplete suggestions will display to the user
    • With this value set to Yes the user will be directed to the relevant catalogsearch page and will not fire an AJAX request to get autocomplete results

This module is tested and developed on an unmodified Magento 2.3.5 Open Source instance with Luma theme and sample data. Results may vary using a custom theme.

Developer Notes

The voice search functionality is powered by a jQuery widget $.aimes.voiceSearch which exposes 2 public methods for convenience.

  • startSpeechRecognition - Start listening for user speech
  • stopSpeechRecognition - Stop listening for user speech

Example:

$('#search').voiceSearch('startSpeechRecognition');
$('#search').voiceSearch('stopSpeechRecognition');

The widget has multiple functions for extension. One for each event. It is suggested you use mixins to add additional functionality where appropriate.

Browser Support

This module makes use of the SpeechRecognition API. Browser support can be seen on this page or on caniuse.

About

Adds voice search to Magento 2 global search input


Languages

Language:JavaScript 57.5%Language:PHP 21.5%Language:CSS 12.8%Language:HTML 8.3%