Skip to content

Commit

Permalink
adapt view behavior change, fix KeyError. (PaddlePaddle#3794)
Browse files Browse the repository at this point in the history
* adapt view behavior change, fix KeyError.

* fix readme demo run error.

* fixed opencc version
  • Loading branch information
zxcd authored and luotao1 committed Jun 11, 2024
1 parent 2b7334e commit bfeb8a0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion paddlespeech/cli/asr/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def preprocess(self, model_type: str, input: Union[str, os.PathLike]):
# fbank
audio = preprocessing(audio, **preprocess_args)

audio_len = paddle.to_tensor([audio.shape[0]]).unsqueeze(axis=0)
audio_len = paddle.to_tensor(audio.shape[0]).unsqueeze(axis=0)
audio = paddle.to_tensor(audio, dtype='float32').unsqueeze(axis=0)

self._inputs["audio"] = audio
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/s2t/models/wav2vec2/wav2vec2_ASR.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def ctc_greedy_search(self, wav) -> List[List[int]]:
x_lens = x.shape[1]
ctc_probs = self.ctc.log_softmax(x) # (B, maxlen, vocab_size)
topk_prob, topk_index = ctc_probs.topk(1, axis=2) # (B, maxlen, 1)
topk_index = topk_index.view([batch_size, x_lens]) # (B, maxlen)
topk_index = topk_index.reshape([batch_size, x_lens]) # (B, maxlen)

hyps = [hyp.tolist() for hyp in topk_index]
hyps = [remove_duplicates_and_blank(hyp) for hyp in hyps]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"matplotlib",
"nara_wpe",
"onnxruntime>=1.11.0",
"opencc",
"opencc==1.1.6",
"opencc-python-reimplemented",
"pandas",
"paddleaudio>=1.1.0",
Expand Down

0 comments on commit bfeb8a0

Please sign in to comment.