Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
aivoice_plugin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王苏进
aivoice_plugin
Commits
a68b90f8
提交
a68b90f8
authored
9月 08, 2024
作者:
王苏进
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 补充prepare evvientmen的
上级
e1f79b8e
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
58 行增加
和
13 行删除
+58
-13
AivoicePlugin.java
...ain/java/com/yourcompany/aivoiceplugin/AivoicePlugin.java
+3
-0
AivoicePlugin.m
ios/Classes/AivoicePlugin.m
+7
-3
VoiceAsr.h
ios/Classes/VoiceAsr.h
+2
-0
VoiceAsr.m
ios/Classes/VoiceAsr.m
+13
-1
aivoice_plugin.dart
lib/aivoice_plugin.dart
+5
-0
aivoice_plugin_method_channel.dart
lib/aivoice_plugin_method_channel.dart
+5
-0
aivoice_plugin_platform_interface.dart
lib/aivoice_plugin_platform_interface.dart
+3
-0
method_channel_aivoice_plugin.dart
lib/method_channel_aivoice_plugin.dart
+20
-9
没有找到文件。
android/src/main/java/com/yourcompany/aivoiceplugin/AivoicePlugin.java
浏览文件 @
a68b90f8
...
...
@@ -40,6 +40,9 @@ public class AivoicePlugin implements FlutterPlugin, MethodCallHandler, EventCha
}
else
if
(
call
.
method
.
equals
(
"startOrStopEngine"
))
{
// 空实现
result
.
success
(
null
);
}
else
if
(
call
.
method
.
equals
(
"prepareEnvironment"
))
{
// 空实现
result
.
success
(
null
);
}
else
{
result
.
notImplemented
();
}
...
...
ios/Classes/AivoicePlugin.m
浏览文件 @
a68b90f8
...
...
@@ -21,10 +21,8 @@
eventChannelWithName
:
@"aivoice_plugin/events"
binaryMessenger
:[
registrar
messenger
]];
[
eventChannel
setStreamHandler
:
instance
];
}
}
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
// 删除了 getPlatformVersion 方法的实现
...
...
@@ -43,6 +41,10 @@
// BOOL arg = [NSNumber numberWithBool:call.arguments];
[
self
.
voiceAsr
startEngineBtnClicked
];
result
(
nil
);
}
else
if
([
@"prepareEnvironment"
isEqualToString
:
call
.
method
])
{
[
VoiceAsr
prepareEnvironment
:
call
.
arguments
];
result
(
nil
);
}
else
{
result
(
FlutterMethodNotImplemented
);
}
...
...
@@ -72,8 +74,10 @@
return
_voiceAsr
;
}
-
(
void
)
onRecieve
:
(
nonnull
NSDictionary
*
)
message
{
[
self
sendMessageToFlutter
:
message
];
}
@end
ios/Classes/VoiceAsr.h
浏览文件 @
a68b90f8
...
...
@@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
-
(
instancetype
)
initWithDelegate
:(
id
<
VoiceAsrDelegate
>
)
delegate
;
+
(
void
)
prepareEnvironment
:(
NSDictionary
*
)
config
;
-
(
void
)
initEngine
;
-
(
void
)
uninitEngine
;
...
...
ios/Classes/VoiceAsr.m
浏览文件 @
a68b90f8
...
...
@@ -63,7 +63,19 @@
#pragma mark - UI Actions
+
(
void
)
prepareEnvironment
:
(
NSDictionary
*
)
config
{
BOOL
status
=
[
SpeechEngine
prepareEnvironment
];
NSString
*
appId
=
config
[
@"appId"
];
if
(
status
)
{
SpeechResourceManager
*
speechResourceManager
=
[
SpeechResourceManager
shareInstance
];
[
speechResourceManager
setAppId
:
SDEF_APPID
];
[
speechResourceManager
setAppVersion
:
@"1.0.0"
];
// [speechResourceManager setDeviceId:self.deviceID];
[
speechResourceManager
setRootPath
:
[
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
).
firstObject
stringByAppendingPathComponent
:
@"models"
]];
[
speechResourceManager
setOnlineModelEnable
:
YES
];
[
speechResourceManager
setup
];
}
}
-
(
void
)
startEngineBtnClicked
{
[
self
setResultText
:
@""
];
...
...
lib/aivoice_plugin.dart
浏览文件 @
a68b90f8
...
...
@@ -25,6 +25,11 @@ class AivoicePlugin {
return
AivoicePluginPlatform
.
instance
.
startOrStopEngine
(
isBegin
);
}
// 新增的 prepareEnvironment 方法
Future
<
void
>
prepareEnvironment
(
Map
<
String
,
dynamic
>
config
)
{
return
AivoicePluginPlatform
.
instance
.
prepareEnvironment
(
config
);
}
// 新增的监听方法
static
const
EventChannel
_eventChannel
=
EventChannel
(
'aivoice_plugin/events'
);
...
...
lib/aivoice_plugin_method_channel.dart
浏览文件 @
a68b90f8
...
...
@@ -30,4 +30,9 @@ class MethodChannelAivoicePlugin extends AivoicePluginPlatform {
Future
<
void
>
startOrStopEngine
(
bool
isBegin
)
async
{
await
methodChannel
.
invokeMethod
<
void
>(
'startOrStopEngine'
,
{
'isBegin'
:
isBegin
});
}
@override
Future
<
void
>
prepareEnvironment
(
Map
<
String
,
dynamic
>
config
)
async
{
await
methodChannel
.
invokeMethod
<
void
>(
'prepareEnvironment'
,
config
);
}
}
lib/aivoice_plugin_platform_interface.dart
浏览文件 @
a68b90f8
...
...
@@ -36,4 +36,7 @@ abstract class AivoicePluginPlatform extends PlatformInterface {
// 新增的 startOrStopEngine 方法
Future
<
void
>
startOrStopEngine
(
bool
isBegin
);
// 新增的 prepareEnvironment 方法
Future
<
void
>
prepareEnvironment
(
Map
<
String
,
dynamic
>
config
);
}
lib/method_channel_aivoice_plugin.dart
浏览文件 @
a68b90f8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'aivoice_plugin_platform_interface.dart'
;
/// An implementation of [AivoicePluginPlatform] that uses method channels.
class
MethodChannelAivoicePlugin
extends
AivoicePluginPlatform
{
final
MethodChannel
_channel
=
const
MethodChannel
(
'aivoice_plugin'
);
/// The method channel used to interact with the native platform.
@visibleForTesting
final
methodChannel
=
const
MethodChannel
(
'aivoice_plugin'
);
// 删除了 getPlatformVersion 方法
@override
Future
<
void
>
initEngine
(
Map
<
String
,
dynamic
>
config
)
async
{
await
methodChannel
.
invokeMethod
<
void
>(
'initEngine'
,
config
);
}
@override
Future
<
void
>
initEngine
(
Map
<
String
,
dynamic
>
config
)
{
return
_channel
.
invokeMethod
<
void
>(
'initEngine'
,
config
);
Future
<
void
>
stopEngine
()
async
{
await
methodChannel
.
invokeMethod
<
void
>(
'stopEngine'
);
}
@override
Future
<
void
>
stopEngine
()
{
return
_channel
.
invokeMethod
<
void
>(
'stop
Engine'
);
Future
<
void
>
uninitEngine
()
async
{
await
methodChannel
.
invokeMethod
<
void
>(
'uninit
Engine'
);
}
@override
Future
<
void
>
uninitEngine
()
{
return
_channel
.
invokeMethod
<
void
>(
'uninitEngine'
);
Future
<
void
>
startOrStopEngine
(
bool
isBegin
)
async
{
await
methodChannel
.
invokeMethod
<
void
>(
'startOrStopEngine'
,
{
'isBegin'
:
isBegin
}
);
}
@override
Future
<
void
>
startOrStopEngine
(
bool
isBegin
)
{
return
_channel
.
invokeMethod
<
void
>(
'startOrStopEngine'
,
{
'isBegin'
:
isBegin
}
);
Future
<
void
>
prepareEnvironment
(
Map
<
String
,
dynamic
>
config
)
async
{
await
methodChannel
.
invokeMethod
<
void
>(
'prepareEnvironment'
,
config
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论