From 5069111e6dd32308938e03cd2d9457ac0d00864d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:53:34 +0800 Subject: [PATCH] =?UTF-8?q?[Hackathon=207th]=20=E4=BF=AE=E5=A4=8D=20deepsp?= =?UTF-8?q?eech2online=20=E7=9A=84=E5=AF=BC=E5=87=BA=E9=97=AE=E9=A2=98=20(?= =?UTF-8?q?#3935)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update model.py * Update model.py --- paddlespeech/s2t/exps/deepspeech2/model.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/paddlespeech/s2t/exps/deepspeech2/model.py b/paddlespeech/s2t/exps/deepspeech2/model.py index 71075711..7836d3ad 100644 --- a/paddlespeech/s2t/exps/deepspeech2/model.py +++ b/paddlespeech/s2t/exps/deepspeech2/model.py @@ -23,6 +23,7 @@ import paddle from paddle import distributed as dist from paddle import inference +import paddlespeech.utils from paddlespeech.audio.text.text_featurizer import TextFeaturizer from paddlespeech.s2t.io.dataloader import BatchDataLoader from paddlespeech.s2t.models.ds2 import DeepSpeech2InferModel @@ -629,9 +630,19 @@ class DeepSpeech2ExportTester(DeepSpeech2Tester): def setup_model(self): super().setup_model() - deepspeech_config = inference.Config( - self.args.export_path + ".pdmodel", - self.args.export_path + ".pdiparams") + + # after paddle 3.0, support new inference interface + if paddlespeech.utils.satisfy_paddle_version('3.0.0-beta'): + model_dir = os.path.dirname(self.args.export_path) + model_prefix = os.path.basename(self.args.export_path) + deepspeech_config = inference.Config(model_dir, model_prefix) + else: + deepspeech_config = inference.Config( + self.args.export_path + ".pdmodel", + self.args.export_path + ".pdiparams") + + deepspeech_config.disable_mkldnn() + if (os.environ['CUDA_VISIBLE_DEVICES'].strip() != ''): deepspeech_config.enable_use_gpu(100, 0) deepspeech_config.enable_memory_optim()