Comments (3)
Hi @ashram78 , if you add an error listener to your code, you'll find that the problem will be identified with "recognition_overlap"
(read more about artyom.when here). This error happens when you try to start artyom but it's still active.
To solve it, as you want immediately change of language, you can use a setTimeout to wait 300 ms to be started again.
The speechRecognition cannot be started till the last speechRecognition is finished. However the original API doesn't stop immediately the speechRecognition, therefore you need to use a setTimeout to prevent errors.
/**
* Note that this commands will work only in english mode .. in other language they will be not so good
* recognized.
*/
artyom.addCommands({
// note that if you're in spanish for example
// the command should be instead : "Iniciar en ingles, Iniciar en alemán" etc...
indexes:["switch to italian","switch to german",
"switch to french","switch to spanish",
"switch to portuguese","switch to dutch",
"switch to polish","switch to indonesian",
"switch to english"],
action: function(i){
switch(i){
case 0: stop(); start("it-IT"); break;
case 1: start("de-IT"); break;
case 2: start("fr-FR"); break;
case 3: start("es-ES"); break;
case 4: start("pt-PT"); break;
case 5: start("nl-NL"); break;
case 6: start("pl-PL"); break;
case 7: start("id-ID"); break;
case 8: start("en-GB"); break;
}
}
});
// on command recognition end
artyom.when("COMMAND_RECOGNITION_END",function(status){
if(status.code == "continuous_mode_enabled"){
console.info("Command reconition finalized, restarting because the continuous mode is enabled");
}
});
function start(language){
if(!language){
language = artyom.getLanguage();
}
var _startArtyom = function(){
artyom.initialize({
lang: language,// Start artyom with provided language
continuous:true,// Continuous mode enabled
listen:true, // Start recognizing
debug:true, // Show everything in the console
speed:1, // talk normally
executionKeyword: "now" // say "now" at the end of a command to execute it immediately
});
console.log("Artyom is listening to your commands");
};
// stop artyom if stills active
artyom.fatality();
setTimeout(_startArtyom,250);
}
// Catch errors
artyom.when("ERROR",function(data){
console.error(data);
});
start("en-GB");
// or
// start("en-US");
from artyom.js.
Thank you Carlos for your great jpb and the quick response. I found the solution with this function:
pausecomp(3000);
function pausecomp(ms) {
ms += new Date().getTime();
while (new Date() < ms){}
}
it's a little hacky, but it works, :-)
from artyom.js.
@ashram78 , that works however that will block the UI. I recommend to use setTimeout
function instead. Thanks for use artyom !
from artyom.js.
Related Issues (20)
- Webview with artyom
- Basic Usage with TS HOT 1
- Remove command Callbacks (TEXT_RECOGNIZED).
- Allow adding custom JSGF
- Speech adaptation
- artyom.say doesn't speak after some time HOT 2
- problem installing node.js HOT 2
- newPrompt returns before receiving a spoken response
- React native HOT 1
- Raspberry artyom HOT 1
- Capturing values with Regex expressions
- .say() and continuos recognition creates a loop
- Voice command
- Very handy tool, looking for progress
- Artyom does not recognize the command HOT 1
- Contentious restarting for no reason.
- Additional languages
- Is there a way for it to only recognise the defined commands?
- Speech Recognition Doesn't work on Safari standalone app on IOS<17
- Regex with wildcard
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 artyom.js.