Skip to content

Commit 248cc03

Browse files
author
Yibing Liu
authored
Merge pull request #347 from kuke/coding_convert
Convert decoding results to unicode in DS2
2 parents 6350373 + 7d2a19e commit 248cc03

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

deep_speech_2/decoders/swig_wrapper.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def ctc_greedy_decoder(probs_seq, vocabulary):
3535
:return: Decoding result string.
3636
:rtype: basestring
3737
"""
38-
return swig_decoders.ctc_greedy_decoder(probs_seq.tolist(), vocabulary)
38+
result = swig_decoders.ctc_greedy_decoder(probs_seq.tolist(), vocabulary)
39+
return result.decode('utf-8')
3940

4041

4142
def ctc_beam_search_decoder(probs_seq,
@@ -69,9 +70,11 @@ def ctc_beam_search_decoder(probs_seq,
6970
results, in descending order of the probability.
7071
:rtype: list
7172
"""
72-
return swig_decoders.ctc_beam_search_decoder(probs_seq.tolist(), vocabulary,
73-
beam_size, cutoff_prob,
74-
cutoff_top_n, ext_scoring_func)
73+
beam_results = swig_decoders.ctc_beam_search_decoder(
74+
probs_seq.tolist(), vocabulary, beam_size, cutoff_prob, cutoff_top_n,
75+
ext_scoring_func)
76+
beam_results = [(res[0], res[1].decode('utf-8')) for res in beam_results]
77+
return beam_results
7578

7679

7780
def ctc_beam_search_decoder_batch(probs_split,
@@ -111,6 +114,11 @@ def ctc_beam_search_decoder_batch(probs_split,
111114
"""
112115
probs_split = [probs_seq.tolist() for probs_seq in probs_split]
113116

114-
return swig_decoders.ctc_beam_search_decoder_batch(
117+
batch_beam_results = swig_decoders.ctc_beam_search_decoder_batch(
115118
probs_split, vocabulary, beam_size, num_processes, cutoff_prob,
116119
cutoff_top_n, ext_scoring_func)
120+
batch_beam_results = [
121+
[(res[0], res[1].decode("utf-8")) for res in beam_results]
122+
for beam_results in batch_beam_results
123+
]
124+
return batch_beam_results

deep_speech_2/examples/tiny/run_train.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ python -u train.py \
3333
--shuffle_method='batch_shuffle_clipped'
3434

3535
if [ $? -ne 0 ]; then
36-
echo "Fail to do inference!"
36+
echo "Fail in training!"
3737
exit 1
3838
fi
3939

deep_speech_2/train.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def train():
118118

119119
def main():
120120
print_arguments(args)
121-
paddle.init(use_gpu=args.use_gpu, trainer_count=args.trainer_count)
121+
paddle.init(use_gpu=args.use_gpu,
122+
trainer_count=args.trainer_count,
123+
log_clipping=True)
122124
train()
123125

124126

0 commit comments

Comments
 (0)