Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
aivoice_plugin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王苏进
aivoice_plugin
Commits
7c171eb0
提交
7c171eb0
authored
9月 13, 2024
作者:
王苏进
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 优化
上级
83ea0d07
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
34 行增加
和
30 行删除
+34
-30
TtsNovel.m
ios/Classes/TtsNovel.m
+34
-30
没有找到文件。
ios/Classes/TtsNovel.m
浏览文件 @
7c171eb0
...
...
@@ -475,8 +475,6 @@ static int TTS_MAX_RETRY_COUNT = 3;
self
.
textFromFlutter
=
text
;
NSLog
(
@"Start engine, current status: %d"
,
self
.
engineStarted
);
if
(
!
self
.
engineStarted
)
{
// [self clearResult:nil];
self
.
engineErrorOccurred
=
FALSE
;
// Directive:启动引擎前调用SYNC_STOP指令,保证前一次请求结束。
...
...
@@ -496,7 +494,6 @@ static int TTS_MAX_RETRY_COUNT = 3;
[
self
sendStartEngineDirectiveFailed
:
message
];
}
}
}
}
-
(
void
)
stopEngineBtnClicked
{
...
...
@@ -693,29 +690,29 @@ static int TTS_MAX_RETRY_COUNT = 3;
// 根据 SDK 返回的播放进度高亮正在播放的文本,用红色表示
// 根据 SDK 返回的合成开始和合成结束回调高亮正在合成的文本,用蓝色表示
-
(
void
)
updatePlayingWords
:
(
NSString
*
)
playingId
{
int
synthesisIndex
=
self
.
ttsSynthesisIndex
;
NSNumber
*
val
=
[
self
.
ttsSynthesisMap
objectForKey
:
playingId
];
if
(
val
!=
nil
)
{
self
.
ttsPlayingIndex
=
[
val
intValue
];
}
int
beginIndex
=
MAX
(
self
.
ttsPlayingIndex
,
0
);
int
maxSentencesDisplayed
=
MIN
((
int
)[
self
.
ttsSynthesisText
count
],
16
);
// int synthesisIndex = self.ttsSynthesisIndex;
// NSNumber* val = [self.ttsSynthesisMap objectForKey:playingId];
// if (val != nil) {
// self.ttsPlayingIndex = [val intValue];
// }
//
// int beginIndex = MAX(self.ttsPlayingIndex, 0);
// int maxSentencesDisplayed = MIN((int)[self.ttsSynthesisText count], 500);
//
//// NSString *resultStr = @"";
// for (int cnt = 0; cnt < maxSentencesDisplayed; ++cnt) {
// int index = (beginIndex + cnt) % [self.ttsSynthesisText count];
// NSString* current_sentence = self.ttsSynthesisText[index];
//// NSInteger playedPosition = 0;
// if (index == self.ttsPlayingIndex) {
//// playedPosition = MIN(ceil((double)(self.ttsPlayingProgress) * (double)([current_sentence length])), [current_sentence length]);
//// NSLog(@"played position: %ld", (long)playedPosition);
//
//
// }
//
// }
NSString
*
resultStr
=
@""
;
for
(
int
cnt
=
0
;
cnt
<
maxSentencesDisplayed
;
++
cnt
)
{
int
index
=
(
beginIndex
+
cnt
)
%
[
self
.
ttsSynthesisText
count
];
NSString
*
current_sentence
=
self
.
ttsSynthesisText
[
index
];
NSInteger
playedPosition
=
0
;
if
(
index
==
self
.
ttsPlayingIndex
)
{
playedPosition
=
MIN
(
ceil
((
double
)(
self
.
ttsPlayingProgress
)
*
(
double
)([
current_sentence
length
])),
[
current_sentence
length
]);
NSLog
(
@"played position: %ld"
,
(
long
)
playedPosition
);
resultStr
=
[
resultStr
stringByAppendingString
:[
current_sentence
substringToIndex
:
playedPosition
]];
}
if
([
self
.
delegate
respondsToSelector
:
@selector
(
onRecieve
:)])
{
[
self
.
delegate
onRecieve
:@{
@"playWords"
:
resultStr
}];
}
}
// [self.resultTextView setAttributedText:resultStr];
}
...
...
@@ -745,6 +742,11 @@ static int TTS_MAX_RETRY_COUNT = 3;
// self.pauseResumeButton.enabled = TRUE;
self
.
ttsPlayingProgress
=
0
.
0
;
[
self
updatePlayingWords
:
playingId
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
onRecieve
:)])
{
int
index
=
[[
self
.
ttsSynthesisMap
objectForKey
:
playingId
]
intValue
];
[
self
.
delegate
onRecieve
:@{
@"playWords"
:
self
.
ttsSynthesisText
[
index
]}];
}
});
}
...
...
@@ -786,6 +788,7 @@ static int TTS_MAX_RETRY_COUNT = 3;
if
([[
self
.
ttsSynthesisMap
allKeys
]
count
]
==
0
)
{
NSLog
(
@"这里告诉flutter 已经全部读完了"
);
[
self
.
delegate
onRecieve
:@{
@"finish"
:
@
(
YES
)}];
[
self
resetTtsContext
];
}
});
if
(
self
.
ttsSynthesisFromPlayer
)
{
...
...
@@ -811,12 +814,15 @@ static int TTS_MAX_RETRY_COUNT = 3;
}
-
(
void
)
synthesisNextSentence
{
self
.
ttsSynthesisIndex
=
(
self
.
ttsSynthesisIndex
+
1
)
%
[
self
.
ttsSynthesisText
count
];
self
.
ttsSynthesisIndex
+=
1
;
// 合成最后一条后停止
if
(
!
self
.
ttsSynthesisFromPlayer
&&
(
self
.
ttsSynthesisIndex
+
1
)
<
self
.
ttsSynthesisText
.
count
)
{
// && ((self.ttsSynthesisIndex +1) < self.ttsSynthesisText.count)
NSLog
(
@"合成下后一条%@"
,
@
(
self
.
ttsSynthesisIndex
));
if
(
!
self
.
ttsSynthesisFromPlayer
&&
((
self
.
ttsSynthesisIndex
+
1
)
<=
self
.
ttsSynthesisText
.
count
))
{
[
self
triggerSynthesis
];
}
}
-
(
void
)
triggerSynthesis
{
...
...
@@ -954,8 +960,6 @@ static int TTS_MAX_RETRY_COUNT = 3;
}
}
-
(
void
)
onRecieve
:
(
nonnull
NSDictionary
*
)
message
{
}
@end
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论