Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
043b21d3
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 1 年 前同步成功
通知
207
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
043b21d3
编写于
8月 25, 2022
作者:
L
liangym
提交者:
GitHub
8月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix mix frontend, test=tts (#2299)
上级
25b96405
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
30 deletion
+40
-30
paddlespeech/t2s/frontend/mix_frontend.py
paddlespeech/t2s/frontend/mix_frontend.py
+40
-30
未找到文件。
paddlespeech/t2s/frontend/mix_frontend.py
浏览文件 @
043b21d3
...
...
@@ -61,7 +61,8 @@ class MixFrontend():
return
False
def
is_end
(
self
,
before_char
,
after_char
)
->
bool
:
if
((
self
.
is_alphabet
(
before_char
)
or
before_char
==
" "
)
and
(
self
.
is_alphabet
(
after_char
)
or
after_char
==
" "
)):
if
((
self
.
is_alphabet
(
before_char
)
or
before_char
==
" "
)
and
(
self
.
is_alphabet
(
after_char
)
or
after_char
==
" "
)):
return
True
else
:
return
False
...
...
@@ -86,10 +87,11 @@ class MixFrontend():
if
point_index
==
0
or
point_index
==
len
(
text
)
-
1
:
new_text
=
text
else
:
if
not
self
.
is_end
(
text
[
point_index
-
1
],
text
[
point_index
+
1
]):
if
not
self
.
is_end
(
text
[
point_index
-
1
],
text
[
point_index
+
1
]):
new_text
=
text
else
:
new_text
=
text
[:
point_index
]
+
"。"
+
text
[
point_index
+
1
:]
new_text
=
text
[:
point_index
]
+
"。"
+
text
[
point_index
+
1
:]
elif
len
(
point_indexs
)
==
2
:
first_index
=
point_indexs
[
0
]
...
...
@@ -97,7 +99,8 @@ class MixFrontend():
# first
if
first_index
!=
0
:
if
not
self
.
is_end
(
text
[
first_index
-
1
],
text
[
first_index
+
1
]):
if
not
self
.
is_end
(
text
[
first_index
-
1
],
text
[
first_index
+
1
]):
new_text
+=
(
text
[:
first_index
]
+
"."
)
else
:
new_text
+=
(
text
[:
first_index
]
+
"。"
)
...
...
@@ -106,18 +109,20 @@ class MixFrontend():
# last
if
end_index
!=
len
(
text
)
-
1
:
if
not
self
.
is_end
(
text
[
end_index
-
1
],
text
[
end_index
+
1
]):
new_text
+=
text
[
point_indexs
[
-
2
]
+
1
:
]
new_text
+=
text
[
point_indexs
[
-
2
]
+
1
:
]
else
:
new_text
+=
(
text
[
point_indexs
[
-
2
]
+
1
:
end_index
]
+
"。"
+
text
[
end_index
+
1
:
])
new_text
+=
(
text
[
point_indexs
[
-
2
]
+
1
:
end_index
]
+
"。"
+
text
[
end_index
+
1
:])
else
:
new_text
+=
"."
new_text
+=
"."
else
:
first_index
=
point_indexs
[
0
]
end_index
=
point_indexs
[
-
1
]
# first
if
first_index
!=
0
:
if
not
self
.
is_end
(
text
[
first_index
-
1
],
text
[
first_index
+
1
]):
if
not
self
.
is_end
(
text
[
first_index
-
1
],
text
[
first_index
+
1
]):
new_text
+=
(
text
[:
first_index
]
+
"."
)
else
:
new_text
+=
(
text
[:
first_index
]
+
"。"
)
...
...
@@ -126,16 +131,20 @@ class MixFrontend():
# middle
for
j
in
range
(
1
,
len
(
point_indexs
)
-
1
):
point_index
=
point_indexs
[
j
]
if
not
self
.
is_end
(
text
[
point_index
-
1
],
text
[
point_index
+
1
]):
new_text
+=
(
text
[
point_indexs
[
j
-
1
]
+
1
:
point_index
]
+
"."
)
if
not
self
.
is_end
(
text
[
point_index
-
1
],
text
[
point_index
+
1
]):
new_text
+=
(
text
[
point_indexs
[
j
-
1
]
+
1
:
point_index
]
+
"."
)
else
:
new_text
+=
(
text
[
point_indexs
[
j
-
1
]
+
1
:
point_index
]
+
"。"
)
new_text
+=
(
text
[
point_indexs
[
j
-
1
]
+
1
:
point_index
]
+
"。"
)
# last
if
end_index
!=
len
(
text
)
-
1
:
if
not
self
.
is_end
(
text
[
end_index
-
1
],
text
[
end_index
+
1
]):
new_text
+=
text
[
point_indexs
[
-
2
]
+
1
:
]
new_text
+=
text
[
point_indexs
[
-
2
]
+
1
:
]
else
:
new_text
+=
(
text
[
point_indexs
[
-
2
]
+
1
:
end_index
]
+
"。"
+
text
[
end_index
+
1
:
])
new_text
+=
(
text
[
point_indexs
[
-
2
]
+
1
:
end_index
]
+
"。"
+
text
[
end_index
+
1
:])
else
:
new_text
+=
"."
...
...
@@ -224,7 +233,7 @@ class MixFrontend():
def
get_input_ids
(
self
,
sentence
:
str
,
merge_sentences
:
bool
=
Tru
e
,
merge_sentences
:
bool
=
Fals
e
,
get_tone_ids
:
bool
=
False
,
add_sp
:
bool
=
True
,
to_tensor
:
bool
=
True
)
->
Dict
[
str
,
List
[
paddle
.
Tensor
]]:
...
...
@@ -232,28 +241,29 @@ class MixFrontend():
sentences
=
self
.
_split
(
sentence
)
phones_list
=
[]
result
=
{}
for
text
in
sentences
:
phones_seg
=
[]
segments
=
self
.
_distinguish
(
text
)
for
seg
in
segments
:
content
=
seg
[
0
]
lang
=
seg
[
1
]
if
lang
==
"zh"
:
input_ids
=
self
.
zh_frontend
.
get_input_ids
(
content
,
merge_sentences
=
True
,
get_tone_ids
=
get_tone_ids
,
to_tensor
=
to_tensor
)
elif
lang
==
"en"
:
input_ids
=
self
.
en_frontend
.
get_input_ids
(
content
,
merge_sentences
=
True
,
to_tensor
=
to_tensor
)
phones_seg
.
append
(
input_ids
[
"phone_ids"
][
0
])
if
add_sp
:
phones_seg
.
append
(
self
.
sp_id_tensor
)
if
content
!=
''
:
if
lang
==
"en"
:
input_ids
=
self
.
en_frontend
.
get_input_ids
(
content
,
merge_sentences
=
True
,
to_tensor
=
to_tensor
)
else
:
input_ids
=
self
.
zh_frontend
.
get_input_ids
(
content
,
merge_sentences
=
True
,
get_tone_ids
=
get_tone_ids
,
to_tensor
=
to_tensor
)
phones_seg
.
append
(
input_ids
[
"phone_ids"
][
0
])
if
add_sp
:
phones_seg
.
append
(
self
.
sp_id_tensor
)
if
phones_seg
==
[]:
phones_seg
.
append
(
self
.
sp_id_tensor
)
phones
=
paddle
.
concat
(
phones_seg
)
phones_list
.
append
(
phones
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录