Skip to content

Commit

Permalink
[ASR]Whisper remove audio duration limit, test=asr (#2900)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcd authored Feb 9, 2023
1 parent 8cbf6a2 commit 6728db5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
9 changes: 1 addition & 8 deletions paddlespeech/cli/whisper/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def _init_from_path(self,
Init model and other resources from a specific path.
"""
logger.debug("start to init the model")
# default max_len: unit:second
self.max_len = 50

if hasattr(self, 'model'):
logger.debug('Model had been initialized.')
return
Expand Down Expand Up @@ -339,12 +338,6 @@ def _check(self, audio_file: str, sample_rate: int, force_yes: bool=False):
try:
audio, audio_sample_rate = soundfile.read(
audio_file, dtype="int16", always_2d=True)
audio_duration = audio.shape[0] / audio_sample_rate
if audio_duration > self.max_len:
logger.error(
f"Please input audio file less then {self.max_len} seconds.\n"
)
return False
except Exception as e:
logger.exception(e)
logger.error(
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/s2t/models/whisper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI.
# Copyright (c) 2022 PaddlePaddle Authors and . All Rights Reserved.
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper/__init__.py)
from paddlespeech.s2t.models.whisper.whipser import decode
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/s2t/models/whisper/tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI.
# Copyright (c) 2022 PaddlePaddle Authors and . All Rights Reserved.
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper/tokenizer.py)
import os
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/s2t/models/whisper/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI.
# Copyright (c) 2022 PaddlePaddle Authors and . All Rights Reserved.
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper/utils.py)
import zlib
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/s2t/models/whisper/whipser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI.
# Copyright (c) 2022 PaddlePaddle Authors and . All Rights Reserved.
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper)
import os
Expand Down

0 comments on commit 6728db5

Please sign in to comment.