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

pull/2911/head
zxcd 3 years ago committed by GitHub
parent 8cbf6a2c9a
commit 6728db5b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -152,8 +152,7 @@ class WhisperExecutor(BaseExecutor):
Init model and other resources from a specific path. Init model and other resources from a specific path.
""" """
logger.debug("start to init the model") logger.debug("start to init the model")
# default max_len: unit:second
self.max_len = 50
if hasattr(self, 'model'): if hasattr(self, 'model'):
logger.debug('Model had been initialized.') logger.debug('Model had been initialized.')
return return
@ -339,12 +338,6 @@ class WhisperExecutor(BaseExecutor):
try: try:
audio, audio_sample_rate = soundfile.read( audio, audio_sample_rate = soundfile.read(
audio_file, dtype="int16", always_2d=True) 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: except Exception as e:
logger.exception(e) logger.exception(e)
logger.error( logger.error(

@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI. # 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) # Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper/__init__.py)
from paddlespeech.s2t.models.whisper.whipser import decode from paddlespeech.s2t.models.whisper.whipser import decode

@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI. # 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) # Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper/tokenizer.py)
import os import os

@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI. # 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) # Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper/utils.py)
import zlib import zlib

@ -1,5 +1,5 @@
# MIT License, Copyright (c) 2022 OpenAI. # 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) # Modified from OpenAI Whisper 2022 (https://github.com/openai/whisper/whisper)
import os import os

Loading…
Cancel
Save