Skip to content

Commit

Permalink
use isort (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
kan-bayashi authored Jan 23, 2023
1 parent fdfb04d commit 817befd
Show file tree
Hide file tree
Showing 43 changed files with 125 additions and 141 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: [3.7]
# 1.6 is failed on cpu: https://github.com/kan-bayashi/ParallelWaveGAN/issues/198
# 1.10 does not support python 3.6
pytorch-version: [1.4, 1.5.1, 1.7.1, 1.8.1, 1.9, 1.10.2, 1.11.0]
pytorch-version: [1.4, 1.5.1, 1.7.1, 1.8.1, 1.9, 1.10.2, 1.11.0, 1.12.1, 1.13.1]
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
Expand All @@ -45,10 +45,11 @@ jobs:
export PATH=shellcheck-stable:$PATH
# not to check the script copied from kaldi
find egs -name "*.sh" | grep -v path.sh | while read line; do shellcheck -x --shell=bash -P $(dirname $line) ${line}; done
- name: Black & Flake8
- name: Black & isort & Flake8
run: |
source tools/venv/bin/activate
black --diff --check parallel_wavegan
isort --diff --check parallel_wavegan
flake8 parallel_wavegan
flake8 --extend-ignore=D test
- name: Pytest
Expand All @@ -62,7 +63,7 @@ jobs:
max-parallel: 10
matrix:
python-version: [3.9]
pytorch-version: [1.11.0]
pytorch-version: [1.13.1]
config:
- "parallel_wavegan.v1.debug.yaml"
- "melgan.v1.debug.yaml"
Expand Down Expand Up @@ -103,8 +104,8 @@ jobs:
strategy:
max-parallel: 10
matrix:
python-version: [3.7]
pytorch-version: [1.9]
python-version: [3.8]
pytorch-version: [1.13.1]
config:
- "melgan_vae.v3.debug.yaml"
- "conditioned_melgan_vae.v3.debug.yaml"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ This repository is tested on Ubuntu 20.04 with a GPU Titan V.
- sox (you can install via `sudo apt install sox` in ubuntu)

Different cuda version should be working but not explicitly tested.
All of the codes are tested on Pytorch 1.4, 1.5.1, 1.7.1, 1.8.1, 1.9, 1.10.2, and 1.11.0.
All of the codes are tested on Pytorch 1.4, 1.5.1, 1.7.1, 1.8.1, 1.9, 1.10.2, 1.11.0, 1.12.1, and 1.13.1.

Pytorch 1.6 works but there are some issues in cpu mode (See #198).

Expand Down
1 change: 0 additions & 1 deletion egs/csd/voc1/local/dataset_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import shutil


UTT_PREFIX = "csd"
DEV_LIST = ["046"]
TEST_LIST = ["047", "048", "049", "050"]
Expand Down
5 changes: 2 additions & 3 deletions egs/kiritan/voc1/local/dataset_split.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python3
import os
import argparse
import sys
import os
import random
import shutil
import sys
from shutil import copyfile


UTT_PREFIX = "kiritan"
DEV_LIST = ["13", "14", "26", "28", "39"]
TEST_LIST = ["01", "16", "17", "27", "44"]
Expand Down
1 change: 1 addition & 0 deletions egs/kising/voc1/local/data_prep.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import os

import librosa
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion egs/natsume/voc1/local/dataset_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import shutil


UTT_PREFIX = "natsume"
DEV_LIST = ["9", "22", "38", "43", "44"]
TEST_LIST = ["2", "13", "24", "25", "27"]
Expand Down
5 changes: 2 additions & 3 deletions egs/no7singing/voc1/local/dataset_split.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python3
import os
import argparse
import sys
import os
import random
import shutil
import sys
from shutil import copyfile


UTT_PREFIX = "no7singing"
DEV_LIST = ["13", "14", "26", "28", "39"]
TEST_LIST = ["01", "16", "17", "27", "44"]
Expand Down
1 change: 0 additions & 1 deletion egs/ofuton_p_utagoe_db/voc1/local/dataset_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import shutil


UTT_PREFIX = "ofuton"
DEV_LIST = [
"chatsumi",
Expand Down
1 change: 0 additions & 1 deletion egs/oniku_kurumi_utagoe_db/voc1/local/dataset_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import shutil


UTT_PREFIX = "oniku"
DEV_LIST = ["chatsumi", "goin_home", "aoimeno_ningyou", "momiji", "tetsudou_shouka"]
TEST_LIST = ["usagito_kame", "sousyunfu", "romance_anonimo", "momotarou", "furusato"]
Expand Down
1 change: 1 addition & 0 deletions egs/opencpop/voc1/local/data_prep.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import os

import librosa
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion egs/pjs/voc1/local/dataset_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import shutil


UTT_PREFIX = "pjs"
DEV_LIST = [
"pjs002",
Expand Down
6 changes: 2 additions & 4 deletions egs/vctk/voc1/local/preprocess_hubert.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@

import librosa
import numpy as np
import soundfile as sf
import resampy
import soundfile as sf
import yaml

from tqdm import tqdm

from parallel_wavegan.datasets import AudioDataset
from parallel_wavegan.datasets import AudioSCPDataset
from parallel_wavegan.datasets import AudioDataset, AudioSCPDataset
from parallel_wavegan.utils import write_hdf5


Expand Down
2 changes: 0 additions & 2 deletions egs/vctk/vq1/local/decode_from_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
import soundfile as sf
import torch
import yaml

from tqdm import tqdm

import parallel_wavegan.models

from parallel_wavegan.utils import load_model


Expand Down
4 changes: 1 addition & 3 deletions egs/vctk/vq1/local/setup_for_vc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

import numpy as np
import yaml

from tqdm import tqdm

from parallel_wavegan.datasets import AudioDataset
from parallel_wavegan.utils import read_hdf5
from parallel_wavegan.utils import write_hdf5
from parallel_wavegan.utils import read_hdf5, write_hdf5


def main():
Expand Down
7 changes: 2 additions & 5 deletions parallel_wavegan/bin/compute_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@

import numpy as np
import yaml

from sklearn.preprocessing import StandardScaler
from tqdm import tqdm

from parallel_wavegan.datasets import MelDataset
from parallel_wavegan.datasets import MelSCPDataset
from parallel_wavegan.utils import read_hdf5
from parallel_wavegan.utils import write_hdf5
from parallel_wavegan.datasets import MelDataset, MelSCPDataset
from parallel_wavegan.utils import read_hdf5, write_hdf5


def main():
Expand Down
14 changes: 7 additions & 7 deletions parallel_wavegan/bin/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import soundfile as sf
import torch
import yaml

from tqdm import tqdm

from parallel_wavegan.datasets import AudioDataset
from parallel_wavegan.datasets import AudioSCPDataset
from parallel_wavegan.datasets import MelDataset
from parallel_wavegan.datasets import MelSCPDataset
from parallel_wavegan.utils import load_model
from parallel_wavegan.utils import read_hdf5
from parallel_wavegan.datasets import (
AudioDataset,
AudioSCPDataset,
MelDataset,
MelSCPDataset,
)
from parallel_wavegan.utils import load_model, read_hdf5


def main():
Expand Down
14 changes: 7 additions & 7 deletions parallel_wavegan/bin/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

import numpy as np
import yaml

from sklearn.preprocessing import StandardScaler
from tqdm import tqdm

from parallel_wavegan.datasets import AudioMelDataset
from parallel_wavegan.datasets import AudioMelSCPDataset
from parallel_wavegan.datasets import MelDataset
from parallel_wavegan.datasets import MelSCPDataset
from parallel_wavegan.utils import read_hdf5
from parallel_wavegan.utils import write_hdf5
from parallel_wavegan.datasets import (
AudioMelDataset,
AudioMelSCPDataset,
MelDataset,
MelSCPDataset,
)
from parallel_wavegan.utils import read_hdf5, write_hdf5


def main():
Expand Down
4 changes: 1 addition & 3 deletions parallel_wavegan/bin/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
import numpy as np
import soundfile as sf
import yaml

from scipy.interpolate import interp1d
from tqdm import tqdm

from parallel_wavegan.datasets import AudioDataset
from parallel_wavegan.datasets import AudioSCPDataset
from parallel_wavegan.datasets import AudioDataset, AudioSCPDataset
from parallel_wavegan.utils import write_hdf5


Expand Down
25 changes: 13 additions & 12 deletions parallel_wavegan/bin/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,34 @@
import logging
import os
import sys

from collections import defaultdict

import matplotlib
import numpy as np
import soundfile as sf
import torch
import yaml

from tensorboardX import SummaryWriter
from torch.utils.data import DataLoader
from tqdm import tqdm

import parallel_wavegan
import parallel_wavegan.models
import parallel_wavegan.optimizers

from parallel_wavegan.datasets import AudioDataset
from parallel_wavegan.datasets import AudioMelDataset
from parallel_wavegan.datasets import AudioMelSCPDataset
from parallel_wavegan.datasets import AudioSCPDataset
from parallel_wavegan.datasets import (
AudioDataset,
AudioMelDataset,
AudioMelSCPDataset,
AudioSCPDataset,
)
from parallel_wavegan.layers import PQMF
from parallel_wavegan.losses import DiscriminatorAdversarialLoss
from parallel_wavegan.losses import FeatureMatchLoss
from parallel_wavegan.losses import GeneratorAdversarialLoss
from parallel_wavegan.losses import MelSpectrogramLoss
from parallel_wavegan.losses import MultiResolutionSTFTLoss
from parallel_wavegan.losses import (
DiscriminatorAdversarialLoss,
FeatureMatchLoss,
GeneratorAdversarialLoss,
MelSpectrogramLoss,
MultiResolutionSTFTLoss,
)
from parallel_wavegan.utils import read_hdf5

# set to avoid matplotlib error in CLI environment
Expand Down
5 changes: 1 addition & 4 deletions parallel_wavegan/datasets/audio_mel_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@

import logging
import os

from multiprocessing import Manager

import numpy as np

from torch.utils.data import Dataset

from parallel_wavegan.utils import find_files
from parallel_wavegan.utils import read_hdf5
from parallel_wavegan.utils import find_files, read_hdf5


class AudioMelDataset(Dataset):
Expand Down
5 changes: 1 addition & 4 deletions parallel_wavegan/datasets/scp_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
"""Dataset modules based on kaldi-style scp files."""

import logging

from multiprocessing import Manager

import kaldiio
import numpy as np

from torch.utils.data import Dataset

from parallel_wavegan.utils import HDF5ScpLoader
from parallel_wavegan.utils import NpyScpLoader
from parallel_wavegan.utils import HDF5ScpLoader, NpyScpLoader


def _get_feats_scp_loader(feats_scp):
Expand Down
4 changes: 1 addition & 3 deletions parallel_wavegan/distributed/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import os
import subprocess
import sys

from argparse import ArgumentParser
from argparse import REMAINDER
from argparse import REMAINDER, ArgumentParser


def parse_args():
Expand Down
1 change: 0 additions & 1 deletion parallel_wavegan/functions/vector_quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""

import torch

from torch.autograd import Function


Expand Down
1 change: 0 additions & 1 deletion parallel_wavegan/layers/pqmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np
import torch
import torch.nn.functional as F

from scipy.signal import kaiser


Expand Down
3 changes: 1 addition & 2 deletions parallel_wavegan/layers/vector_quantize_codebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

import torch

from parallel_wavegan.functions import vector_quantize
from parallel_wavegan.functions import vector_quantize_straight_through
from parallel_wavegan.functions import vector_quantize, vector_quantize_straight_through


class VQCodebook(torch.nn.Module):
Expand Down
1 change: 0 additions & 1 deletion parallel_wavegan/losses/mel_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import torch
import torch.nn.functional as F


is_pytorch_17plus = LooseVersion(torch.__version__) >= LooseVersion("1.7")


Expand Down
4 changes: 2 additions & 2 deletions parallel_wavegan/losses/stft_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

"""STFT-based Loss modules."""

from distutils.version import LooseVersion

import torch
import torch.nn.functional as F

from distutils.version import LooseVersion

is_pytorch_17plus = LooseVersion(torch.__version__) >= LooseVersion("1.7")


Expand Down
Loading

0 comments on commit 817befd

Please sign in to comment.