aimes/module-voice-search

Add voice search functionality to Magento 2 global search

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 0

Forks: 0

Open Issues: 1

Language:JavaScript

Type:magento2-module

1.0.0 2020-07-26 18:14 UTC

This package is auto-updated.

Last update: 2024-10-15 04:19:47 UTC


README

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.