Skip to content

Commit

Permalink
[Hackathon 7th] 修复 deepspeech2online 的导出问题 (#3935)
Browse files Browse the repository at this point in the history
* Update model.py

* Update model.py
  • Loading branch information
Liyulingyue authored Dec 9, 2024
1 parent e3c4d4b commit 5069111
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions paddlespeech/s2t/exps/deepspeech2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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
Expand Down Expand Up @@ -629,9 +630,19 @@ def static_forward_offline(self, audio, audio_len):

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()
Expand Down

0 comments on commit 5069111

Please sign in to comment.