pull/2157/head
Hui Zhang 3 years ago
parent ad3b1abf55
commit 4bcecc1c5e

@ -18,6 +18,4 @@ from . import audio
# _init_audio_backend must called after audio import
audio.backends.utils._init_audio_backend()
__all__ = [
"audio"
]
__all__ = ["audio"]

@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from . import compliance
from . import datasets
from . import features
@ -19,10 +18,10 @@ from . import functional
from . import io
from . import metric
from . import utils
from ._ops import ops
from paddlespeech.audio.backends import get_audio_backend, list_audio_backends, set_audio_backend
from paddlespeech.audio.backends import get_audio_backend
from paddlespeech.audio.backends import list_audio_backends
from paddlespeech.audio.backends import set_audio_backend
__all__ = [
"io",
@ -35,4 +34,4 @@ __all__ = [
"list_audio_backends",
"get_audio_backend",
"set_audio_backend",
]
]

@ -11,7 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# flake8: noqa
from . import utils
from .utils import get_audio_backend, list_audio_backends, set_audio_backend
from .utils import get_audio_backend
from .utils import list_audio_backends
from .utils import set_audio_backend

@ -15,15 +15,14 @@ import os
import warnings
from typing import Optional
from typing import Tuple
from typing import Union
import numpy as np
import resampy
import soundfile as sf
from scipy.io import wavfile
from ..utils import ParameterError
from ..utils import depth_convert
from ..utils import ParameterError
__all__ = [
'resample',
@ -254,4 +253,4 @@ def load(
def info(filepath: str) -> None:
raise RuntimeError("No audio I/O backend is available.")
raise RuntimeError("No audio I/O backend is available.")

@ -71,7 +71,8 @@ class AudioClassificationDataset(paddle.io.Dataset):
if self.sample_rate is None:
waveform, sample_rate = paddlespeech.audio.load(file)
else:
waveform, sample_rate = paddlespeech.audio.load(file, sr=self.sample_rate)
waveform, sample_rate = paddlespeech.audio.load(
file, sr=self.sample_rate)
feat_func = feat_funcs[self.feat_type]

@ -141,7 +141,8 @@ class OpenRIRNoise(Dataset):
end_sample = int(float(e) * sr)
new_wav_file = os.path.join(self.base_path,
audio_id + f'_chunk_{idx+1:02}.wav')
paddlespeech.audio.save(waveform[start_sample:end_sample], sr, new_wav_file)
paddlespeech.audio.save(waveform[start_sample:end_sample], sr,
new_wav_file)
# id, duration, new_wav
ret.append([chunk, self.chunk_duration, new_wav_file])
else: # Keep whole audio.

@ -13,18 +13,13 @@
# limitations under the License.
from ...cli.utils import DATA_HOME
from ...cli.utils import MODEL_HOME
from .download import decompress
from .download import download_and_decompress
from .download import load_state_dict_from_url
from .error import ParameterError
from .log import Logger
from .log import logger
from .numeric import depth_convert
from .numeric import pcm16to32
from .time import seconds_to_hms
from .time import Timer
from .numeric import pcm16to32
from .numeric import depth_convert

@ -11,13 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
from typing import Union
__all__ = [
"pcm16to32",
"depth_convert"
]
import numpy as np
__all__ = ["pcm16to32", "depth_convert"]
def pcm16to32(audio: np.ndarray) -> np.ndarray:
"""pcm int16 to float32
@ -105,4 +104,4 @@ def depth_convert(y: np.ndarray, dtype: Union[type, str]) -> np.ndarray:
if dtype in ['float32', 'float64']:
org_dtype = y.dtype
y = y.astype(dtype) / np.iinfo(org_dtype).max
return y
return y

@ -27,7 +27,6 @@ from setuptools import Command
from setuptools import find_packages
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.command.test import test
from tools import setup_helpers
@ -38,43 +37,13 @@ VERSION = '0.0.0'
COMMITID = 'none'
base = [
"editdistance",
"g2p_en",
"g2pM",
"h5py",
"inflect",
"jieba",
"jsonlines",
"kaldiio",
"librosa==0.8.1",
"loguru",
"matplotlib",
"nara_wpe",
"onnxruntime",
"pandas",
"paddlenlp",
"paddlespeech_feat",
"praatio==5.0.0",
"pypinyin",
"pypinyin-dict",
"python-dateutil",
"pyworld",
"resampy==0.2.2",
"sacrebleu",
"scipy",
"sentencepiece~=0.1.96",
"soundfile~=0.10",
"textgrid",
"timer",
"tqdm",
"typeguard",
"visualdl",
"webrtcvad",
"yacs~=0.1.8",
"prettytable",
"zhon",
"colorlog",
"pathos == 0.2.8"
"editdistance", "g2p_en", "g2pM", "h5py", "inflect", "jieba", "jsonlines",
"kaldiio", "librosa==0.8.1", "loguru", "matplotlib", "nara_wpe",
"onnxruntime", "pandas", "paddlenlp", "paddlespeech_feat", "praatio==5.0.0",
"pypinyin", "pypinyin-dict", "python-dateutil", "pyworld", "resampy==0.2.2",
"sacrebleu", "scipy", "sentencepiece~=0.1.96", "soundfile~=0.10",
"textgrid", "timer", "tqdm", "typeguard", "visualdl", "webrtcvad",
"yacs~=0.1.8", "prettytable", "zhon", "colorlog", "pathos == 0.2.8"
]
server = [
@ -141,7 +110,9 @@ def check_output(cmd: Union[str, List[str], Tuple[str]], shell=False):
def _run_cmd(cmd):
try:
return subprocess.check_output(cmd, cwd=ROOT_DIR, stderr=subprocess.DEVNULL).decode("ascii").strip()
return subprocess.check_output(
cmd, cwd=ROOT_DIR,
stderr=subprocess.DEVNULL).decode("ascii").strip()
except Exception:
return None
@ -193,7 +164,6 @@ class DevelopCommand(develop):
self.execute(_post_install, (self.install_lib, ), msg="Post Install...")
class TestCommand(test):
def finalize_options(self):
test.finalize_options(self)
@ -207,7 +177,7 @@ class TestCommand(test):
# cmd: python setup.py upload
class UploadCommand(distutils.cmd.Command):
class UploadCommand(Command):
description = "Build and publish the package."
user_options = []
@ -270,7 +240,6 @@ class clean(distutils.command.clean.clean):
def main():
sha = _run_cmd(["git", "rev-parse", "HEAD"]) # commit id
branch = _run_cmd(["git", "rev-parse", "--abbrev-ref", "HEAD"])
tag = _run_cmd(["git", "describe", "--tags", "--exact-match", "@"])

Loading…
Cancel
Save