Comments (11)
Hi ! Can I see the code you used ?
from react-native-vosk.
`import React, {useState, useEffect, useRef, useCallback} from 'react';
import {StyleSheet, View, Text, Button} from 'react-native';
import Vosk from 'react-native-vosk';
export default function App(): JSX.Element {
const [ready, setReady] = useState<Boolean>(false);
const [recognizing, setRecognizing] = useState<Boolean>(false);
const [result, setResult] = useState<String | undefined>();
const vosk = useRef(new Vosk()).current;
const load = useCallback(() => {
vosk
.loadModel('model-en-en')
.then(() => setReady(true))
.catch((e: any) => console.log(e));
}, [vosk]);
const unload = useCallback(() => {
vosk.unload();
setReady(false);
}, [vosk]);
useEffect(() => {
const resultEvent = vosk.onResult((res: {data: String}) => {
console.log(res);
console.log('A onResult event has been caught: ' + JSON.stringify(res));
});
return () => {
resultEvent.remove();
};
}, [vosk]);
// const grammar = ['gauche', 'droite', '[unk]'];
const grammar = ['left', 'right', '[unk]'];
const record = () => {
if (!ready) {
return;
}
console.log('Starting recognition...');
setRecognizing(true);
vosk
.start(grammar)
.then((res: string) => {
console.log('Result is: ' + res);
setResult(res);
})
.catch((e: any) => {
console.log('Error: ' + e);
})
.finally(() => {
setRecognizing(false);
});
};
return (
<View style={styles.container}>
<Button
onPress={ready ? unload : load}
title={ready ? 'Unload model' : 'Load model'}
color="blue"
/>
<Button
onPress={record}
title="Record"
disabled={ready === false || recognizing === true}
color="#841584"
/>
<Text>Recognized word:</Text>
<Text>{result}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
box: {
width: 60,
height: 60,
marginVertical: 20,
},
});
`
Hi @kingdcreations here is above my code , I have created a folder inside assets folder named model-en-en and pasted the model files into it.
from react-native-vosk.
Which platform ?
from react-native-vosk.
Take care of the availabilities you have set:
const grammar = ['left', 'right', '[unk]'];
Vosk will only recognize "left", "right", or anything else this way
from react-native-vosk.
Which platform ?
For now I am testing on android
from react-native-vosk.
Take care of the availabilities you have set: const grammar = ['left', 'right', '[unk]'];
Vosk will only recognize "left", "right", or anything else this way
Actually I didnt get what is grammer , could you please guide me ? and what should i add in there if i want to recognize english language .
from react-native-vosk.
Hi @alitele !
The grammar parameter is used to recognize only specified words/phrases for exemple:
in start(['left', 'right', '[unk]']) saying a word other than "left" or "right" returns "[unk]" as result, otherwise if you say "left", you ll get "left" as result.
To recognize anything just use start() without parameter !
Hope I could help you :)
from react-native-vosk.
Yes now it recognize but the accuracy is not good for example i spoke "pakistan america india" and it wrote "pakistan a map" is there any way to improve it ? Thanks a lot @kingdcreations
from react-native-vosk.
Maybe try to use a larger model:
https://alphacephei.com/vosk/models
from react-native-vosk.
ok if i download a bigger model then will it increase the app size too while uploading on store? secondly can the listener keeps listening continuously until we manually stop it ? as of now it listen for certain time period and then listener stops.
from react-native-vosk.
ok if i download a bigger model then will it increase the app size too while uploading on store? secondly can the listener keeps listening continuously until we manually stop it ? as of now it listen for certain time period and then listener stops.
Unfortunately yes !
For now it's not possible, but we are currently working on a v2 to handle that in #40
Stay in touch !
from react-native-vosk.
Related Issues (11)
- Undefined symbol error HOT 3
- onFinalResult never triggered? HOT 1
- android gradle version is 7.2.1? HOT 1
- example not works HOT 5
- how to build libvosk.a with latest vosk codes for ios HOT 3
- Better implementation HOT 4
- what to do with cleanup() and stopOnly() HOT 3
- Adding feature HOT 1
- im getting this error when i try to run my project on xcode " Import of module 'glog.glog.log_severity' appears within namespace 'google' " HOT 1
- Load model from the another path HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-vosk.