mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-31 02:33:44 +00:00
tweaked SpeechTools
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8953 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
61d081ee59
commit
53fda0eeca
@ -194,7 +194,6 @@ function SpeechDetect(session, mod, ip) {
|
|||||||
rv.push("_no_idea_");
|
rv.push("_no_idea_");
|
||||||
}
|
}
|
||||||
|
|
||||||
console_log("debug", "dammit: " + rv + "\n");
|
|
||||||
delete interp;
|
delete interp;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -287,6 +286,14 @@ function SpeechObtainer(asr, req, wait_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.addItemAlias = function(item,alias) {
|
||||||
|
ia = item.split(",");
|
||||||
|
var x;
|
||||||
|
for (x = 0; x < ia.length; x++) {
|
||||||
|
this.items[this.index++] = ia[x] + ":::" + alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Add a regex */
|
/* Add a regex */
|
||||||
this.addRegEx = function(item) {
|
this.addRegEx = function(item) {
|
||||||
this.items[this.index++] = item;
|
this.items[this.index++] = item;
|
||||||
@ -404,29 +411,41 @@ function SpeechObtainer(asr, req, wait_time) {
|
|||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
console_log("debug", "----Testing [" + y + "] [" + x + "] " + items[y] + " =~ [" + this.items[x] + "]\n");
|
console_log("debug", "----Testing [" + y + "] [" + x + "] " + items[y] + " =~ [" + this.items[x] + "]\n");
|
||||||
}
|
}
|
||||||
var re = new RegExp(this.items[x]);
|
str = this.items[x];
|
||||||
|
|
||||||
|
ab = str.split(":::");
|
||||||
|
|
||||||
|
var re = new RegExp(ab[0], "i");
|
||||||
match = re.exec(items[y]);
|
match = re.exec(items[y]);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
||||||
for (i = 0; i < match.length; i++) {
|
for (i = 0; i < match.length; i++) {
|
||||||
|
if (ab.length == 1) {
|
||||||
|
rep = match[i];
|
||||||
|
} else {
|
||||||
|
rep = ab[1];
|
||||||
|
}
|
||||||
|
|
||||||
dup = false;
|
dup = false;
|
||||||
for(z = 0; z < this.collected_items.length; z++) {
|
for(z = 0; z < this.collected_items.length; z++) {
|
||||||
if (this.collected_items[z] == match[i]) {
|
if (this.collected_items[z] == rep) {
|
||||||
dup = true;
|
dup = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dup) {
|
if (dup) {
|
||||||
if (this.dup_sound) {
|
if (this.dup_sound) {
|
||||||
rv = this.react(this.dup_sound + " " + match[i], this.dup_sound + "," + match[i]);
|
rv = this.react(this.dup_sound + " " + rep, this.dup_sound + "," + rep);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
console_log("debug", "----Adding " + match[i] + "\n");
|
console_log("debug", "----Adding " + rep + "\n");
|
||||||
}
|
}
|
||||||
this.collected_items[this.collected_index++] = match[i];
|
this.collected_items[this.collected_index++] = rep;
|
||||||
hit = true;
|
hit = true;
|
||||||
if (this.add_sound) {
|
if (this.add_sound) {
|
||||||
rv = this.react(this.add_sound + " " + match[i], this.add_sound + "," + match[i]);
|
rv = this.react(this.add_sound + " " + rep, this.add_sound + "," + rep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user