Skip to content

Commit 8c6f890

Browse files
committed
Artyom 1.0.5
Artyom V1.0.5 - Artyom Sandbox works now on LAN. - Fix on mobile devices that recognizes the text twice. - Smart commands now accept regular expressions in the indexes array. The RegExp needs to be true in order to trigger the command in which it's assigned. - Artyom now supports Hindi (hi-IN)
1 parent 7a1240e commit 8c6f890

File tree

10 files changed

+293
-140
lines changed

10 files changed

+293
-140
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Nodemon will restart the server automatically everytime you make changes in Arty
104104
npm run sandbox
105105
```
106106

107-
With any of the previous methods, navigate to https://localhost:8443 and explore artyom in your browser.
107+
With any of the previous methods, navigate to `https://localhost:8443` and explore artyom in your browser. You can directly debug the sandbox from mobile devices in the Local Area Network ([read this article for more information](http://ourcodeworld.com/articles/read/404/how-to-use-the-artyom-js-sandbox-on-lan-connected-devices)).
108108

109109
# Languages
110110

@@ -114,7 +114,7 @@ Artyom provides **complete** support for the following languages. Every language
114114
------------- | ------------- | ------------- |
115115
|<img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-usa.png" alt="Supported language"/>| English (USA)<br/>English (Great Britain) Great Britain| en-US<br/>en-GB |
116116
|<img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-spanish.png" alt="Supported language"/>| Español | es-ES |
117-
|<img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-german.png" alt="Supported language"/>| Deutsch | de-DE |
117+
|<img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-german.png" alt="Supported language"/>| Deutsch (German) | de-DE |
118118
| <img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-italy.png" alt="Supported language"/> | Italiano |it-IT |
119119
| <img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-france.png" alt="Supported language"/> | Français |fr-FR |
120120
| <img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-japan.png" alt="Supported language"/> | Japanese 日本人 | ja-JP |
@@ -124,6 +124,7 @@ Artyom provides **complete** support for the following languages. Every language
124124
| <img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-poland.png" alt="Supported language"/> | Polski (polonia)| pl-PL |
125125
| <img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-indonesia.png" alt="Supported language"/> | Indonesian (Indonesia)| id-ID |
126126
| <img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-china.png" alt="Supported language"/> | Chinese (Cantonese[ 粤語(香港)] <br/> Mandarin[普通话(中国大陆)])| Cantonese<br/>zh-HK<br/> Mandarin<br />zh-CN|
127+
|<img src="https://raw.githubusercontent.com/sdkcarlos/sdkcarlos.github.io/master/sites/artyom-resources/images/flag-hindi.png" alt="Supported language" />| Hindi (India) | hi-IN |
127128

128129
# All you need to know about Artyom
129130

@@ -177,6 +178,14 @@ artyom.addCommands([
177178
action: (i,wildcard) => {
178179
artyom.say("You've said : "+ wildcard);
179180
}
181+
},
182+
// The smart commands support regular expressions
183+
{
184+
indexes: [/Good Morning/i],
185+
smart:true,
186+
action: (i,wildcard) => {
187+
artyom.say("You've said : "+ wildcard);
188+
}
180189
}
181190
]);
182191

build-vanilla/artyom.js

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Artyom.js requires webkitSpeechRecognition and speechSynthesis APIs
33
*
44
* @license MIT
5-
* @version 1.0.4
5+
* @version 1.0.5
66
* @copyright 2017 Our Code World All Rights Reserved.
77
* @author Carlos Delgado - www.ourcodeworld.com
88
* @param {Object} window
@@ -81,6 +81,7 @@
8181
france: ["Google français","fr-FR","fr_FR"],
8282
polski: ["Google polski","pl-PL","pl_PL"],
8383
indonesia: ["Google Bahasa Indonesia","id-ID","id_ID"],
84+
hindi: ["Google हिन्दी","hi-IN", "hi_IN"],
8485
mandarinChinese: ["Google 普通话(中国大陆)","zh-CN","zh_CN"],
8586
cantoneseChinese: ["Google 粤語(香港)","zh-HK","zh_HK"],
8687
native: ["native"]
@@ -167,6 +168,9 @@
167168
case 'id-ID':
168169
voiceIdentifiersArray = artyomLanguages.indonesia;
169170
break;
171+
case 'hi-IN':
172+
voiceIdentifiersArray = artyomLanguages.hindi;
173+
break;
170174
case 'pl-PL':
171175
voiceIdentifiersArray = artyomLanguages.polski;
172176
break;
@@ -718,11 +722,22 @@
718722
var artyom_hey = function (resolve, reject) {
719723
var start_timestamp;
720724
var artyom_is_allowed;
725+
726+
/**
727+
* On mobile devices the recognized text is always thrown twice.
728+
* By setting the following configuration, fixes the issue
729+
*/
730+
if(artyom.device.isMobile){
731+
reconocimiento.continuous = false;
732+
reconocimiento.interimResults = false;
733+
reconocimiento.maxAlternatives = 1;
734+
}else{
735+
reconocimiento.continuous = true;
736+
reconocimiento.interimResults = true;
737+
}
721738

722-
reconocimiento.continuous = true;
723-
reconocimiento.interimResults = true;
724739
reconocimiento.lang = artyomProperties.lang;
725-
740+
726741
reconocimiento.onstart = function () {
727742
artyom.debug("Event reached : " + artyom_global_events.COMMAND_RECOGNITION_START);
728743
artyom_triggerEvent(artyom_global_events.COMMAND_RECOGNITION_START);
@@ -1078,39 +1093,49 @@
10781093
continue;//Jump if is not smart command
10791094
}
10801095

1081-
if (opcion.indexOf("*") != -1) {
1082-
///LOGIC HERE
1083-
var grupo = opcion.split("*");
1084-
1085-
if (grupo.length > 2) {
1086-
console.warn("Artyom found a smart command with " + (grupo.length - 1) + " wildcards. Artyom only support 1 wildcard for each command. Sorry");
1087-
continue;
1096+
// Process RegExp
1097+
if(opcion instanceof RegExp){
1098+
// If RegExp matches
1099+
if(opcion.test(voz)){
1100+
artyom.debug(">> REGEX "+ opcion.toString() + " MATCHED AGAINST " + voz + " WITH INDEX " + c + " IN COMMAND ", "info");
1101+
encontrado = parseInt(c);
10881102
}
1089-
//START SMART COMMAND
1090-
1091-
var before = grupo[0];
1092-
var later = grupo[1];
1103+
// Otherwise just wildcards
1104+
}else{
1105+
if (opcion.indexOf("*") != -1) {
1106+
///LOGIC HERE
1107+
var grupo = opcion.split("*");
10931108

1094-
//Wildcard in the end
1095-
if ((later == "") || (later == " ")) {
1096-
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1097-
var wildy = voz.replace(before, '');
1098-
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '');
1099-
encontrado = parseInt(c);
1109+
if (grupo.length > 2) {
1110+
console.warn("Artyom found a smart command with " + (grupo.length - 1) + " wildcards. Artyom only support 1 wildcard for each command. Sorry");
1111+
continue;
11001112
}
1101-
} else {
1102-
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1103-
if ((voz.indexOf(later) != -1) || ((voz.toLowerCase()).indexOf(later.toLowerCase()) != -1)) {
1104-
var wildy = voz.replace(before, '').replace(later, '');
1105-
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '').replace(later.toLowerCase(), '');
1113+
//START SMART COMMAND
1114+
1115+
var before = grupo[0];
1116+
var later = grupo[1];
11061117

1107-
wildy = (wildy.toLowerCase()).replace(later.toLowerCase(), '');
1118+
//Wildcard in the end
1119+
if ((later == "") || (later == " ")) {
1120+
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1121+
var wildy = voz.replace(before, '');
1122+
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '');
11081123
encontrado = parseInt(c);
11091124
}
1125+
} else {
1126+
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1127+
if ((voz.indexOf(later) != -1) || ((voz.toLowerCase()).indexOf(later.toLowerCase()) != -1)) {
1128+
var wildy = voz.replace(before, '').replace(later, '');
1129+
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '').replace(later.toLowerCase(), '');
1130+
1131+
wildy = (wildy.toLowerCase()).replace(later.toLowerCase(), '');
1132+
encontrado = parseInt(c);
1133+
}
1134+
}
11101135
}
1136+
} else {
1137+
console.warn("Founded command marked as SMART but have no wildcard in the indexes, remove the SMART for prevent extensive memory consuming or add the wildcard *");
11111138
}
1112-
} else {
1113-
console.warn("Founded command marked as SMART but have no wildcard in the indexes, remove the SMART for prevent extensive memory consuming or add the wildcard *");
11141139
}
11151140

11161141
if ((encontrado >= 0)) {
@@ -1614,7 +1639,7 @@
16141639
* @returns {String}
16151640
*/
16161641
artyom.getVersion = function () {
1617-
return "1.0.4";
1642+
return "1.0.5";
16181643
};
16191644

16201645
/**

build-vanilla/artyom.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

development/artyom-source/artyom.js

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
france: ["Google français","fr-FR","fr_FR"],
7575
polski: ["Google polski","pl-PL","pl_PL"],
7676
indonesia: ["Google Bahasa Indonesia","id-ID","id_ID"],
77+
hindi: ["Google हिन्दी","hi-IN", "hi_IN"],
7778
mandarinChinese: ["Google 普通话(中国大陆)","zh-CN","zh_CN"],
7879
cantoneseChinese: ["Google 粤語(香港)","zh-HK","zh_HK"],
7980
native: ["native"]
@@ -160,6 +161,9 @@
160161
case 'id-ID':
161162
voiceIdentifiersArray = artyomLanguages.indonesia;
162163
break;
164+
case 'hi-IN':
165+
voiceIdentifiersArray = artyomLanguages.hindi;
166+
break;
163167
case 'pl-PL':
164168
voiceIdentifiersArray = artyomLanguages.polski;
165169
break;
@@ -711,11 +715,22 @@
711715
var artyom_hey = function (resolve, reject) {
712716
var start_timestamp;
713717
var artyom_is_allowed;
718+
719+
/**
720+
* On mobile devices the recognized text is always thrown twice.
721+
* By setting the following configuration, fixes the issue
722+
*/
723+
if(artyom.device.isMobile){
724+
reconocimiento.continuous = false;
725+
reconocimiento.interimResults = false;
726+
reconocimiento.maxAlternatives = 1;
727+
}else{
728+
reconocimiento.continuous = true;
729+
reconocimiento.interimResults = true;
730+
}
714731

715-
reconocimiento.continuous = true;
716-
reconocimiento.interimResults = true;
717732
reconocimiento.lang = artyomProperties.lang;
718-
733+
719734
reconocimiento.onstart = function () {
720735
artyom.debug("Event reached : " + artyom_global_events.COMMAND_RECOGNITION_START);
721736
artyom_triggerEvent(artyom_global_events.COMMAND_RECOGNITION_START);
@@ -1071,39 +1086,49 @@
10711086
continue;//Jump if is not smart command
10721087
}
10731088

1074-
if (opcion.indexOf("*") != -1) {
1075-
///LOGIC HERE
1076-
var grupo = opcion.split("*");
1077-
1078-
if (grupo.length > 2) {
1079-
console.warn("Artyom found a smart command with " + (grupo.length - 1) + " wildcards. Artyom only support 1 wildcard for each command. Sorry");
1080-
continue;
1089+
// Process RegExp
1090+
if(opcion instanceof RegExp){
1091+
// If RegExp matches
1092+
if(opcion.test(voz)){
1093+
artyom.debug(">> REGEX "+ opcion.toString() + " MATCHED AGAINST " + voz + " WITH INDEX " + c + " IN COMMAND ", "info");
1094+
encontrado = parseInt(c);
10811095
}
1082-
//START SMART COMMAND
1083-
1084-
var before = grupo[0];
1085-
var later = grupo[1];
1096+
// Otherwise just wildcards
1097+
}else{
1098+
if (opcion.indexOf("*") != -1) {
1099+
///LOGIC HERE
1100+
var grupo = opcion.split("*");
10861101

1087-
//Wildcard in the end
1088-
if ((later == "") || (later == " ")) {
1089-
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1090-
var wildy = voz.replace(before, '');
1091-
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '');
1092-
encontrado = parseInt(c);
1102+
if (grupo.length > 2) {
1103+
console.warn("Artyom found a smart command with " + (grupo.length - 1) + " wildcards. Artyom only support 1 wildcard for each command. Sorry");
1104+
continue;
10931105
}
1094-
} else {
1095-
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1096-
if ((voz.indexOf(later) != -1) || ((voz.toLowerCase()).indexOf(later.toLowerCase()) != -1)) {
1097-
var wildy = voz.replace(before, '').replace(later, '');
1098-
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '').replace(later.toLowerCase(), '');
1106+
//START SMART COMMAND
1107+
1108+
var before = grupo[0];
1109+
var later = grupo[1];
10991110

1100-
wildy = (wildy.toLowerCase()).replace(later.toLowerCase(), '');
1111+
//Wildcard in the end
1112+
if ((later == "") || (later == " ")) {
1113+
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1114+
var wildy = voz.replace(before, '');
1115+
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '');
11011116
encontrado = parseInt(c);
11021117
}
1118+
} else {
1119+
if ((voz.indexOf(before) != -1) || ((voz.toLowerCase()).indexOf(before.toLowerCase()) != -1)) {
1120+
if ((voz.indexOf(later) != -1) || ((voz.toLowerCase()).indexOf(later.toLowerCase()) != -1)) {
1121+
var wildy = voz.replace(before, '').replace(later, '');
1122+
wildy = (wildy.toLowerCase()).replace(before.toLowerCase(), '').replace(later.toLowerCase(), '');
1123+
1124+
wildy = (wildy.toLowerCase()).replace(later.toLowerCase(), '');
1125+
encontrado = parseInt(c);
1126+
}
1127+
}
11031128
}
1129+
} else {
1130+
console.warn("Founded command marked as SMART but have no wildcard in the indexes, remove the SMART for prevent extensive memory consuming or add the wildcard *");
11041131
}
1105-
} else {
1106-
console.warn("Founded command marked as SMART but have no wildcard in the indexes, remove the SMART for prevent extensive memory consuming or add the wildcard *");
11071132
}
11081133

11091134
if ((encontrado >= 0)) {
@@ -1607,7 +1632,7 @@
16071632
* @returns {String}
16081633
*/
16091634
artyom.getVersion = function () {
1610-
return "1.0.4";
1635+
return "1.0.5";
16111636
};
16121637

16131638
/**
@@ -1665,4 +1690,4 @@
16651690
console.info("Artyom has been already defined in the Window");
16661691
}
16671692

1668-
})(window);
1693+
})(window);

development/artyom-source/artyomCommands.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,10 @@
6060
artyom.say(wildcard);
6161
});
6262

63+
// Matches "regular expressions" case insensitive
64+
artyom.on([/regular expressions/i], true).then(function(){
65+
artyom.say("The usage of regular expressions is allowed in the smart commands");
66+
});
67+
6368
console.log(artyom.getAvailableCommands());
6469
})(window);

0 commit comments

Comments
 (0)