Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions deep_speech_2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,31 @@ More help for arguments:
python train.py --help
```

### Inferencing
### Preparing language model

The following steps, inference, parameters tuning and evaluating, will require a language model during decoding.
A compressed language model is provided and can be accessed by

```
cd ./lm
sh run.sh
cd ..
```

### Inference

For GPU inference

```
CUDA_VISIBLE_DEVICES=0 python infer.py
```

For CPU inference

```
python infer.py --use_gpu=False
```

More help for arguments:

```
Expand All @@ -92,14 +111,24 @@ python evaluate.py --help

### Parameters tuning

Parameters tuning for the CTC beam search decoder
Usually, the parameters $\alpha$ and $\beta$ for the CTC [prefix beam search](https://arxiv.org/abs/1408.2873) decoder need to be tuned after retraining the acoustic model.

For GPU tuning

```
CUDA_VISIBLE_DEVICES=0 python tune.py
```

For CPU tuning

```
python tune.py --use_gpu=False
```

More help for arguments:

```
python tune.py --help
```

Then reset parameters with the tuning result before inference or evaluating.
3 changes: 2 additions & 1 deletion deep_speech_2/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
)
parser.add_argument(
"--language_model_path",
default="lm/data/1Billion.klm",
default="lm/data/common_crawl_00.prune01111.trie.klm",
type=str,
help="Path for language model. (default: %(default)s)")
parser.add_argument(
Expand Down Expand Up @@ -139,6 +139,7 @@ def evaluate():
batch_reader = data_generator.batch_reader_creator(
manifest_path=args.decode_manifest_path,
batch_size=args.batch_size,
min_batch_size=1,
sortagrad=False,
shuffle_method=None)

Expand Down
2 changes: 1 addition & 1 deletion deep_speech_2/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
help="Number of output per sample in beam search. (default: %(default)d)")
parser.add_argument(
"--language_model_path",
default="lm/data/1Billion.klm",
default="lm/data/common_crawl_00.prune01111.trie.klm",
type=str,
help="Path for language model. (default: %(default)s)")
parser.add_argument(
Expand Down
20 changes: 18 additions & 2 deletions deep_speech_2/lm/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
echo "Downloading language model."
echo "Downloading language model ..."

mkdir data

LM=common_crawl_00.prune01111.trie.klm
MD5="099a601759d467cd0a8523ff939819c5"

wget -c http://paddlepaddle.bj.bcebos.com/model_zoo/speech/$LM -P ./data

echo "Checking md5sum ..."
md5_tmp=`md5sum ./data/$LM | awk -F[' '] '{print $1}'`

if [ $MD5 != $md5_tmp ]; then
echo "Fail to download the language model!"
exit 1
fi



wget -c ftp://xxx/xxx/en.00.UNKNOWN.klm -P ./data
2 changes: 1 addition & 1 deletion deep_speech_2/tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
help="Width for beam search decoding. (default: %(default)d)")
parser.add_argument(
"--language_model_path",
default="lm/data/1Billion.klm",
default="lm/data/common_crawl_00.prune01111.trie.klm",
type=str,
help="Path for language model. (default: %(default)s)")
parser.add_argument(
Expand Down