format and fix pre-commit (#1120)

pull/1122/head
Hui Zhang 3 years ago committed by GitHub
parent c4a79ccea4
commit 51d7a07c6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,6 +25,7 @@ import os
from pathlib import Path
import soundfile
from utils.utility import download
from utils.utility import unpack

@ -25,6 +25,7 @@ import os
from pathlib import Path
import soundfile
from utils.utility import download
from utils.utility import unpack

@ -27,6 +27,7 @@ import os
from multiprocessing.pool import Pool
import soundfile
from utils.utility import download
from utils.utility import unpack

@ -26,6 +26,7 @@ import os
from multiprocessing.pool import Pool
import soundfile
from utils.utility import download
from utils.utility import unpack

@ -28,6 +28,7 @@ import json
import os
import soundfile
from utils.utility import download
from utils.utility import unpack

@ -28,6 +28,7 @@ import json
import os
import soundfile
from utils.utility import download
from utils.utility import unzip

@ -26,6 +26,7 @@ from multiprocessing.pool import Pool
from pathlib import Path
import soundfile
from utils.utility import download
from utils.utility import unpack

@ -27,6 +27,7 @@ import string
from pathlib import Path
import soundfile
from utils.utility import unzip
URL_ROOT = ""

@ -27,6 +27,7 @@ import shutil
import subprocess
import soundfile
from utils.utility import download_multi
from utils.utility import getfile_insensitive
from utils.utility import unpack

@ -75,4 +75,3 @@ PANN | ESC-50 |[pann-esc50]("./examples/esc50/cls0")|[panns_cnn6.tar.gz](https:/
| [Ds2 Offline Aishell model](https://deepspeech.bj.bcebos.com/mandarin_models/aishell_model_v1.8_to_v2.x.tar.gz) | Aishell Dataset | Char-based | 234 MB | 2 Conv + 3 bidirectional GRU layers | 0.0804 | - | 151 h |
| [Ds2 Offline Librispeech model](https://deepspeech.bj.bcebos.com/eng_models/librispeech_v1.8_to_v2.x.tar.gz) | Librispeech Dataset | Word-based | 307 MB | 2 Conv + 3 bidirectional sharing weight RNN layers | - | 0.0685 | 960 h |
| [Ds2 Offline Baidu en8k model](https://deepspeech.bj.bcebos.com/eng_models/baidu_en8k_v1.8_to_v2.x.tar.gz) | Baidu Internal English Dataset | Word-based | 273 MB | 2 Conv + 3 bidirectional GRU layers | - | 0.0541 | 8628 h |

@ -11,8 +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.
import _locale
from .asr import ASRExecutor
from .base_commands import BaseCommand
from .base_commands import HelpCommand

@ -16,10 +16,11 @@ import os
import numpy as np
from paddle import inference
from scipy.special import softmax
from paddleaudio.backends import load as load_audio
from paddleaudio.datasets import ESC50
from paddleaudio.features import melspectrogram
from scipy.special import softmax
# yapf: disable
parser = argparse.ArgumentParser()

@ -15,8 +15,8 @@ import argparse
import os
import paddle
from paddleaudio.datasets import ESC50
from paddleaudio.datasets import ESC50
from paddlespeech.cls.models import cnn14
from paddlespeech.cls.models import SoundClassifier

@ -16,11 +16,11 @@ import argparse
import numpy as np
import paddle
import paddle.nn.functional as F
from paddleaudio.backends import load as load_audio
from paddleaudio.datasets import ESC50
from paddleaudio.features import LogMelSpectrogram
from paddleaudio.features import melspectrogram
from paddlespeech.cls.models import cnn14
from paddlespeech.cls.models import SoundClassifier

@ -15,11 +15,11 @@ import argparse
import os
import paddle
from paddleaudio.datasets import ESC50
from paddleaudio.features import LogMelSpectrogram
from paddleaudio.utils import logger
from paddleaudio.utils import Timer
from paddlespeech.cls.models import cnn14
from paddlespeech.cls.models import SoundClassifier

@ -15,6 +15,7 @@ import os
import paddle.nn as nn
import paddle.nn.functional as F
from paddleaudio.utils.download import load_state_dict_from_url
from paddleaudio.utils.env import MODEL_HOME

@ -356,7 +356,7 @@ class AudioSegment():
# sox, slow
try:
import soxbindings as sox
except:
except ImportError:
try:
from paddlespeech.s2t.utils import dynamic_pip_install
package = "sox"
@ -364,8 +364,9 @@ class AudioSegment():
package = "soxbindings"
dynamic_pip_install.install(package)
import soxbindings as sox
except:
raise RuntimeError("Can not install soxbindings on your system." )
except Exception:
raise RuntimeError(
"Can not install soxbindings on your system.")
tfm = sox.Transformer()
tfm.set_globals(multithread=False)

@ -102,9 +102,11 @@ def read_manifest(
with jsonlines.open(manifest_path, 'r') as reader:
for json_data in reader:
feat_len = json_data["input"][0]["shape"][
0] if "input" in json_data and "shape" in json_data["input"][0] else 1.0
0] if "input" in json_data and "shape" in json_data["input"][
0] else 1.0
token_len = json_data["output"][0]["shape"][
0] if "output" in json_data and "shape" in json_data["output"][0] else 1.0
0] if "output" in json_data and "shape" in json_data["output"][
0] else 1.0
conditions = [
feat_len >= min_input_len,
feat_len <= max_input_len,

@ -20,13 +20,13 @@ from paddle.io import DistributedBatchSampler
from paddlespeech.s2t.utils.log import Log
logger = Log(__name__).getlog()
__all__ = [
"SortagradDistributedBatchSampler",
"SortagradBatchSampler",
]
logger = Log(__name__).getlog()
def _batch_shuffle(indices, batch_size, epoch, clipped=False):
"""Put similarly-sized instances into minibatches for better efficiency

@ -17,11 +17,11 @@ from paddlespeech.s2t.utils import dynamic_pip_install
try:
import swig_decoders
except:
except ImportError:
try:
package_name = 'paddlespeech_ctcdecoders'
dynamic_pip_install.install(package_name)
except:
except Exception:
raise RuntimeError(
"Can not install package paddlespeech_ctcdecoders on your system. \
The DeepSpeech2 model is not supported for your system")

@ -17,11 +17,11 @@ from paddlespeech.s2t.utils import dynamic_pip_install
try:
import swig_decoders
except:
except ImportError:
try:
package_name = 'paddlespeech_ctcdecoders'
dynamic_pip_install.install(package_name)
except:
except Exception:
raise RuntimeError(
"Can not install package paddlespeech_ctcdecoders on your system. \
The DeepSpeech2 model is not supported for your system")

@ -28,7 +28,7 @@ try:
from paddlespeech.s2t.decoders.ctcdecoder.swig_wrapper import ctc_beam_search_decoder_batch # noqa: F401
from paddlespeech.s2t.decoders.ctcdecoder.swig_wrapper import ctc_greedy_decoder # noqa: F401
from paddlespeech.s2t.decoders.ctcdecoder.swig_wrapper import Scorer # noqa: F401
except:
except ImportError:
try:
from paddlespeech.s2t.utils import dynamic_pip_install
package_name = 'paddlespeech_ctcdecoders'

@ -221,6 +221,8 @@ class Trainer():
if hasattr(self.train_loader, "batch_sampler"):
batch_sampler = self.train_loader.batch_sampler
if isinstance(batch_sampler, paddle.io.DistributedBatchSampler):
logger.debug(
f"train_loader.batch_sample set epoch: {self.epoch}")
batch_sampler.set_epoch(self.epoch)
def before_train(self):

@ -147,7 +147,7 @@ class SpeedPerturbationSox():
try:
import soxbindings as sox
except:
except ImportError:
try:
from paddlespeech.s2t.utils import dynamic_pip_install
package = "sox"
@ -155,8 +155,10 @@ class SpeedPerturbationSox():
package = "soxbindings"
dynamic_pip_install.install(package)
import soxbindings as sox
except:
raise RuntimeError("Can not install soxbindings on your system." )
except Exception:
raise RuntimeError(
"Can not install soxbindings on your system.")
self.sox = sox
if utt2ratio is not None:
self.utt2ratio = {}
@ -200,7 +202,7 @@ class SpeedPerturbationSox():
else:
ratio = self.state.uniform(self.lower, self.upper)
tfm = sox.Transformer()
tfm = self.sox.Transformer()
tfm.set_globals(multithread=False)
tfm.speed(ratio)
y = tfm.build_array(input_array=x, sample_rate_in=self.sr)

@ -5,6 +5,7 @@ import functools
from pathlib import Path
import jsonlines
from utils.utility import add_arguments
from utils.utility import print_arguments

Loading…
Cancel
Save