Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASR]Whisper remove audio duration limit, test=asr #2900

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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