Skip to content

Commit

Permalink
fix: fixed the README
Browse files Browse the repository at this point in the history
  • Loading branch information
riderodd committed Nov 10, 2023
1 parent 5fbef45 commit 6113c45
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,33 @@ That's all. The model folder should appear in your project. When you click on it
## Usage

```js
import VoiceRecognition from 'react-native-voice-recognition';
import Vosk from 'react-native-vosk';

// ...

const voiceRecognition = new VoiceRecognition();
const voiceRecognition = new Vosk();

voiceRecognition.loadModel('model-fr-fr').then(() => {
voiceRecognition.loadModel('model-en-en').then(() => {
// we can use promise...
const options = ['left', 'right', '[unk]'];
voiceRecognition
.start()
.then((res: any) => {
console.log('Result is: ' + res);
})
.start(options)
.then((res: string) => {
console.log('Result is: ' + res);
})
.catch((e: any) => {
console.log('Error: ' + e);
})
.finally(() => {
console.log("Recognition is complete")
});

// ... or events
const resultEvent = vosk.onResult((res) => {
const resultEvent = voiceRecognition.onResult((res) => {
console.log('A onResult event has been caught: ' + res.data);
});

// Don't forget to call resultEvent.remove(); when needed
// Don't forget to call resultEvent.remove(); to delete the listener
}).catch(e => {
console.error(e);
})
Expand Down

0 comments on commit 6113c45

Please sign in to comment.