Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
e60a63fb
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
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看板
提交
e60a63fb
编写于
8月 07, 2022
作者:
B
BarryKCL
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rollback "get_input_ids"
上级
ab2a1219
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
15 deletion
+18
-15
paddlespeech/t2s/frontend/zh_frontend.py
paddlespeech/t2s/frontend/zh_frontend.py
+18
-15
未找到文件。
paddlespeech/t2s/frontend/zh_frontend.py
浏览文件 @
e60a63fb
...
@@ -174,11 +174,11 @@ class Frontend():
...
@@ -174,11 +174,11 @@ class Frontend():
phones_list
=
[]
phones_list
=
[]
for
seg
in
segments
:
for
seg
in
segments
:
phones
=
[]
phones
=
[]
initials
=
[]
finals
=
[]
# Replace all English words in the sentence
# Replace all English words in the sentence
seg
=
re
.
sub
(
'[a-zA-Z]+'
,
''
,
seg
)
seg
=
re
.
sub
(
'[a-zA-Z]+'
,
''
,
seg
)
seg_cut
=
psg
.
lcut
(
seg
)
seg_cut
=
psg
.
lcut
(
seg
)
initials
=
[]
finals
=
[]
seg_cut
=
self
.
tone_modifier
.
pre_merge_for_modify
(
seg_cut
)
seg_cut
=
self
.
tone_modifier
.
pre_merge_for_modify
(
seg_cut
)
if
self
.
g2p_model
==
"g2pW"
:
if
self
.
g2p_model
==
"g2pW"
:
pinyins
=
self
.
g2pW_model
(
seg
)[
0
]
pinyins
=
self
.
g2pW_model
(
seg
)[
0
]
...
@@ -233,6 +233,7 @@ class Frontend():
...
@@ -233,6 +233,7 @@ class Frontend():
# assert len(sub_initials) == len(sub_finals) == len(word)
# assert len(sub_initials) == len(sub_finals) == len(word)
initials
=
sum
(
initials
,
[])
initials
=
sum
(
initials
,
[])
finals
=
sum
(
finals
,
[])
finals
=
sum
(
finals
,
[])
for
c
,
v
in
zip
(
initials
,
finals
):
for
c
,
v
in
zip
(
initials
,
finals
):
# NOTE: post process for pypinyin outputs
# NOTE: post process for pypinyin outputs
# we discriminate i, ii and iii
# we discriminate i, ii and iii
...
@@ -365,15 +366,15 @@ class Frontend():
...
@@ -365,15 +366,15 @@ class Frontend():
print
(
"----------------------------"
)
print
(
"----------------------------"
)
return
phonemes
return
phonemes
def
get_input_ids
(
def
get_input_ids
(
self
,
self
,
sentence
:
str
,
sentence
:
str
,
merge_sentences
:
bool
=
True
,
merge_sentences
:
bool
=
Tru
e
,
get_tone_ids
:
bool
=
Fals
e
,
get_tone_ids
:
bool
=
False
,
robot
:
bool
=
False
,
robot
:
bool
=
False
,
print_info
:
bool
=
False
,
print_info
:
bool
=
False
,
add_blank
:
bool
=
False
,
add_blank
:
bool
=
False
,
blank_token
:
str
=
"<pad>"
,
blank_token
:
str
=
"<pad>"
)
->
Dict
[
str
,
List
[
paddle
.
Tensor
]]:
to_tensor
:
bool
=
True
)
->
Dict
[
str
,
List
[
paddle
.
Tensor
]]:
phonemes
=
self
.
get_phonemes
(
phonemes
=
self
.
get_phonemes
(
sentence
,
sentence
,
merge_sentences
=
merge_sentences
,
merge_sentences
=
merge_sentences
,
...
@@ -384,20 +385,22 @@ class Frontend():
...
@@ -384,20 +385,22 @@ class Frontend():
tones
=
[]
tones
=
[]
temp_phone_ids
=
[]
temp_phone_ids
=
[]
temp_tone_ids
=
[]
temp_tone_ids
=
[]
for
part_phonemes
in
phonemes
:
for
part_phonemes
in
phonemes
:
phones
,
tones
=
self
.
_get_phone_tone
(
phones
,
tones
=
self
.
_get_phone_tone
(
part_phonemes
,
get_tone_ids
=
get_tone_ids
)
part_phonemes
,
get_tone_ids
=
get_tone_ids
)
if
add_blank
:
if
add_blank
:
phones
=
insert_after_character
(
phones
,
blank_token
)
phones
=
insert_after_character
(
phones
,
blank_token
)
if
tones
:
if
tones
:
tone_ids
=
self
.
_t2id
(
tones
)
tone_ids
=
self
.
_t2id
(
tones
)
tone_ids
=
paddle
.
to_tensor
(
tone_ids
)
if
to_tensor
:
tone_ids
=
paddle
.
to_tensor
(
tone_ids
)
temp_tone_ids
.
append
(
tone_ids
)
temp_tone_ids
.
append
(
tone_ids
)
if
phones
:
if
phones
:
phone_ids
=
self
.
_p2id
(
phones
)
phone_ids
=
self
.
_p2id
(
phones
)
phone_ids
=
paddle
.
to_tensor
(
phone_ids
)
# if use paddle.to_tensor() in onnxruntime, the first time will be too low
if
to_tensor
:
phone_ids
=
paddle
.
to_tensor
(
phone_ids
)
temp_phone_ids
.
append
(
phone_ids
)
temp_phone_ids
.
append
(
phone_ids
)
if
temp_tone_ids
:
if
temp_tone_ids
:
result
[
"tone_ids"
]
=
temp_tone_ids
result
[
"tone_ids"
]
=
temp_tone_ids
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录