Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
aivoice_plugin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王苏进
aivoice_plugin
Commits
84e8b07c
提交
84e8b07c
authored
9月 08, 2024
作者:
王苏进
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 调整方法
上级
a68b90f8
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
57 行增加
和
49 行删除
+57
-49
AivoicePlugin.java
...ain/java/com/yourcompany/aivoiceplugin/AivoicePlugin.java
+2
-0
AppDelegate.swift
example/ios/Runner/AppDelegate.swift
+1
-17
main.dart
example/lib/main.dart
+9
-2
AivoicePlugin.m
ios/Classes/AivoicePlugin.m
+5
-2
SensitiveDefines.h
ios/Classes/SensitiveDefines.h
+4
-4
SensitiveDefines.m
ios/Classes/SensitiveDefines.m
+4
-4
SettingsHelper.m
ios/Classes/SettingsHelper.m
+13
-12
VoiceAsr.h
ios/Classes/VoiceAsr.h
+3
-2
VoiceAsr.m
ios/Classes/VoiceAsr.m
+16
-6
没有找到文件。
android/src/main/java/com/yourcompany/aivoiceplugin/AivoicePlugin.java
浏览文件 @
84e8b07c
...
@@ -29,6 +29,8 @@ public class AivoicePlugin implements FlutterPlugin, MethodCallHandler, EventCha
...
@@ -29,6 +29,8 @@ public class AivoicePlugin implements FlutterPlugin, MethodCallHandler, EventCha
// 删除了 getPlatformVersion 方法的实现
// 删除了 getPlatformVersion 方法的实现
if
(
call
.
method
.
equals
(
"initEngine"
))
{
if
(
call
.
method
.
equals
(
"initEngine"
))
{
// 处理 config 参数
Map
<
String
,
Object
>
config
=
call
.
arguments
();
// 空实现
// 空实现
result
.
success
(
null
);
result
.
success
(
null
);
}
else
if
(
call
.
method
.
equals
(
"stopEngine"
))
{
}
else
if
(
call
.
method
.
equals
(
"stopEngine"
))
{
...
...
example/ios/Runner/AppDelegate.swift
浏览文件 @
84e8b07c
...
@@ -9,29 +9,13 @@ import aivoice_plugin
...
@@ -9,29 +9,13 @@ import aivoice_plugin
didFinishLaunchingWithOptions
launchOptions
:
[
UIApplication
.
LaunchOptionsKey
:
Any
]?
didFinishLaunchingWithOptions
launchOptions
:
[
UIApplication
.
LaunchOptionsKey
:
Any
]?
)
->
Bool
{
)
->
Bool
{
GeneratedPluginRegistrant
.
register
(
with
:
self
)
GeneratedPluginRegistrant
.
register
(
with
:
self
)
let
ret
=
SpeechEngine
.
prepareEnvironment
();
if
ret
{
setupResourceManager
()
}
return
super
.
application
(
application
,
didFinishLaunchingWithOptions
:
launchOptions
)
return
super
.
application
(
application
,
didFinishLaunchingWithOptions
:
launchOptions
)
}
}
func
setupResourceManager
()
{
let
ins
=
SpeechResourceManager
.
shareInstance
()
ins
.
setAppId
(
SDEF_APPID
)
ins
.
setAppVersion
(
"1.0.0"
)
if
let
documentDirectory
=
FileManager
.
default
.
urls
(
for
:
.
documentDirectory
,
in
:
.
userDomainMask
)
.
first
{
let
modelsPath
=
documentDirectory
.
appendingPathComponent
(
"models"
)
.
path
ins
.
setRootPath
(
modelsPath
)
}
ins
.
setOnlineModelEnable
(
true
)
ins
.
setup
()
}
}
}
example/lib/main.dart
浏览文件 @
84e8b07c
...
@@ -20,6 +20,13 @@ class _MyAppState extends State<MyApp> {
...
@@ -20,6 +20,13 @@ class _MyAppState extends State<MyApp> {
String
_text
=
''
;
String
_text
=
''
;
final
configMap
=
{
"appId"
:
"2301072440"
,
"token"
:
"Bearer;75UvJCpxRjTCppqQUkQ-o-4UfjnCgVmp"
,
"voiceType"
:
"BV213_w5H18f6VbKnhg3Ph"
,
"voice"
:
"灿灿"
};
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
...
@@ -31,7 +38,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -31,7 +38,7 @@ class _MyAppState extends State<MyApp> {
});
});
// print(event["text"]);
// print(event["text"]);
});
});
// _aivoicePlugin.initEngine({
});
_aivoicePlugin
.
prepareEnvironment
({
"appId"
:
"2301072440"
});
}
}
// Platform messages are asynchronous, so we initialize in an async method.
// Platform messages are asynchronous, so we initialize in an async method.
...
@@ -59,7 +66,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -59,7 +66,7 @@ class _MyAppState extends State<MyApp> {
children:
[
children:
[
TextButton
(
TextButton
(
onPressed:
()
{
onPressed:
()
{
_aivoicePlugin
.
initEngine
(
{}
);
_aivoicePlugin
.
initEngine
(
configMap
);
},
},
child:
const
Text
(
'init'
)),
child:
const
Text
(
'init'
)),
TextButton
(
TextButton
(
...
...
ios/Classes/AivoicePlugin.m
浏览文件 @
84e8b07c
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
@property
(
nonatomic
,
strong
)
FlutterEventSink
eventSink
;
@property
(
nonatomic
,
strong
)
FlutterEventSink
eventSink
;
@property
(
nonatomic
,
strong
)
VoiceAsr
*
voiceAsr
;
@property
(
nonatomic
,
strong
)
VoiceAsr
*
voiceAsr
;
@property
(
nonatomic
,
strong
)
NSDictionary
*
config
;
@end
@end
@implementation
AivoicePlugin
@implementation
AivoicePlugin
...
@@ -28,7 +30,8 @@
...
@@ -28,7 +30,8 @@
// 删除了 getPlatformVersion 方法的实现
// 删除了 getPlatformVersion 方法的实现
if
([
@"initEngine"
isEqualToString
:
call
.
method
])
{
if
([
@"initEngine"
isEqualToString
:
call
.
method
])
{
[
self
.
voiceAsr
initEngine
];
self
.
config
=
call
.
arguments
;
[
self
.
voiceAsr
initEngineWithConfig
:
call
.
arguments
];
result
(
nil
);
result
(
nil
);
}
else
if
([
@"stopEngine"
isEqualToString
:
call
.
method
])
{
}
else
if
([
@"stopEngine"
isEqualToString
:
call
.
method
])
{
[
self
.
voiceAsr
stopEngineBtnClicked
];
[
self
.
voiceAsr
stopEngineBtnClicked
];
...
@@ -69,7 +72,7 @@
...
@@ -69,7 +72,7 @@
-
(
VoiceAsr
*
)
voiceAsr
{
-
(
VoiceAsr
*
)
voiceAsr
{
if
(
!
_voiceAsr
)
{
if
(
!
_voiceAsr
)
{
_voiceAsr
=
[[
VoiceAsr
alloc
]
initWithDelegate
:
self
];
_voiceAsr
=
[[
VoiceAsr
alloc
]
initWithDelegate
:
self
config
:
self
.
config
];
}
}
return
_voiceAsr
;
return
_voiceAsr
;
}
}
...
...
ios/Classes/SensitiveDefines.h
浏览文件 @
84e8b07c
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
extern
NSString
*
SDEF_UID
;
extern
NSString
*
SDEF_UID
;
// Online & Resource Authentication
// Online & Resource Authentication
extern
NSString
*
SDEF_APPID
;
//
extern NSString* SDEF_APPID;
extern
NSString
*
SDEF_TOKEN
;
//
extern NSString* SDEF_TOKEN;
extern
NSString
*
SDEF_APP_VERSION
;
extern
NSString
*
SDEF_APP_VERSION
;
// Offline Authentication
// Offline Authentication
...
@@ -46,8 +46,8 @@ extern NSString* SDEF_AU_DEFAULT_URI;
...
@@ -46,8 +46,8 @@ extern NSString* SDEF_AU_DEFAULT_URI;
extern
NSString
*
SDEF_TTS_DEFAULT_URI
;
extern
NSString
*
SDEF_TTS_DEFAULT_URI
;
extern
NSString
*
SDEF_TTS_DEFAULT_CLUSTER
;
extern
NSString
*
SDEF_TTS_DEFAULT_CLUSTER
;
extern
NSString
*
SDEF_TTS_DEFAULT_BACKEND_CLUSTER
;
extern
NSString
*
SDEF_TTS_DEFAULT_BACKEND_CLUSTER
;
extern
NSString
*
SDEF_TTS_DEFAULT_ONLINE_VOICE
;
//
extern NSString* SDEF_TTS_DEFAULT_ONLINE_VOICE;
extern
NSString
*
SDEF_TTS_DEFAULT_ONLINE_VOICE_TYPE
;
//
extern NSString* SDEF_TTS_DEFAULT_ONLINE_VOICE_TYPE;
extern
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE
;
extern
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE
;
extern
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE_TYPE
;
extern
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE_TYPE
;
extern
NSString
*
SDEF_TTS_DEFAULT_ONLINE_LANGUAGE
;
extern
NSString
*
SDEF_TTS_DEFAULT_ONLINE_LANGUAGE
;
...
...
ios/Classes/SensitiveDefines.m
浏览文件 @
84e8b07c
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
const
NSString
*
SDEF_UID
=
@"YOUR UID"
;
const
NSString
*
SDEF_UID
=
@"YOUR UID"
;
// Online & Resource Authentication
// Online & Resource Authentication
const
NSString
*
SDEF_APPID
=
@"2301072440"
;
//
const NSString* SDEF_APPID = @"2301072440";
const
NSString
*
SDEF_TOKEN
=
@"Bearer;75UvJCpxRjTCppqQUkQ-o-4UfjnCgVmp"
;
//;
//
const NSString* SDEF_TOKEN = @"Bearer;75UvJCpxRjTCppqQUkQ-o-4UfjnCgVmp";//;
const
NSString
*
SDEF_APP_VERSION
=
@"1.0.0"
;
const
NSString
*
SDEF_APP_VERSION
=
@"1.0.0"
;
// Offline Authentication
// Offline Authentication
...
@@ -43,8 +43,8 @@ const NSString* SDEF_AU_DEFAULT_URI = @"/api/v1/sauc";
...
@@ -43,8 +43,8 @@ const NSString* SDEF_AU_DEFAULT_URI = @"/api/v1/sauc";
const
NSString
*
SDEF_TTS_DEFAULT_URI
=
@"/api/v1/tts/ws_binary"
;
const
NSString
*
SDEF_TTS_DEFAULT_URI
=
@"/api/v1/tts/ws_binary"
;
const
NSString
*
SDEF_TTS_DEFAULT_CLUSTER
=
@"volcano_tts"
;
const
NSString
*
SDEF_TTS_DEFAULT_CLUSTER
=
@"volcano_tts"
;
const
NSString
*
SDEF_TTS_DEFAULT_BACKEND_CLUSTER
=
@"YOUR TTS BACKEND CLUSTER"
;
const
NSString
*
SDEF_TTS_DEFAULT_BACKEND_CLUSTER
=
@"YOUR TTS BACKEND CLUSTER"
;
const
NSString
*
SDEF_TTS_DEFAULT_ONLINE_VOICE
=
@"灿灿"
;
//
const NSString* SDEF_TTS_DEFAULT_ONLINE_VOICE = @"灿灿";
const
NSString
*
SDEF_TTS_DEFAULT_ONLINE_VOICE_TYPE
=
@"BV213_w5H18f6VbKnhg3Ph"
;
//
const NSString* SDEF_TTS_DEFAULT_ONLINE_VOICE_TYPE = @"BV213_w5H18f6VbKnhg3Ph";
//BV002_streaming BV021_PSj8BvWAZyepfUPB BV705_streaming BV115_H74MBi790rUFu993 BV213_w5H18f6VbKnhg3Ph
//BV002_streaming BV021_PSj8BvWAZyepfUPB BV705_streaming BV115_H74MBi790rUFu993 BV213_w5H18f6VbKnhg3Ph
const
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE
=
@"YOUR TTS OFFLINE VOICE"
;
const
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE
=
@"YOUR TTS OFFLINE VOICE"
;
const
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE_TYPE
=
@"YOUR TTS OFFLINE VOICE TYPE"
;
const
NSString
*
SDEF_TTS_DEFAULT_OFFLINE_VOICE_TYPE
=
@"YOUR TTS OFFLINE VOICE TYPE"
;
...
...
ios/Classes/SettingsHelper.m
浏览文件 @
84e8b07c
...
@@ -244,8 +244,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
...
@@ -244,8 +244,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
[
sharedInstance
.
asrSettings
registerItems
:@[
[
sharedInstance
.
asrSettings
registerItems
:@[
// common
// common
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildString
:
SETTING_APPID
val
:
SDEF_APPID
hint
:
@""
],
//
[SettingItem buildString:SETTING_APPID val:SDEF_APPID hint:@""],
[
SettingItem
buildString
:
SETTING_TOKEN
val
:
SDEF_TOKEN
hint
:
@""
],
//
[SettingItem buildString:SETTING_TOKEN val:SDEF_TOKEN hint:@""],
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
SDEF_ASR_DEFAULT_CLUSTER
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
SDEF_ASR_DEFAULT_CLUSTER
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_URI
val
:
SDEF_ASR_DEFAULT_URI
hint
:
SETTING_HINT_URI
],
[
SettingItem
buildString
:
SETTING_URI
val
:
SDEF_ASR_DEFAULT_URI
hint
:
SETTING_HINT_URI
],
...
@@ -282,7 +282,7 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
...
@@ -282,7 +282,7 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
[
sharedInstance
.
asrOfflineSettings
registerItems
:@[
[
sharedInstance
.
asrOfflineSettings
registerItems
:@[
// common
// common
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildString
:
SETTING_APPID
val
:
SDEF_APPID
hint
:
@""
],
//
[SettingItem buildString:SETTING_APPID val:SDEF_APPID hint:@""],
[
SettingItem
buildOptions
:
SETTING_RECORD_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_RECORD_TYPE
()
choose
:
0
]
hint
:
@""
],
[
SettingItem
buildOptions
:
SETTING_RECORD_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_RECORD_TYPE
()
choose
:
0
]
hint
:
@""
],
[
SettingItem
buildInt
:
SETTING_VAD_MAX_SPEECH_DURATION
val
:
15000
hint
:
@""
],
[
SettingItem
buildInt
:
SETTING_VAD_MAX_SPEECH_DURATION
val
:
15000
hint
:
@""
],
[
SettingItem
buildInt
:
SETTING_STREAM_PACKAGE_DURATION
val
:
20000
hint
:
@""
],
[
SettingItem
buildInt
:
SETTING_STREAM_PACKAGE_DURATION
val
:
20000
hint
:
@""
],
...
@@ -302,8 +302,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
...
@@ -302,8 +302,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
SDEF_CAPT_DEFAULT_CLUSTER
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
SDEF_CAPT_DEFAULT_CLUSTER
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_URI
val
:
@""
hint
:
SETTING_HINT_URI
],
[
SettingItem
buildString
:
SETTING_URI
val
:
@""
hint
:
SETTING_HINT_URI
],
[
SettingItem
buildString
:
SETTING_APPID
val
:
SDEF_APPID
hint
:
@""
],
//
[SettingItem buildString:SETTING_APPID val:SDEF_APPID hint:@""],
[
SettingItem
buildString
:
SETTING_TOKEN
val
:
SDEF_APPID
hint
:
@""
],
//
[SettingItem buildString:SETTING_TOKEN val:SDEF_APPID hint:@""],
[
SettingItem
buildBool
:
SETTING_GET_VOLUME
val
:
false
hint
:
@""
],
[
SettingItem
buildBool
:
SETTING_GET_VOLUME
val
:
false
hint
:
@""
],
[
SettingItem
buildOptions
:
SETTING_RECORD_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_RECORD_TYPE
()
choose
:
0
]
hint
:
@""
],
[
SettingItem
buildOptions
:
SETTING_RECORD_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_RECORD_TYPE
()
choose
:
0
]
hint
:
@""
],
[
SettingItem
buildBool
:
SETTING_ENABLE_AEC
val
:
false
hint
:
@""
],
[
SettingItem
buildBool
:
SETTING_ENABLE_AEC
val
:
false
hint
:
@""
],
...
@@ -355,8 +355,9 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
...
@@ -355,8 +355,9 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
SDEF_TTS_DEFAULT_CLUSTER
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
SDEF_TTS_DEFAULT_CLUSTER
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_URI
val
:
SDEF_TTS_DEFAULT_URI
hint
:
SETTING_HINT_URI
],
[
SettingItem
buildString
:
SETTING_URI
val
:
SDEF_TTS_DEFAULT_URI
hint
:
SETTING_HINT_URI
],
[
SettingItem
buildString
:
SETTING_ONLINE_VOICE
val
:
SDEF_TTS_DEFAULT_ONLINE_VOICE
hint
:
SETTING_HINT_ONLINE_VOICE
],
[
SettingItem
buildString
:
SETTING_ONLINE_VOICE_TYPE
val
:
SDEF_TTS_DEFAULT_ONLINE_VOICE_TYPE
hint
:
SETTING_HINT_ONLINE_VOICE_TYPE
],
// [SettingItem buildString:SETTING_ONLINE_VOICE val:SDEF_TTS_DEFAULT_ONLINE_VOICE hint:SETTING_HINT_ONLINE_VOICE],
// [SettingItem buildString:SETTING_ONLINE_VOICE_TYPE val:SDEF_TTS_DEFAULT_ONLINE_VOICE_TYPE hint:SETTING_HINT_ONLINE_VOICE_TYPE],
[
SettingItem
buildString
:
SETTING_OFFLINE_VOICE
val
:
SDEF_TTS_DEFAULT_OFFLINE_VOICE
hint
:
SETTING_HINT_OFFLINE_VOICE
],
[
SettingItem
buildString
:
SETTING_OFFLINE_VOICE
val
:
SDEF_TTS_DEFAULT_OFFLINE_VOICE
hint
:
SETTING_HINT_OFFLINE_VOICE
],
[
SettingItem
buildString
:
SETTING_OFFLINE_VOICE_TYPE
val
:
SDEF_TTS_DEFAULT_OFFLINE_VOICE_TYPE
hint
:
SETTING_HINT_OFFLINE_VOICE_TYPE
],
[
SettingItem
buildString
:
SETTING_OFFLINE_VOICE_TYPE
val
:
SDEF_TTS_DEFAULT_OFFLINE_VOICE_TYPE
hint
:
SETTING_HINT_OFFLINE_VOICE_TYPE
],
[
SettingItem
buildOptions
:
SETTING_AUTHENTICATION_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_AUTHENTICATION_TYPE
()
choose
:
0
]
hint
:
@""
],
[
SettingItem
buildOptions
:
SETTING_AUTHENTICATION_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_AUTHENTICATION_TYPE
()
choose
:
0
]
hint
:
@""
],
...
@@ -397,8 +398,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
...
@@ -397,8 +398,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
// common
// common
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildInt
:
SETTING_SAMPLE_RATE
val
:
44100
hint
:
@""
],
[
SettingItem
buildInt
:
SETTING_SAMPLE_RATE
val
:
44100
hint
:
@""
],
[
SettingItem
buildString
:
SETTING_APPID
val
:
SDEF_APPID
hint
:
@""
],
//
[SettingItem buildString:SETTING_APPID val:SDEF_APPID hint:@""],
[
SettingItem
buildString
:
SETTING_TOKEN
val
:
SDEF_APPID
hint
:
@""
],
//
[SettingItem buildString:SETTING_TOKEN val:SDEF_APPID hint:@""],
[
SettingItem
buildOptions
:
SETTING_RECORD_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_RECORD_TYPE
()
choose
:
0
]
hint
:
@""
],
[
SettingItem
buildOptions
:
SETTING_RECORD_TYPE
val
:[
SettingOptions
build
:
SETTING_OPTIONS_RECORD_TYPE
()
choose
:
0
]
hint
:
@""
],
// voiceclone
// voiceclone
...
@@ -435,8 +436,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
...
@@ -435,8 +436,8 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
[
sharedInstance
.
dialogSettings
registerItems
:@[
[
sharedInstance
.
dialogSettings
registerItems
:@[
// common
// common
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildString
:
SETTING_APPID
val
:
SDEF_APPID
hint
:
@""
],
//
[SettingItem buildString:SETTING_APPID val:SDEF_APPID hint:@""],
[
SettingItem
buildString
:
SETTING_TOKEN
val
:
SDEF_TOKEN
hint
:
@""
],
//
[SettingItem buildString:SETTING_TOKEN val:SDEF_TOKEN hint:@""],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
SDEF_DEFAULT_ADDRESS
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_URI
val
:
SDEF_DIALOG_DEFAULT_URI
hint
:
SETTING_HINT_URI
],
[
SettingItem
buildString
:
SETTING_URI
val
:
SDEF_DIALOG_DEFAULT_URI
hint
:
SETTING_HINT_URI
],
...
@@ -471,7 +472,7 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
...
@@ -471,7 +472,7 @@ static NSArray* SETTING_OPTIONS_AU_ABILITY(void) {
// common
// common
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildGroup
:
SETTING_COMMON
val
:
@""
hint
:
@""
],
[
SettingItem
buildString
:
SETTING_APPID
val
:
@"vs_tt_input_qa"
hint
:
@""
],
[
SettingItem
buildString
:
SETTING_APPID
val
:
@"vs_tt_input_qa"
hint
:
@""
],
[
SettingItem
buildString
:
SETTING_TOKEN
val
:
SDEF_TOKEN
hint
:
@""
],
//
[SettingItem buildString:SETTING_TOKEN val:SDEF_TOKEN hint:@""],
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
@"vs_tt_input_qa"
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_CLUSTER
val
:
@"vs_tt_input_qa"
hint
:
SETTING_HINT_CLUSTER
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
@"wss://speech-maliva.bytedance.com"
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_ADDRESS
val
:
@"wss://speech-maliva.bytedance.com"
hint
:
SETTING_HINT_ADDRESS
],
[
SettingItem
buildString
:
SETTING_URI
val
:
@"/api/v1/sauc_test"
hint
:
SETTING_HINT_URI
],
[
SettingItem
buildString
:
SETTING_URI
val
:
@"/api/v1/sauc_test"
hint
:
SETTING_HINT_URI
],
...
...
ios/Classes/VoiceAsr.h
浏览文件 @
84e8b07c
...
@@ -17,11 +17,12 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -17,11 +17,12 @@ NS_ASSUME_NONNULL_BEGIN
@interface
VoiceAsr
:
NSObject
@interface
VoiceAsr
:
NSObject
-
(
instancetype
)
initWithDelegate
:(
id
<
VoiceAsrDelegate
>
)
delegate
;
-
(
instancetype
)
initWithDelegate
:(
id
<
VoiceAsrDelegate
>
)
delegate
config
:(
NSDictionary
*
)
config
;
+
(
void
)
prepareEnvironment
:(
NSDictionary
*
)
config
;
+
(
void
)
prepareEnvironment
:(
NSDictionary
*
)
config
;
-
(
void
)
initEngine
;
-
(
void
)
initEngine
WithConfig
:(
NSDictionary
*
)
config
;
-
(
void
)
uninitEngine
;
-
(
void
)
uninitEngine
;
...
...
ios/Classes/VoiceAsr.m
浏览文件 @
84e8b07c
...
@@ -38,6 +38,8 @@
...
@@ -38,6 +38,8 @@
@property
(
nonatomic
,
weak
)
id
<
VoiceAsrDelegate
>
delegate
;
@property
(
nonatomic
,
weak
)
id
<
VoiceAsrDelegate
>
delegate
;
@property
(
strong
,
nonatomic
)
NSDictionary
*
config
;
@end
@end
...
@@ -45,13 +47,15 @@
...
@@ -45,13 +47,15 @@
@implementation
VoiceAsr
@implementation
VoiceAsr
-
(
instancetype
)
init
{
-
(
instancetype
)
init
{
return
[
self
initWithDelegate
:
nil
];
return
[
self
initWithDelegate
:
nil
config
:@{}
];
}
}
-
(
instancetype
)
initWithDelegate
:
(
id
<
VoiceAsrDelegate
>
)
delegate
{
-
(
instancetype
)
initWithDelegate
:
(
id
<
VoiceAsrDelegate
>
)
delegate
config
:
(
NSDictionary
*
)
config
{
self
=
[
super
init
];
self
=
[
super
init
];
if
(
self
)
{
if
(
self
)
{
self
.
delegate
=
delegate
;
self
.
delegate
=
delegate
;
self
.
config
=
config
;
self
.
streamRecorder
=
[[
StreamRecorder
alloc
]
init
];
self
.
streamRecorder
=
[[
StreamRecorder
alloc
]
init
];
self
.
settings
=
[
SettingsHelper
shareInstance
].
asrSettings
;
self
.
settings
=
[
SettingsHelper
shareInstance
].
asrSettings
;
}
}
...
@@ -68,7 +72,7 @@
...
@@ -68,7 +72,7 @@
NSString
*
appId
=
config
[
@"appId"
];
NSString
*
appId
=
config
[
@"appId"
];
if
(
status
)
{
if
(
status
)
{
SpeechResourceManager
*
speechResourceManager
=
[
SpeechResourceManager
shareInstance
];
SpeechResourceManager
*
speechResourceManager
=
[
SpeechResourceManager
shareInstance
];
[
speechResourceManager
setAppId
:
SDEF_APPID
];
[
speechResourceManager
setAppId
:
appId
];
[
speechResourceManager
setAppVersion
:
@"1.0.0"
];
[
speechResourceManager
setAppVersion
:
@"1.0.0"
];
// [speechResourceManager setDeviceId:self.deviceID];
// [speechResourceManager setDeviceId:self.deviceID];
[
speechResourceManager
setRootPath
:
[
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
).
firstObject
stringByAppendingPathComponent
:
@"models"
]];
[
speechResourceManager
setRootPath
:
[
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
).
firstObject
stringByAppendingPathComponent
:
@"models"
]];
...
@@ -77,6 +81,11 @@
...
@@ -77,6 +81,11 @@
}
}
}
}
-
(
void
)
initEngineWithConfig
:
(
NSDictionary
*
)
config
{
self
.
config
=
config
;
[
self
initEngine
];
}
-
(
void
)
startEngineBtnClicked
{
-
(
void
)
startEngineBtnClicked
{
[
self
setResultText
:
@""
];
[
self
setResultText
:
@""
];
...
@@ -189,11 +198,12 @@
...
@@ -189,11 +198,12 @@
[
self
.
curEngine
setStringParam
:
uri
forKey
:
SE_PARAMS_KEY_ASR_URI_STRING
];
[
self
.
curEngine
setStringParam
:
uri
forKey
:
SE_PARAMS_KEY_ASR_URI_STRING
];
NSString
*
appID
=
[
self
.
settings
getString
:
SETTING_APPID
];
NSString
*
appID
=
[
self
.
settings
getString
:
SETTING_APPID
];
//【必需配置】鉴权相关:Appid
//【必需配置】鉴权相关:Appid
[
self
.
curEngine
setStringParam
:
appID
.
length
<=
0
?
SDEF_APPID
:
appID
forKey
:
SE_PARAMS_KEY_APP_ID_STRING
];
[
self
.
curEngine
setStringParam
:
appID
.
length
<=
0
?
self
.
config
[
@"appId"
]
:
appID
forKey
:
SE_PARAMS_KEY_APP_ID_STRING
];
//【必需配置】鉴权相关:Token
//【必需配置】鉴权相关:Token
NSString
*
token
=
[
self
.
settings
getString
:
SETTING_TOKEN
];
//
NSString* token = [self.settings getString:SETTING_TOKEN];
[
self
.
curEngine
setStringParam
:
token
forKey
:
SE_PARAMS_KEY_APP_TOKEN_STRING
];
[
self
.
curEngine
setStringParam
:
self
.
config
[
@"token"
]
forKey
:
SE_PARAMS_KEY_APP_TOKEN_STRING
];
NSString
*
cluster
=
[
self
.
settings
getString
:
SETTING_CLUSTER
];
NSString
*
cluster
=
[
self
.
settings
getString
:
SETTING_CLUSTER
];
NSLog
(
@"Current cluster: %@"
,
cluster
);
NSLog
(
@"Current cluster: %@"
,
cluster
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论