@timesinternet/voice-to-text
v1.0.0
Published
Convert voice to text
Downloads
5
Keywords
Readme
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