Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
aivoice_plugin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王苏进
aivoice_plugin
Commits
2830ee85
提交
2830ee85
authored
9月 15, 2024
作者:
王苏进
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 语音识别相关
上级
49603dc4
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
4 行删除
+21
-4
AivoicePlugin.kt
...c/main/kotlin/com/example/aivoice_plugin/AivoicePlugin.kt
+10
-3
AsrCenter.java
...src/main/kotlin/com/example/aivoice_plugin/AsrCenter.java
+11
-1
没有找到文件。
android/src/main/kotlin/com/example/aivoice_plugin/AivoicePlugin.kt
浏览文件 @
2830ee85
...
...
@@ -53,6 +53,7 @@ class AivoicePlugin: FlutterPlugin, MethodCallHandler, EventChannel.StreamHandle
asrConfig
=
call
.
arguments
as
Map
<
String
,
String
>?
// 现有的实现
asrCenter
.
initEngineBtnClicked
()
asrCenter
.
startEngineBtnClicked
()
}
"stopEngine"
->
{
// 现有的实现
...
...
@@ -63,12 +64,16 @@ class AivoicePlugin: FlutterPlugin, MethodCallHandler, EventChannel.StreamHandle
asrCenter
.
uninitEngineBtnClicked
()
}
"startOrStopEngine"
->
{
// 现有的实现
if
(
call
.
arguments
==
true
)
{
asrCenter
.
startEngineBtnClicked
()
}
else
{
asrCenter
.
stopEngineBtnClicked
()
}
}
"prepareEnvironment"
->
{
val
re
=
SpeechEngineGenerator
.
PrepareEnvironment
(
context
,
context
as
Application
?)
println
(
"prepare:===>$re"
)
}
"ttsStartEngineBtnClick"
->
{
println
(
"来自安卓"
)
...
...
@@ -106,6 +111,7 @@ class AivoicePlugin: FlutterPlugin, MethodCallHandler, EventChannel.StreamHandle
}
"destoryAsrVoice"
->
{
// 空实现
asrCenter
.
destroy
();
result
.
success
(
null
)
}
else
->
{
...
...
@@ -128,8 +134,9 @@ class AivoicePlugin: FlutterPlugin, MethodCallHandler, EventChannel.StreamHandle
this
.
events
=
null
}
fun
sendMessageToFlutter
(
message
:
Map
<*,
*>?)
{
private
fun
sendMessageToFlutter
(
message
:
Map
<*,
*>?)
{
if
(
events
!=
null
)
{
context
.
run
{
}
events
?.
success
(
message
)
}
}
...
...
android/src/main/kotlin/com/example/aivoice_plugin/AsrCenter.java
浏览文件 @
2830ee85
...
...
@@ -10,6 +10,7 @@ import android.content.pm.PackageManager;
import
android.os.Build
;
import
android.os.Environment
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.util.Log
;
//import androidx.lifecycle.LifecycleObserver;
//import androidx.lifecycle.ProcessLifecycleOwner;
...
...
@@ -122,7 +123,7 @@ public class AsrCenter implements SpeechEngine.SpeechListener {
}
public
void
onD
estroy
()
{
public
void
d
estroy
()
{
Log
.
i
(
SpeechDemoDefines
.
TAG
,
"Asr onDestroy"
);
uninitEngine
();
...
...
@@ -324,6 +325,7 @@ public class AsrCenter implements SpeechEngine.SpeechListener {
public
void
startEngineBtnClicked
()
{
Log
.
i
(
SpeechDemoDefines
.
TAG
,
"配置启动参数."
);
configStartAsrParams
();
//【可选配置】是否启用云端自动判停,仅一句话识别场景生效
Log
.
i
(
SpeechDemoDefines
.
TAG
,
"开启 ASR 云端自动判停"
);
...
...
@@ -488,6 +490,9 @@ public class AsrCenter implements SpeechEngine.SpeechListener {
mFinishTalkingTimestamp
=
0
;
}
final
long
response_delay
=
delay
;
new
Handler
(
Looper
.
getMainLooper
()).
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
// 从回调的 json 数据中解析 ASR 结果
JSONObject
reader
=
new
JSONObject
(
data
);
...
...
@@ -511,6 +516,11 @@ public class AsrCenter implements SpeechEngine.SpeechListener {
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
});
}
public
void
speechError
(
final
String
data
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论