From b2fd68cd210c07a6bd5f26635a17ac5b9f196c7e Mon Sep 17 00:00:00 2001 From: ZapBird Date: Thu, 29 Sep 2022 11:08:06 +0800 Subject: [PATCH] =?UTF-8?q?BytesIO=E7=B1=BB=E5=9E=8B=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=A6=81=E4=BF=9D=E8=AF=81=E5=88=87=E5=88=B0=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=EF=BC=8C=E8=BF=99=E6=A0=B7=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=89=8D=E8=83=BD=E5=A4=9F=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E3=80=82=E6=AF=94=E5=A6=82=5F=5Fcall=5F=5F=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E3=80=82=20=5F=5Fcall=5F=5F=E5=87=BD=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0audio=5Ffile=E4=B8=BABytesIO=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=97=B6=E6=89=A7=E8=A1=8C=E5=88=B0self.preprocess(mo?= =?UTF-8?q?del,=20audio=5Ffile)=E4=BC=9A=E6=8A=A5=E9=94=99=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=88=A4=E6=96=ADaudio=5Ffile=E4=B8=BABytesI?= =?UTF-8?q?O=E7=B1=BB=E5=9E=8B=E6=97=B6=E6=89=A7=E8=A1=8Caudio=5Ffile.seek?= =?UTF-8?q?(0)=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- paddlespeech/cli/asr/infer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paddlespeech/cli/asr/infer.py b/paddlespeech/cli/asr/infer.py index 7296776f9..d6489f6d0 100644 --- a/paddlespeech/cli/asr/infer.py +++ b/paddlespeech/cli/asr/infer.py @@ -15,6 +15,7 @@ import argparse import os import sys import time +from io import BytesIO from collections import OrderedDict from typing import List from typing import Optional @@ -229,6 +230,8 @@ class ASRExecutor(BaseExecutor): audio_file = input if isinstance(audio_file, (str, os.PathLike)): logger.debug("Preprocess audio_file:" + audio_file) + elif isinstance(audio_file, BytesIO): + audio_file.seek(0) # Get the object for feature extraction if "deepspeech2" in model_type or "conformer" in model_type or "transformer" in model_type: @@ -352,6 +355,8 @@ class ASRExecutor(BaseExecutor): if not os.path.isfile(audio_file): logger.error("Please input the right audio file path") return False + elif isinstance(audio_file, BytesIO): + audio_file.seek(0) logger.debug("checking the audio file format......") try: