ninoish / lwc-web-speech-api-input

Implements voice powered input for Lightning Web Component with Web Speech API and SpeechRecognition.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LWC Web Speech API Input

lwc-web-speech-api-example.mov

An experimental implementation of voice powered input for Lightning Web Component with Web Speech API and SpeechRecognition Interface, the native browswer Javascript API for free.

Settings

Properties

  • Language
  • Min textarea height
  • Show toast notification on error
  • Textarea Label

web-speech-api-comp-props

How to use

Place c-web-speech-api-input component where you want with props. onchangevalue event returns the value of the input in its detail prop.

  <c-web-speech-api-input
    min-height="200"
    input-label="Test Input"
    show-toast-on-error="true"
    language={language}
    onchangevalue={handleInputChange}
  ></c-web-speech-api-input>

If you want to set up the language flexibly, it can be configured via Apex Picklist. Set the property fetching datasource in your .js-meta.xml file.

    <property name="language"  type="String" label="Language" datasource="apex://WebSpeechApiPicklist"/>

Considerations

Disclaimer

This is an experimental demo implementation. It doesn't ensure code integrity. Please confirm the code before you deploy.

About

Implements voice powered input for Lightning Web Component with Web Speech API and SpeechRecognition.

License:MIT License


Languages

Language:Apex 42.4%Language:JavaScript 38.4%Language:HTML 18.0%Language:CSS 0.7%Language:Shell 0.4%