From 645b3a397e119c6ef475d4fe0aa6e5372a32d55f Mon Sep 17 00:00:00 2001 From: yangyaming Date: Sun, 17 Sep 2017 19:38:33 +0800 Subject: [PATCH] fix bugs for model.py and demo_server.py. --- deep_speech_2/cloud/pcloud_submit.sh | 2 +- deep_speech_2/cloud/pcloud_train.sh | 2 +- deep_speech_2/cloud/pcloud_upload_data.sh | 2 +- deep_speech_2/deploy/demo_server.py | 2 +- deep_speech_2/examples/librispeech/run_data.sh | 2 +- deep_speech_2/examples/librispeech/run_infer.sh | 2 +- deep_speech_2/examples/librispeech/run_infer_golden.sh | 2 +- deep_speech_2/examples/librispeech/run_test.sh | 2 +- deep_speech_2/examples/librispeech/run_test_golden.sh | 2 +- deep_speech_2/examples/librispeech/run_train.sh | 2 +- deep_speech_2/examples/librispeech/run_tune.sh | 2 +- deep_speech_2/examples/mandarin/run_demo_client.sh | 2 +- deep_speech_2/examples/mandarin/run_demo_server.sh | 2 +- deep_speech_2/examples/tiny/run_data.sh | 2 +- deep_speech_2/examples/tiny/run_infer.sh | 2 +- deep_speech_2/examples/tiny/run_infer_golden.sh | 2 +- deep_speech_2/examples/tiny/run_test.sh | 2 +- deep_speech_2/examples/tiny/run_test_golden.sh | 2 +- deep_speech_2/examples/tiny/run_train.sh | 2 +- deep_speech_2/examples/tiny/run_tune.sh | 2 +- deep_speech_2/model_utils/model.py | 3 ++- deep_speech_2/models/aishell/download_model.sh | 2 +- deep_speech_2/models/librispeech/download_model.sh | 2 +- deep_speech_2/models/lm/download_lm_ch.sh | 2 +- deep_speech_2/models/lm/download_lm_en.sh | 2 +- deep_speech_2/setup.sh | 2 +- 26 files changed, 27 insertions(+), 26 deletions(-) diff --git a/deep_speech_2/cloud/pcloud_submit.sh b/deep_speech_2/cloud/pcloud_submit.sh index 378a7c6e..99e458db 100644 --- a/deep_speech_2/cloud/pcloud_submit.sh +++ b/deep_speech_2/cloud/pcloud_submit.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash TRAIN_MANIFEST="cloud/cloud_manifests/cloud.manifest.train" DEV_MANIFEST="cloud/cloud_manifests/cloud.manifest.dev" diff --git a/deep_speech_2/cloud/pcloud_train.sh b/deep_speech_2/cloud/pcloud_train.sh index d04132f9..26e537c2 100644 --- a/deep_speech_2/cloud/pcloud_train.sh +++ b/deep_speech_2/cloud/pcloud_train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash TRAIN_MANIFEST=$1 DEV_MANIFEST=$2 diff --git a/deep_speech_2/cloud/pcloud_upload_data.sh b/deep_speech_2/cloud/pcloud_upload_data.sh index 4ef235ef..71bb4af1 100644 --- a/deep_speech_2/cloud/pcloud_upload_data.sh +++ b/deep_speech_2/cloud/pcloud_upload_data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash mkdir cloud_manifests diff --git a/deep_speech_2/deploy/demo_server.py b/deep_speech_2/deploy/demo_server.py index a7157001..7c558419 100644 --- a/deep_speech_2/deploy/demo_server.py +++ b/deep_speech_2/deploy/demo_server.py @@ -100,7 +100,7 @@ class AsrRequestHandler(SocketServer.BaseRequestHandler): finish_time = time.time() print("Response Time: %f, Transcript: %s" % (finish_time - start_time, transcript)) - self.request.sendall(transcript) + self.request.sendall(transcript.encode('utf-8')) def _write_to_file(self, data): # prepare save dir and filename diff --git a/deep_speech_2/examples/librispeech/run_data.sh b/deep_speech_2/examples/librispeech/run_data.sh index f65aa233..bdd5abb5 100644 --- a/deep_speech_2/examples/librispeech/run_data.sh +++ b/deep_speech_2/examples/librispeech/run_data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/librispeech/run_infer.sh b/deep_speech_2/examples/librispeech/run_infer.sh index 6b790502..eb812440 100644 --- a/deep_speech_2/examples/librispeech/run_infer.sh +++ b/deep_speech_2/examples/librispeech/run_infer.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/librispeech/run_infer_golden.sh b/deep_speech_2/examples/librispeech/run_infer_golden.sh index 679bd1bf..eeccfdeb 100644 --- a/deep_speech_2/examples/librispeech/run_infer_golden.sh +++ b/deep_speech_2/examples/librispeech/run_infer_golden.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/librispeech/run_test.sh b/deep_speech_2/examples/librispeech/run_test.sh index 9709234a..7ef06ba9 100644 --- a/deep_speech_2/examples/librispeech/run_test.sh +++ b/deep_speech_2/examples/librispeech/run_test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/librispeech/run_test_golden.sh b/deep_speech_2/examples/librispeech/run_test_golden.sh index a505cdc7..86fe1530 100644 --- a/deep_speech_2/examples/librispeech/run_test_golden.sh +++ b/deep_speech_2/examples/librispeech/run_test_golden.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/librispeech/run_train.sh b/deep_speech_2/examples/librispeech/run_train.sh index 07575dde..9aa5e0d1 100644 --- a/deep_speech_2/examples/librispeech/run_train.sh +++ b/deep_speech_2/examples/librispeech/run_train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/librispeech/run_tune.sh b/deep_speech_2/examples/librispeech/run_tune.sh index 05c024be..abc28d36 100644 --- a/deep_speech_2/examples/librispeech/run_tune.sh +++ b/deep_speech_2/examples/librispeech/run_tune.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/mandarin/run_demo_client.sh b/deep_speech_2/examples/mandarin/run_demo_client.sh index dfde20f8..bf8e5451 100644 --- a/deep_speech_2/examples/mandarin/run_demo_client.sh +++ b/deep_speech_2/examples/mandarin/run_demo_client.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/mandarin/run_demo_server.sh b/deep_speech_2/examples/mandarin/run_demo_server.sh index 703184a6..b0d4bc7f 100644 --- a/deep_speech_2/examples/mandarin/run_demo_server.sh +++ b/deep_speech_2/examples/mandarin/run_demo_server.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash # TODO: replace the model with a mandarin model pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/tiny/run_data.sh b/deep_speech_2/examples/tiny/run_data.sh index 46266daa..a98dab21 100644 --- a/deep_speech_2/examples/tiny/run_data.sh +++ b/deep_speech_2/examples/tiny/run_data.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/tiny/run_infer.sh b/deep_speech_2/examples/tiny/run_infer.sh index 1d33bfbb..dafc99d9 100644 --- a/deep_speech_2/examples/tiny/run_infer.sh +++ b/deep_speech_2/examples/tiny/run_infer.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/tiny/run_infer_golden.sh b/deep_speech_2/examples/tiny/run_infer_golden.sh index 32e9d862..66360a69 100644 --- a/deep_speech_2/examples/tiny/run_infer_golden.sh +++ b/deep_speech_2/examples/tiny/run_infer_golden.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/tiny/run_test.sh b/deep_speech_2/examples/tiny/run_test.sh index f9c3cc11..70cf4bfe 100644 --- a/deep_speech_2/examples/tiny/run_test.sh +++ b/deep_speech_2/examples/tiny/run_test.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/tiny/run_test_golden.sh b/deep_speech_2/examples/tiny/run_test_golden.sh index 080c3c06..e188c81b 100644 --- a/deep_speech_2/examples/tiny/run_test_golden.sh +++ b/deep_speech_2/examples/tiny/run_test_golden.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/tiny/run_train.sh b/deep_speech_2/examples/tiny/run_train.sh index 74d82712..3c2b8a1e 100644 --- a/deep_speech_2/examples/tiny/run_train.sh +++ b/deep_speech_2/examples/tiny/run_train.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/examples/tiny/run_tune.sh b/deep_speech_2/examples/tiny/run_tune.sh index 360c11d5..926e9f8d 100644 --- a/deep_speech_2/examples/tiny/run_tune.sh +++ b/deep_speech_2/examples/tiny/run_tune.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash pushd ../.. > /dev/null diff --git a/deep_speech_2/model_utils/model.py b/deep_speech_2/model_utils/model.py index cf146f8c..09ee3c76 100644 --- a/deep_speech_2/model_utils/model.py +++ b/deep_speech_2/model_utils/model.py @@ -7,6 +7,7 @@ import sys import os import time import gzip +from distutils.dir_util import mkpath import paddle.v2 as paddle from model_utils.lm_scorer import LmScorer from model_utils.decoder import ctc_greedy_decoder, ctc_beam_search_decoder @@ -79,7 +80,7 @@ class DeepSpeech2Model(object): """ # prepare model output directory if not os.path.exists(output_model_dir): - os.mkdir(output_model_dir) + mkpath(output_model_dir) # prepare optimizer and trainer optimizer = paddle.optimizer.Adam( diff --git a/deep_speech_2/models/aishell/download_model.sh b/deep_speech_2/models/aishell/download_model.sh index 4368ee55..77fc84b5 100644 --- a/deep_speech_2/models/aishell/download_model.sh +++ b/deep_speech_2/models/aishell/download_model.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash source ../../utils/utility.sh diff --git a/deep_speech_2/models/librispeech/download_model.sh b/deep_speech_2/models/librispeech/download_model.sh index b5fcd7d8..336502de 100644 --- a/deep_speech_2/models/librispeech/download_model.sh +++ b/deep_speech_2/models/librispeech/download_model.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash source ../../utils/utility.sh diff --git a/deep_speech_2/models/lm/download_lm_ch.sh b/deep_speech_2/models/lm/download_lm_ch.sh index 7f1c47a2..46bfe932 100644 --- a/deep_speech_2/models/lm/download_lm_ch.sh +++ b/deep_speech_2/models/lm/download_lm_ch.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash source ../../utils/utility.sh diff --git a/deep_speech_2/models/lm/download_lm_en.sh b/deep_speech_2/models/lm/download_lm_en.sh index e967e25d..fbfe647e 100644 --- a/deep_speech_2/models/lm/download_lm_en.sh +++ b/deep_speech_2/models/lm/download_lm_en.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#! /usr/bin/env bash source ../../utils/utility.sh diff --git a/deep_speech_2/setup.sh b/deep_speech_2/setup.sh index 6c8a7099..15c6e1e2 100644 --- a/deep_speech_2/setup.sh +++ b/deep_speech_2/setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#! /usr/bin/env bash # install python dependencies if [ -f "requirements.txt" ]; then -- GitLab