Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
39dbcb4d
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看板
提交
39dbcb4d
编写于
10月 23, 2017
作者:
Y
yangyaming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Give option to disable converting from transcription text to ids.
上级
f23282dc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
26 addition
and
16 deletion
+26
-16
data_utils/data.py
data_utils/data.py
+10
-3
data_utils/featurizer/speech_featurizer.py
data_utils/featurizer/speech_featurizer.py
+5
-3
deploy/demo_server.py
deploy/demo_server.py
+2
-1
infer.py
infer.py
+3
-3
test.py
test.py
+3
-3
tools/tune.py
tools/tune.py
+3
-3
未找到文件。
data_utils/data.py
浏览文件 @
39dbcb4d
...
@@ -55,6 +55,10 @@ class DataGenerator(object):
...
@@ -55,6 +55,10 @@ class DataGenerator(object):
:type num_threads: int
:type num_threads: int
:param random_seed: Random seed.
:param random_seed: Random seed.
:type random_seed: int
:type random_seed: int
:param keep_transcription_text: If set to True, transcription text will
be passed forward directly without
converting to index sequence.
:type keep_transcription_text: bool
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
...
@@ -69,7 +73,8 @@ class DataGenerator(object):
...
@@ -69,7 +73,8 @@ class DataGenerator(object):
specgram_type
=
'linear'
,
specgram_type
=
'linear'
,
use_dB_normalization
=
True
,
use_dB_normalization
=
True
,
num_threads
=
multiprocessing
.
cpu_count
()
//
2
,
num_threads
=
multiprocessing
.
cpu_count
()
//
2
,
random_seed
=
0
):
random_seed
=
0
,
keep_transcription_text
=
False
):
self
.
_max_duration
=
max_duration
self
.
_max_duration
=
max_duration
self
.
_min_duration
=
min_duration
self
.
_min_duration
=
min_duration
self
.
_normalizer
=
FeatureNormalizer
(
mean_std_filepath
)
self
.
_normalizer
=
FeatureNormalizer
(
mean_std_filepath
)
...
@@ -84,6 +89,7 @@ class DataGenerator(object):
...
@@ -84,6 +89,7 @@ class DataGenerator(object):
use_dB_normalization
=
use_dB_normalization
)
use_dB_normalization
=
use_dB_normalization
)
self
.
_num_threads
=
num_threads
self
.
_num_threads
=
num_threads
self
.
_rng
=
random
.
Random
(
random_seed
)
self
.
_rng
=
random
.
Random
(
random_seed
)
self
.
_keep_transcription_text
=
keep_transcription_text
self
.
_epoch
=
0
self
.
_epoch
=
0
# for caching tar files info
# for caching tar files info
self
.
_local_data
=
local
()
self
.
_local_data
=
local
()
...
@@ -107,9 +113,10 @@ class DataGenerator(object):
...
@@ -107,9 +113,10 @@ class DataGenerator(object):
else
:
else
:
speech_segment
=
SpeechSegment
.
from_file
(
filename
,
transcript
)
speech_segment
=
SpeechSegment
.
from_file
(
filename
,
transcript
)
self
.
_augmentation_pipeline
.
transform_audio
(
speech_segment
)
self
.
_augmentation_pipeline
.
transform_audio
(
speech_segment
)
specgram
,
text_ids
=
self
.
_speech_featurizer
.
featurize
(
speech_segment
)
specgram
,
transcript_part
=
self
.
_speech_featurizer
.
featurize
(
speech_segment
,
self
.
_keep_transcription_text
)
specgram
=
self
.
_normalizer
.
apply
(
specgram
)
specgram
=
self
.
_normalizer
.
apply
(
specgram
)
return
specgram
,
t
ext_ids
return
specgram
,
t
ranscript_part
def
batch_reader_creator
(
self
,
def
batch_reader_creator
(
self
,
manifest_path
,
manifest_path
,
...
...
data_utils/featurizer/speech_featurizer.py
浏览文件 @
39dbcb4d
...
@@ -60,12 +60,12 @@ class SpeechFeaturizer(object):
...
@@ -60,12 +60,12 @@ class SpeechFeaturizer(object):
target_dB
=
target_dB
)
target_dB
=
target_dB
)
self
.
_text_featurizer
=
TextFeaturizer
(
vocab_filepath
)
self
.
_text_featurizer
=
TextFeaturizer
(
vocab_filepath
)
def
featurize
(
self
,
speech_segment
):
def
featurize
(
self
,
speech_segment
,
keep_transcription_text
):
"""Extract features for speech segment.
"""Extract features for speech segment.
1. For audio parts, extract the audio features.
1. For audio parts, extract the audio features.
2. For transcript parts,
convert text string to a list of token indices
2. For transcript parts,
keep the original text or convert text string
in char-level.
to a list of token indices
in char-level.
:param audio_segment: Speech segment to extract features from.
:param audio_segment: Speech segment to extract features from.
:type audio_segment: SpeechSegment
:type audio_segment: SpeechSegment
...
@@ -74,6 +74,8 @@ class SpeechFeaturizer(object):
...
@@ -74,6 +74,8 @@ class SpeechFeaturizer(object):
:rtype: tuple
:rtype: tuple
"""
"""
audio_feature
=
self
.
_audio_featurizer
.
featurize
(
speech_segment
)
audio_feature
=
self
.
_audio_featurizer
.
featurize
(
speech_segment
)
if
keep_transcription_text
:
return
audio_feature
,
speech_segment
.
transcript
text_ids
=
self
.
_text_featurizer
.
featurize
(
speech_segment
.
transcript
)
text_ids
=
self
.
_text_featurizer
.
featurize
(
speech_segment
.
transcript
)
return
audio_feature
,
text_ids
return
audio_feature
,
text_ids
...
...
deploy/demo_server.py
浏览文件 @
39dbcb4d
...
@@ -146,7 +146,8 @@ def start_server():
...
@@ -146,7 +146,8 @@ def start_server():
mean_std_filepath
=
args
.
mean_std_path
,
mean_std_filepath
=
args
.
mean_std_path
,
augmentation_config
=
'{}'
,
augmentation_config
=
'{}'
,
specgram_type
=
args
.
specgram_type
,
specgram_type
=
args
.
specgram_type
,
num_threads
=
1
)
num_threads
=
1
,
keep_transcription_text
=
True
)
# prepare ASR model
# prepare ASR model
ds2_model
=
DeepSpeech2Model
(
ds2_model
=
DeepSpeech2Model
(
vocab_size
=
data_generator
.
vocab_size
,
vocab_size
=
data_generator
.
vocab_size
,
...
...
infer.py
浏览文件 @
39dbcb4d
...
@@ -68,7 +68,8 @@ def infer():
...
@@ -68,7 +68,8 @@ def infer():
mean_std_filepath
=
args
.
mean_std_path
,
mean_std_filepath
=
args
.
mean_std_path
,
augmentation_config
=
'{}'
,
augmentation_config
=
'{}'
,
specgram_type
=
args
.
specgram_type
,
specgram_type
=
args
.
specgram_type
,
num_threads
=
1
)
num_threads
=
1
,
keep_transcription_text
=
True
)
batch_reader
=
data_generator
.
batch_reader_creator
(
batch_reader
=
data_generator
.
batch_reader_creator
(
manifest_path
=
args
.
infer_manifest
,
manifest_path
=
args
.
infer_manifest
,
batch_size
=
args
.
num_samples
,
batch_size
=
args
.
num_samples
,
...
@@ -103,8 +104,7 @@ def infer():
...
@@ -103,8 +104,7 @@ def infer():
error_rate_func
=
cer
if
args
.
error_rate_type
==
'cer'
else
wer
error_rate_func
=
cer
if
args
.
error_rate_type
==
'cer'
else
wer
target_transcripts
=
[
target_transcripts
=
[
''
.
join
([
data_generator
.
vocab_list
[
token
]
for
token
in
transcript
])
transcript
for
_
,
transcript
in
infer_data
for
_
,
transcript
in
infer_data
]
]
for
target
,
result
in
zip
(
target_transcripts
,
result_transcripts
):
for
target
,
result
in
zip
(
target_transcripts
,
result_transcripts
):
print
(
"
\n
Target Transcription: %s
\n
Output Transcription: %s"
%
print
(
"
\n
Target Transcription: %s
\n
Output Transcription: %s"
%
...
...
test.py
浏览文件 @
39dbcb4d
...
@@ -69,7 +69,8 @@ def evaluate():
...
@@ -69,7 +69,8 @@ def evaluate():
mean_std_filepath
=
args
.
mean_std_path
,
mean_std_filepath
=
args
.
mean_std_path
,
augmentation_config
=
'{}'
,
augmentation_config
=
'{}'
,
specgram_type
=
args
.
specgram_type
,
specgram_type
=
args
.
specgram_type
,
num_threads
=
args
.
num_proc_data
)
num_threads
=
args
.
num_proc_data
,
keep_transcription_text
=
True
)
batch_reader
=
data_generator
.
batch_reader_creator
(
batch_reader
=
data_generator
.
batch_reader_creator
(
manifest_path
=
args
.
test_manifest
,
manifest_path
=
args
.
test_manifest
,
batch_size
=
args
.
batch_size
,
batch_size
=
args
.
batch_size
,
...
@@ -104,8 +105,7 @@ def evaluate():
...
@@ -104,8 +105,7 @@ def evaluate():
language_model_path
=
args
.
lang_model_path
,
language_model_path
=
args
.
lang_model_path
,
num_processes
=
args
.
num_proc_bsearch
)
num_processes
=
args
.
num_proc_bsearch
)
target_transcripts
=
[
target_transcripts
=
[
''
.
join
([
data_generator
.
vocab_list
[
token
]
for
token
in
transcript
])
transcript
for
_
,
transcript
in
infer_data
for
_
,
transcript
in
infer_data
]
]
for
target
,
result
in
zip
(
target_transcripts
,
result_transcripts
):
for
target
,
result
in
zip
(
target_transcripts
,
result_transcripts
):
error_sum
+=
error_rate_func
(
target
,
result
)
error_sum
+=
error_rate_func
(
target
,
result
)
...
...
tools/tune.py
浏览文件 @
39dbcb4d
...
@@ -87,7 +87,8 @@ def tune():
...
@@ -87,7 +87,8 @@ def tune():
mean_std_filepath
=
args
.
mean_std_path
,
mean_std_filepath
=
args
.
mean_std_path
,
augmentation_config
=
'{}'
,
augmentation_config
=
'{}'
,
specgram_type
=
args
.
specgram_type
,
specgram_type
=
args
.
specgram_type
,
num_threads
=
args
.
num_proc_data
)
num_threads
=
args
.
num_proc_data
,
keep_transcription_text
=
True
)
audio_data
=
paddle
.
layer
.
data
(
audio_data
=
paddle
.
layer
.
data
(
name
=
"audio_spectrogram"
,
name
=
"audio_spectrogram"
,
...
@@ -164,8 +165,7 @@ def tune():
...
@@ -164,8 +165,7 @@ def tune():
]
]
target_transcripts
=
[
target_transcripts
=
[
''
.
join
([
data_generator
.
vocab_list
[
token
]
for
token
in
transcript
])
transcript
for
_
,
transcript
in
infer_data
for
_
,
transcript
in
infer_data
]
]
num_ins
+=
len
(
target_transcripts
)
num_ins
+=
len
(
target_transcripts
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录