Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
9571b6fc
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
12 个月 前同步成功
通知
205
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,发现更多精彩内容 >>
提交
9571b6fc
编写于
9月 05, 2017
作者:
X
Xinghai Sun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add back utils.py.
上级
8b64ef29
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
82 addition
and
146 deletion
+82
-146
demo_server.py
demo_server.py
+5
-21
evaluate.py
evaluate.py
+5
-21
infer.py
infer.py
+5
-21
tools/build_vocab.py
tools/build_vocab.py
+5
-20
tools/compute_mean_std.py
tools/compute_mean_std.py
+5
-20
train.py
train.py
+5
-21
tune.py
tune.py
+5
-22
utils.py
utils.py
+47
-0
未找到文件。
demo_server.py
浏览文件 @
9571b6fc
...
...
@@ -3,7 +3,7 @@ import os
import
time
import
random
import
argparse
import
distutils.util
import
functools
from
time
import
gmtime
,
strftime
import
SocketServer
import
struct
...
...
@@ -12,20 +12,11 @@ import paddle.v2 as paddle
from
data_utils.data
import
DataGenerator
from
model
import
DeepSpeech2Model
from
data_utils.utils
import
read_manifest
from
utils
import
add_arguments
,
print_arguments
def
add_arg
(
argname
,
type
,
default
,
help
,
**
kwargs
):
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
parser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
# yapf: disable
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'host_port'
,
int
,
8086
,
"Server's IP port."
)
add_arg
(
'beam_size'
,
int
,
500
,
"Beam search width."
)
add_arg
(
'num_conv_layers'
,
int
,
2
,
"# of convolution layers."
)
...
...
@@ -68,8 +59,8 @@ add_arg('specgram_type', str,
'linear'
,
"Audio feature type. Options: linear, mfcc."
,
choices
=
[
'linear'
,
'mfcc'
])
args
=
parser
.
parse_args
()
# yapf: disable
args
=
parser
.
parse_args
()
class
AsrTCPServer
(
SocketServer
.
TCPServer
):
...
...
@@ -198,13 +189,6 @@ def start_server():
server
.
serve_forever
()
def
print_arguments
(
args
):
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
def
main
():
print_arguments
(
args
)
paddle
.
init
(
use_gpu
=
args
.
use_gpu
,
trainer_count
=
1
)
...
...
evaluate.py
浏览文件 @
9571b6fc
...
...
@@ -3,26 +3,17 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
distutils.util
import
argparse
import
functools
import
paddle.v2
as
paddle
from
data_utils.data
import
DataGenerator
from
model
import
DeepSpeech2Model
from
error_rate
import
wer
,
cer
from
utils
import
add_arguments
,
print_arguments
def
add_arg
(
argname
,
type
,
default
,
help
,
**
kwargs
):
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
parser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
# yapf: disable
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'batch_size'
,
int
,
128
,
"Minibatch size."
)
add_arg
(
'trainer_count'
,
int
,
8
,
"# of Trainers (CPUs or GPUs)."
)
add_arg
(
'beam_size'
,
int
,
500
,
"Beam search width."
)
...
...
@@ -66,8 +57,8 @@ add_arg('specgram_type', str,
'linear'
,
"Audio feature type. Options: linear, mfcc."
,
choices
=
[
'linear'
,
'mfcc'
])
args
=
parser
.
parse_args
()
# yapf: disable
args
=
parser
.
parse_args
()
def
evaluate
():
...
...
@@ -120,13 +111,6 @@ def evaluate():
(
args
.
error_rate_type
,
num_ins
,
num_ins
,
error_sum
/
num_ins
))
def
print_arguments
(
args
):
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
def
main
():
print_arguments
(
args
)
paddle
.
init
(
use_gpu
=
args
.
use_gpu
,
trainer_count
=
args
.
trainer_count
)
...
...
infer.py
浏览文件 @
9571b6fc
...
...
@@ -4,25 +4,16 @@ from __future__ import division
from
__future__
import
print_function
import
argparse
import
distutils.util
import
functools
import
paddle.v2
as
paddle
from
data_utils.data
import
DataGenerator
from
model
import
DeepSpeech2Model
from
error_rate
import
wer
,
cer
from
utils
import
add_arguments
,
print_arguments
def
add_arg
(
argname
,
type
,
default
,
help
,
**
kwargs
):
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
parser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
# yapf: disable
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'num_samples'
,
int
,
10
,
"# of samples to infer."
)
add_arg
(
'trainer_count'
,
int
,
8
,
"# of Trainers (CPUs or GPUs)."
)
add_arg
(
'beam_size'
,
int
,
500
,
"Beam search width."
)
...
...
@@ -65,8 +56,8 @@ add_arg('specgram_type', str,
'linear'
,
"Audio feature type. Options: linear, mfcc."
,
choices
=
[
'linear'
,
'mfcc'
])
args
=
parser
.
parse_args
()
# yapf: disable
args
=
parser
.
parse_args
()
def
infer
():
...
...
@@ -116,13 +107,6 @@ def infer():
(
args
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
def
print_arguments
(
args
):
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
def
main
():
print_arguments
(
args
)
paddle
.
init
(
use_gpu
=
args
.
use_gpu
,
trainer_count
=
args
.
trainer_count
)
...
...
tools/build_vocab.py
浏览文件 @
9571b6fc
...
...
@@ -7,26 +7,18 @@ from __future__ import division
from
__future__
import
print_function
import
argparse
import
functools
import
codecs
import
json
from
collections
import
Counter
import
os.path
import
_init_paths
from
data_utils
import
utils
from
utils
import
add_arguments
,
print_arguments
def
add_arg
(
argname
,
type
,
default
,
help
,
**
kwargs
):
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
parser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
# yapf: disable
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'count_threshold'
,
int
,
0
,
"Truncation threshold for char counts."
)
add_arg
(
'vocab_path'
,
str
,
'datasets/vocab/zh_vocab.txt'
,
...
...
@@ -37,8 +29,8 @@ add_arg('manifest_paths', str,
"You can provide multiple manifest files."
,
nargs
=
'+'
,
required
=
True
)
args
=
parser
.
parse_args
()
# yapf: disable
args
=
parser
.
parse_args
()
def
count_manifest
(
counter
,
manifest_path
):
...
...
@@ -48,13 +40,6 @@ def count_manifest(counter, manifest_path):
counter
.
update
(
char
)
def
print_arguments
(
args
):
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
def
main
():
print_arguments
(
args
)
...
...
tools/compute_mean_std.py
浏览文件 @
9571b6fc
...
...
@@ -4,24 +4,16 @@ from __future__ import division
from
__future__
import
print_function
import
argparse
import
functools
import
_init_paths
from
data_utils.normalizer
import
FeatureNormalizer
from
data_utils.augmentor.augmentation
import
AugmentationPipeline
from
data_utils.featurizer.audio_featurizer
import
AudioFeaturizer
from
utils
import
add_arguments
,
print_arguments
def
add_arg
(
argname
,
type
,
default
,
help
,
**
kwargs
):
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
parser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
# yapf: disable
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'num_samples'
,
int
,
2000
,
"# of samples to for statistics."
)
add_arg
(
'specgram_type'
,
str
,
'linear'
,
...
...
@@ -33,15 +25,8 @@ add_arg('manifest_path', str,
add_arg
(
'output_path'
,
str
,
'mean_std.npz'
,
"Filepath of write mean and stddev to (.npz)."
)
args
=
parser
.
parse_args
()
# yapf: disable
def
print_arguments
(
args
):
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
args
=
parser
.
parse_args
()
def
main
():
...
...
train.py
浏览文件 @
9571b6fc
...
...
@@ -4,24 +4,15 @@ from __future__ import division
from
__future__
import
print_function
import
argparse
import
distutils.util
import
functools
import
paddle.v2
as
paddle
from
model
import
DeepSpeech2Model
from
data_utils.data
import
DataGenerator
from
utils
import
add_arguments
,
print_arguments
def
add_arg
(
argname
,
type
,
default
,
help
,
**
kwargs
):
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
parser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
# yapf: disable
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'batch_size'
,
int
,
256
,
"Minibatch size."
)
add_arg
(
'trainer_count'
,
int
,
8
,
"# of Trainers (CPUs or GPUs)."
)
add_arg
(
'num_passes'
,
int
,
200
,
"# of training epochs."
)
...
...
@@ -70,8 +61,8 @@ add_arg('shuffle_method', str,
'batch_shuffle_clipped'
,
"Shuffle method."
,
choices
=
[
'instance_shuffle'
,
'batch_shuffle'
,
'batch_shuffle_clipped'
])
args
=
parser
.
parse_args
()
# yapf: disable
args
=
parser
.
parse_args
()
def
train
():
...
...
@@ -123,13 +114,6 @@ def train():
is_local
=
args
.
is_local
)
def
print_arguments
(
args
):
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
def
main
():
print_arguments
(
args
)
paddle
.
init
(
use_gpu
=
args
.
use_gpu
,
trainer_count
=
args
.
trainer_count
)
...
...
tune.py
浏览文件 @
9571b6fc
...
...
@@ -4,26 +4,17 @@ from __future__ import division
from
__future__
import
print_function
import
numpy
as
np
import
distutils.util
import
argparse
import
functools
import
paddle.v2
as
paddle
from
data_utils.data
import
DataGenerator
from
model
import
DeepSpeech2Model
from
error_rate
import
wer
from
utils
import
add_arguments
,
print_arguments
def
add_arg
(
argname
,
type
,
default
,
help
,
**
kwargs
):
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
parser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
# yapf: disable
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'num_samples'
,
int
,
100
,
"# of samples to infer."
)
add_arg
(
'trainer_count'
,
int
,
8
,
"# of Trainers (CPUs or GPUs)."
)
add_arg
(
'beam_size'
,
int
,
500
,
"Beam search width."
)
...
...
@@ -66,9 +57,8 @@ add_arg('specgram_type', str,
'linear'
,
"Audio feature type. Options: linear, mfcc."
,
choices
=
[
'linear'
,
'mfcc'
])
args
=
parser
.
parse_args
()
# yapf: disable
args
=
parser
.
parse_args
()
def
tune
():
...
...
@@ -130,13 +120,6 @@ def tune():
(
alpha
,
beta
,
wer_sum
/
num_ins
))
def
print_arguments
(
args
):
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
def
main
():
print_arguments
(
args
)
paddle
.
init
(
use_gpu
=
args
.
use_gpu
,
trainer_count
=
args
.
trainer_count
)
...
...
utils.py
0 → 100644
浏览文件 @
9571b6fc
"""Contains common utility functions."""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
distutils.util
def
print_arguments
(
args
):
"""Print argparse's arguments.
Usage:
.. code-block:: python
parser = argparse.ArgumentParser()
parser.add_argument("name", default="Jonh", type=str, help="User name.")
args = parser.parse_args()
print_arguments(args)
:param args: Input argparse.Namespace for printing.
:type args: argparse.Namespace
"""
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
def
add_arguments
(
argname
,
type
,
default
,
help
,
argparser
,
**
kwargs
):
"""Add argparse's argument.
Usage:
.. code-block:: python
parser = argparse.ArgumentParser()
add_argument("name", str, "Jonh", "User name.", parser)
args = parser.parse_args()
"""
type
=
distutils
.
util
.
strtobool
if
type
==
bool
else
type
argparser
.
add_argument
(
"--"
+
argname
,
default
=
default
,
type
=
type
,
help
=
help
+
' Default: %(default)s.'
,
**
kwargs
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录