Skip to content

Commit

Permalink
follow comments in code format
Browse files Browse the repository at this point in the history
  • Loading branch information
Yibing Liu committed Jul 5, 2017
1 parent eec7cb4 commit d7f5ee6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
12 changes: 4 additions & 8 deletions deep_speech_2/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from itertools import groupby
import numpy as np
from math import log
import multiprocessing


Expand Down Expand Up @@ -97,13 +98,8 @@ def ctc_beam_search_decoder(probs_seq,
# prefix_set_prev: the set containing selected prefixes
# probs_b_prev: prefixes' probability ending with blank in previous step
# probs_nb_prev: prefixes' probability ending with non-blank in previous step
prefix_set_prev, probs_b_prev, probs_nb_prev = {
'\t': 1.0
}, {
'\t': 1.0
}, {
'\t': 0.0
}
prefix_set_prev = {'\t': 1.0}
probs_b_prev, probs_nb_prev = {'\t': 1.0}, {'\t': 0.0}

## extend prefix in loop
for time_step in xrange(len(probs_seq)):
Expand Down Expand Up @@ -179,7 +175,7 @@ def ctc_beam_search_decoder(probs_seq,
# score last word by external scorer
if (ext_scoring_func is not None) and (result[-1] != ' '):
prob = prob * ext_scoring_func(result)
log_prob = np.log(prob)
log_prob = log(prob)
beam_result.append((log_prob, result))

## output top beam_size decoding results
Expand Down
4 changes: 2 additions & 2 deletions 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="data/en.00.UNKNOWN.klm",
default="lm/data/1Billion.klm",
type=str,
help="Path for language model. (default: %(default)s)")
parser.add_argument(
Expand All @@ -88,7 +88,7 @@
help="Width for beam search decoding. (default: %(default)d)")
parser.add_argument(
"--decode_manifest_path",
default='data/manifest.libri.test-clean',
default='datasets/manifest.test',
type=str,
help="Manifest path for decoding. (default: %(default)s)")
parser.add_argument(
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/en.00.UNKNOWN.klm",
default="lm/data/1Billion.klm",
type=str,
help="Path for language model. (default: %(default)s)")
parser.add_argument(
Expand Down
6 changes: 2 additions & 4 deletions deep_speech_2/lm/lm_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def __call__(self, sentence, log=False):
lm = self._language_model_score(sentence)
word_cnt = self._word_count(sentence)
if log == False:
score = np.power(lm, self._alpha) \
* np.power(word_cnt, self._beta)
score = np.power(lm, self._alpha) * np.power(word_cnt, self._beta)
else:
score = self._alpha * np.log(lm) \
+ self._beta * np.log(word_cnt)
score = self._alpha * np.log(lm) + self._beta * np.log(word_cnt)
return score
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/en.00.UNKNOWN.klm",
default="lm/data/1Billion.klm",
type=str,
help="Path for language model. (default: %(default)s)")
parser.add_argument(
Expand Down

0 comments on commit d7f5ee6

Please sign in to comment.