Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
964e2e98
提交
964e2e98
authored
11月 10, 2006
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@3299
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
351480b9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
60 行增加
和
37 行删除
+60
-37
SpeechTools.jm
scripts/js_modules/SpeechTools.jm
+42
-25
mod_spidermonkey.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
+18
-12
没有找到文件。
scripts/js_modules/SpeechTools.jm
浏览文件 @
964e2e98
...
@@ -155,19 +155,19 @@ function SpeechDetect(session, mod, ip) {
...
@@ -155,19 +155,19 @@ function SpeechDetect(session, mod, ip) {
if (!_this.grammar_name) {
if (!_this.grammar_name) {
console_log("error", "No Grammar name!\n");
console_log("error", "No Grammar name!\n");
_this.session.hangup();
_this.session.hangup();
return;
return
false
;
}
}
var grammar_object = _this.grammar_hash[_this.grammar_name];
var grammar_object = _this.grammar_hash[_this.grammar_name];
if (!grammar_object) {
if (!grammar_object) {
console_log("error", "Can't find grammar for " + _this.grammar_name + "\n");
console_log("error", "Can't find grammar for " + _this.grammar_name + "\n");
_this.session.hangup();
_this.session.hangup();
return;
return
false
;
}
}
if (speech_type == "begin-speaking") {
if (speech_type == "begin-speaking") {
if (grammar_object.halt) {
if (grammar_object.halt) {
return;
return
false
;
}
}
} else {
} else {
var body = inputEvent.getBody();
var body = inputEvent.getBody();
...
@@ -176,29 +176,27 @@ function SpeechDetect(session, mod, ip) {
...
@@ -176,29 +176,27 @@ function SpeechDetect(session, mod, ip) {
_this.lastDetect = body;
_this.lastDetect = body;
if (_this.debug) {
if (_this.debug) {
console_log("debug", "----XML:\n" + body);
console_log("debug", "----XML:\n" + body
+ "\n"
);
console_log("debug", "----Heard [" + interp.input + "]\n");
console_log("debug", "----Heard [" + interp.input + "]\n");
console_log("debug", "----Hit score " + interp.@score + "\n");
console_log("debug", "----Hit score " + interp.@score + "
/" + grammar_object.min_score + "/" + grammar_object.confirm_score + "
\n");
}
}
if (interp.@score < grammar_object.min_score) {
if (interp.@score >= grammar_object.min_score) {
delete interp;
rv.push("_no_idea_");
return rv;
} else {
if (interp.@score < grammar_object.confirm_score) {
if (interp.@score < grammar_object.confirm_score) {
rv.push("_confirm_");
rv.push("_confirm_");
}
}
eval("xo = interp." + grammar_object.obj_path + ";");
eval("xo = interp." + grammar_object.obj_path + ";");
for (x = 0; x < xo.length(); x++) {
for (x = 0; x < xo.length(); x++) {
rv.push(xo[x]);
rv.push(xo[x]);
}
}
} else {
delete interp;
rv.push("_no_idea_");
return rv;
}
}
console_log("debug", "dammit: " + rv + "\n");
delete interp;
return rv;
}
}
}
}
}
}
...
@@ -331,16 +329,27 @@ function SpeechObtainer(asr, req, wait_time) {
...
@@ -331,16 +329,27 @@ function SpeechObtainer(asr, req, wait_time) {
this.react = function(say_str, play_str) {
this.react = function(say_str, play_str) {
var rv;
var rv;
this.asr.resume();
if (this.tts_eng && this.tts_voice) {
if (!rv) {
rv = this.speak(say_str);
rv = this.asr.session.collectInput(this.asr.onInput, this.asr, 500);
} else {
}
rv = this.streamFile(play_str);
if (!rv) {
this.asr.resume();
if (this.tts_eng && this.tts_voice) {
rv = this.speak(say_str);
} else {
rv = this.streamFile(play_str);
}
}
}
if (!rv) {
if (!rv) {
rv = this.asr.session.collectInput(this.asr.onInput, this.asr, 500);
rv = this.asr.session.collectInput(this.asr.onInput, this.asr, 500);
}
}
if (rv && !rv[0]) {
rv = false;
}
return rv;
return rv;
}
}
...
@@ -374,8 +383,16 @@ function SpeechObtainer(asr, req, wait_time) {
...
@@ -374,8 +383,16 @@ function SpeechObtainer(asr, req, wait_time) {
}
}
hit = false;
hit = false;
if (rv) {
if (rv) {
for (y = 0; y < rv.length; y++) {
var items = rv;
if (rv[y] == "_confirm_") {
rv = undefined;
for (y = 0; y < items.length; y++) {
if (items[y] == "_no_idea_") {
if (this.debug) {
console_log("debug", "----We don't understand this\n");
}
break;
}
if (items[y] == "_confirm_") {
this.needConfirm = true;
this.needConfirm = true;
if (this.debug) {
if (this.debug) {
console_log("debug", "----We need to confirm this one\n");
console_log("debug", "----We need to confirm this one\n");
...
@@ -385,10 +402,10 @@ function SpeechObtainer(asr, req, wait_time) {
...
@@ -385,10 +402,10 @@ function SpeechObtainer(asr, req, wait_time) {
for(x = 0 ; x < this.index; x++) {
for(x = 0 ; x < this.index; x++) {
if (this.debug) {
if (this.debug) {
console_log("debug", "----Testing
" + rv
[y] + " =~ [" + this.items[x] + "]\n");
console_log("debug", "----Testing
[" + y + "] [" + x + "] " + items
[y] + " =~ [" + this.items[x] + "]\n");
}
}
var re = new RegExp(this.items[x]);
var re = new RegExp(this.items[x]);
match = re.exec(
rv
[y]);
match = re.exec(
items
[y]);
if (match) {
if (match) {
for (i = 0; i < match.length; i++) {
for (i = 0; i < match.length; i++) {
dup = false;
dup = false;
...
@@ -419,7 +436,7 @@ function SpeechObtainer(asr, req, wait_time) {
...
@@ -419,7 +436,7 @@ function SpeechObtainer(asr, req, wait_time) {
}
}
if (!rv) {
if (!rv) {
rv = this.asr.session.collectInput(this.asr.onInput, this.asr,
5
00);
rv = this.asr.session.collectInput(this.asr.onInput, this.asr,
10
00);
}
}
if (!rv && !hit && !dup) {
if (!rv && !hit && !dup) {
...
...
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
浏览文件 @
964e2e98
...
@@ -547,7 +547,8 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
...
@@ -547,7 +547,8 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
if
((
status
=
js_common_callback
(
session
,
input
,
itype
,
buf
,
buflen
))
!=
SWITCH_STATUS_SUCCESS
)
{
if
((
status
=
js_common_callback
(
session
,
input
,
itype
,
buf
,
buflen
))
!=
SWITCH_STATUS_SUCCESS
)
{
return
status
;
return
status
;
}
}
if
((
ret
=
JS_GetStringBytes
(
JS_ValueToString
(
cb_state
->
cx
,
cb_state
->
ret
))))
{
if
((
ret
=
JS_GetStringBytes
(
JS_ValueToString
(
cb_state
->
cx
,
cb_state
->
ret
))))
{
if
(
!
strncasecmp
(
ret
,
"speed"
,
4
))
{
if
(
!
strncasecmp
(
ret
,
"speed"
,
4
))
{
char
*
p
;
char
*
p
;
...
@@ -611,10 +612,11 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
...
@@ -611,10 +612,11 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
}
}
if
(
!
strcmp
(
ret
,
"true"
)
||
!
strcmp
(
ret
,
"undefined"
))
{
if
(
!
strcmp
(
ret
,
"true"
)
||
!
strcmp
(
ret
,
"undefined"
))
{
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
return
SWITCH_STATUS_BREAK
;
return
SWITCH_STATUS_BREAK
;
}
}
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -646,10 +648,11 @@ static switch_status_t js_record_input_callback(switch_core_session_t *session,
...
@@ -646,10 +648,11 @@ static switch_status_t js_record_input_callback(switch_core_session_t *session,
}
}
if
(
!
strcmp
(
ret
,
"true"
)
||
!
strcmp
(
ret
,
"undefined"
))
{
if
(
!
strcmp
(
ret
,
"true"
)
||
!
strcmp
(
ret
,
"undefined"
))
{
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
return
SWITCH_STATUS_BREAK
;
return
SWITCH_STATUS_BREAK
;
}
}
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
...
@@ -669,9 +672,11 @@ static switch_status_t js_collect_input_callback(switch_core_session_t *session,
...
@@ -669,9 +672,11 @@ static switch_status_t js_collect_input_callback(switch_core_session_t *session,
if
(
!
strcmp
(
ret
,
"true"
)
||
!
strcmp
(
ret
,
"undefined"
))
{
if
(
!
strcmp
(
ret
,
"true"
)
||
!
strcmp
(
ret
,
"undefined"
))
{
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
return
SWITCH_STATUS_BREAK
;
}
}
return
SWITCH_STATUS_BREAK
;
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -749,7 +754,7 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
...
@@ -749,7 +754,7 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
memset
(
&
fh
,
0
,
sizeof
(
fh
));
memset
(
&
fh
,
0
,
sizeof
(
fh
));
cb_state
.
extra
=
&
fh
;
cb_state
.
extra
=
&
fh
;
cb_state
.
ret
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
switch_ivr_record_file
(
jss
->
session
,
&
fh
,
file_name
,
dtmf_func
,
bp
,
len
);
switch_ivr_record_file
(
jss
->
session
,
&
fh
,
file_name
,
dtmf_func
,
bp
,
len
);
*
rval
=
cb_state
.
ret
;
*
rval
=
cb_state
.
ret
;
...
@@ -794,7 +799,7 @@ static JSBool session_collect_input(JSContext *cx, JSObject *obj, uintN argc, js
...
@@ -794,7 +799,7 @@ static JSBool session_collect_input(JSContext *cx, JSObject *obj, uintN argc, js
}
}
switch_ivr_collect_digits_callback
(
jss
->
session
,
dtmf_func
,
bp
,
len
,
to
);
switch_ivr_collect_digits_callback
(
jss
->
session
,
dtmf_func
,
bp
,
len
,
to
);
*
rval
=
STRING_TO_JSVAL
(
JS_NewStringCopyZ
(
cx
,
cb_state
.
ret_buffer
))
;
*
rval
=
cb_state
.
ret
;
return
(
switch_channel_ready
(
channel
))
?
JS_TRUE
:
JS_FALSE
;
return
(
switch_channel_ready
(
channel
))
?
JS_TRUE
:
JS_FALSE
;
}
}
...
@@ -848,7 +853,7 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
...
@@ -848,7 +853,7 @@ static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval
memset
(
&
fh
,
0
,
sizeof
(
fh
));
memset
(
&
fh
,
0
,
sizeof
(
fh
));
cb_state
.
extra
=
&
fh
;
cb_state
.
extra
=
&
fh
;
cb_state
.
ret
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
switch_ivr_play_file
(
jss
->
session
,
&
fh
,
file_name
,
timer_name
,
dtmf_func
,
bp
,
len
);
switch_ivr_play_file
(
jss
->
session
,
&
fh
,
file_name
,
timer_name
,
dtmf_func
,
bp
,
len
);
*
rval
=
cb_state
.
ret
;
*
rval
=
cb_state
.
ret
;
...
@@ -948,8 +953,8 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
...
@@ -948,8 +953,8 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
}
}
}
}
if
(
argc
>
4
)
{
if
(
argc
>
5
)
{
timer_name
=
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
4
]));
timer_name
=
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
5
]));
}
}
if
(
!
tts_name
&&
text
)
{
if
(
!
tts_name
&&
text
)
{
...
@@ -957,6 +962,7 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
...
@@ -957,6 +962,7 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
}
}
codec
=
switch_core_session_get_read_codec
(
jss
->
session
);
codec
=
switch_core_session_get_read_codec
(
jss
->
session
);
cb_state
.
ret
=
BOOLEAN_TO_JSVAL
(
JS_FALSE
);
switch_ivr_speak_text
(
jss
->
session
,
switch_ivr_speak_text
(
jss
->
session
,
tts_name
,
tts_name
,
voice_name
&&
strlen
(
voice_name
)
?
voice_name
:
NULL
,
voice_name
&&
strlen
(
voice_name
)
?
voice_name
:
NULL
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论