@timesinternet/voice-to-text

1.0.0 • Public • Published

swiper

A React component to convert voice to text

Installation

Browser

npm install --save voice-to-text

Browser

import vtt from 'voice-to-text';

export class MyComponent extends Component {
  componentWillMount(){
    if(vtt.hasSupport()){
      vtt.init(); //take permission from browser
    }
  }

  onStart(){
    // do something when voice to text start
  }

  onResult(text){
    // do something after voice to text converted
  }

  onEnd(){
    // do something when voice to text stop
  }

  onError(error){
    // do something on error
  }

  voiceSearch(){
    vtt.start(this.onStart.bind(this),this.onResult.bind(this), this.onEnd.bind(this), this.onError.bind(this));
  }

  render(){
    return(
      <div>
        <button onClick={this.voiceSearch.bind(this)}>Search</button>
      </div>   
    )
  }
}

export default MyComponent;

Available functions

  • hasSupport: play text in hindi or english (language options are 'hindi','english')
  • init: stop audio
  • start: voice to text start
  • there will be 4 callbacks for start function
  • params will be: onStartCallback, onResultCallback, onEndCallback ,onErrorCallback
  • onStartCallback: do something when voice to text start
  • onResultCallback: do something after voice to text converted
  • onEndCallback: do something when voice to text stop
  • onErrorCallback: do something on error

Who's using text-to-speech?

License

This project is licensed under the terms of the

Readme

Keywords

Package Sidebar

Install

npm i @timesinternet/voice-to-text

Weekly Downloads

4

Version

1.0.0

License

ISC

Unpacked Size

3.92 kB

Total Files

3

Last publish

Collaborators

  • mohit.rathi
  • sandeep.panwar
  • til