Skip to content

Commit

Permalink
Merge pull request #73 from sp-nitech/release
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
takenori-y committed May 3, 2024
2 parents 7b86248 + ff928fa commit b318818
Show file tree
Hide file tree
Showing 101 changed files with 324 additions and 302 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
- python: 3.8
torch: 1.11.0
torchaudio: 0.11.0
- python: 3.11
torch: 2.2.2
torchaudio: 2.2.2
- python: 3.12
torch: 2.3.0
torchaudio: 2.3.0

steps:
- name: Clone
Expand Down
43 changes: 21 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,60 @@ TORCHAUDIO_VERSION := 0.11.0
PLATFORM := cu113

venv:
test -d venv || python$(PYTHON_VERSION) -m venv venv; \
. ./venv/bin/activate; python -m pip install pip --upgrade
. ./venv/bin/activate; python -m pip install torch==$(TORCH_VERSION)+$(PLATFORM) torchaudio==$(TORCHAUDIO_VERSION)+$(PLATFORM) \
-f https://download.pytorch.org/whl/$(PLATFORM)/torch_stable.html; \
. ./venv/bin/activate; python -m pip install -e .[dev]
. ./venv/bin/activate; python -m pip install icc-rt
test -d venv || python$(PYTHON_VERSION) -m venv venv
. ./venv/bin/activate && python -m pip install pip --upgrade
. ./venv/bin/activate && python -m pip install torch==$(TORCH_VERSION)+$(PLATFORM) torchaudio==$(TORCHAUDIO_VERSION)+$(PLATFORM) \
-f https://download.pytorch.org/whl/$(PLATFORM)/torch_stable.html
. ./venv/bin/activate && python -m pip install -e .[dev]
. ./venv/bin/activate && python -m pip install icc-rt

dist:
. ./venv/bin/activate; python -m build
. ./venv/bin/activate; python -m twine check dist/*
. ./venv/bin/activate && python -m build
. ./venv/bin/activate && python -m twine check dist/*

dist-clean:
rm -rf dist

doc:
. ./venv/bin/activate; cd docs; make html
. ./venv/bin/activate && cd docs && make html

doc-clean:
@if [ -f ./venv/bin/activate ]; then \
. ./venv/bin/activate; cd docs; make clean; \
. ./venv/bin/activate && cd docs && make clean; \
fi

check: tool
. ./venv/bin/activate; python -m ruff check $(PROJECT) tests
. ./venv/bin/activate; python -m ruff format --check $(PROJECT) tests
. ./venv/bin/activate; python -m isort --check $(PROJECT) tests
. ./venv/bin/activate && python -m ruff check $(PROJECT) tests
. ./venv/bin/activate && python -m ruff format --check $(PROJECT) tests
. ./venv/bin/activate && python -m isort --check $(PROJECT) tests
./tools/taplo/taplo fmt --check pyproject.toml
./tools/yamlfmt/yamlfmt --lint *.yml .github/workflows/*.yml

format: tool
. ./venv/bin/activate; python -m ruff check --fix $(PROJECT) tests
. ./venv/bin/activate; python -m ruff format $(PROJECT) tests
. ./venv/bin/activate; python -m isort $(PROJECT) tests
. ./venv/bin/activate && python -m ruff check --fix $(PROJECT) tests
. ./venv/bin/activate && python -m ruff format $(PROJECT) tests
. ./venv/bin/activate && python -m isort $(PROJECT) tests
./tools/taplo/taplo fmt pyproject.toml
./tools/yamlfmt/yamlfmt *.yml .github/workflows/*.yml

test: tool
[ -n "$(MODULE)" ] && module=tests/test_$(MODULE).py || module=; \
. ./venv/bin/activate; export PATH=tools/SPTK/bin:$$PATH; \
python -m pytest -s --cov=./ --cov-report=xml $$module
. ./venv/bin/activate && export PATH=tools/SPTK/bin:$$PATH && python -m pytest $$module

test-clean:
rm -rf tests/__pycache__
rm -rf *.wav

tool:
cd tools; make
cd tools && make

tool-clean:
cd tools; make clean
cd tools && make clean

update: tool
. ./venv/bin/activate; python -m pip install --upgrade pip
. ./venv/bin/activate && python -m pip install --upgrade pip
@for package in $$(./tools/taplo/taplo get -f pyproject.toml project.optional-dependencies.dev); do \
. ./venv/bin/activate; python -m pip install --upgrade $$package; \
. ./venv/bin/activate && python -m pip install --upgrade $$package; \
done

clean: dist-clean doc-clean test-clean tool-clean
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ diffsptk
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.

[![Latest Manual](https://img.shields.io/badge/docs-latest-blue.svg)](https://sp-nitech.github.io/diffsptk/latest/)
[![Stable Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/2.0.0/)
[![Stable Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/2.0.1/)
[![Downloads](https://static.pepy.tech/badge/diffsptk)](https://pepy.tech/project/diffsptk)
[![Python Version](https://img.shields.io/pypi/pyversions/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
[![PyTorch Version](https://img.shields.io/badge/pytorch-1.11.0%20%7C%202.2.2-orange.svg)](https://pypi.python.org/pypi/diffsptk)
[![PyTorch Version](https://img.shields.io/badge/pytorch-1.11.0%20%7C%202.3.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
[![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
[![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
[![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
Expand Down
8 changes: 5 additions & 3 deletions diffsptk/misc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
# ------------------------------------------------------------------------ #

from importlib import import_module
import math

import numpy as np
import soundfile as sf
import torch
from torch import nn
import torch.nn.functional as F
import torchaudio

UNVOICED_SYMBOL = 0
TWO_PI = 6.283185307179586
TWO_PI = math.tau


class Lambda(torch.nn.Module):
class Lambda(nn.Module):
def __init__(self, func, **opt):
super(Lambda, self).__init__()
super().__init__()
self.func = func
self.opt = opt

Expand Down
14 changes: 7 additions & 7 deletions diffsptk/modules/acorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ------------------------------------------------------------------------ #

import torch
import torch.nn as nn
from torch import nn

from ..misc.utils import check_size

Expand All @@ -41,7 +41,7 @@ class Autocorrelation(nn.Module):
"""

def __init__(self, frame_length, acr_order, norm=False, estimator="none"):
super(Autocorrelation, self).__init__()
super().__init__()

assert 0 <= acr_order < frame_length

Expand Down Expand Up @@ -93,17 +93,17 @@ def _forward(x, acr_order, norm, const):
@staticmethod
def _func(x, acr_order, norm=False, estimator="none"):
const = Autocorrelation._precompute(
x.size(-1), acr_order, estimator, dtype=x.dtype, device=x.device
x.size(-1), acr_order, estimator, device=x.device
)
return Autocorrelation._forward(x, acr_order, norm, const)

@staticmethod
def _precompute(frame_length, acr_order, estimator, dtype=None, device=None):
if estimator == 0 or estimator == 1 or estimator == "none":
def _precompute(frame_length, acr_order, estimator, device=None):
if estimator in (0, 1, "none"):
return 1
elif estimator == 2 or estimator == "biased":
elif estimator in (2, "biased"):
return 1 / frame_length
elif estimator == 3 or estimator == "unbiased":
elif estimator in (3, "unbiased"):
return torch.arange(
frame_length, frame_length - acr_order - 1, -1, device=device
).reciprocal()
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/alaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import math

import torch
import torch.nn as nn
from torch import nn


class ALawCompression(nn.Module):
Expand All @@ -35,7 +35,7 @@ class ALawCompression(nn.Module):
"""

def __init__(self, abs_max=1, a=87.6):
super(ALawCompression, self).__init__()
super().__init__()

assert 0 < abs_max
assert 1 <= a
Expand Down
14 changes: 7 additions & 7 deletions diffsptk/modules/ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import numpy as np
import torch
import torch.nn as nn
from torch import nn
import torch.nn.functional as F

from ..misc.utils import UNVOICED_SYMBOL
Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(
out_format="a",
**kwargs,
):
super(Aperiodicity, self).__init__()
super().__init__()

assert 1 <= frame_period
assert 1 <= sample_rate
Expand All @@ -79,13 +79,13 @@ def __init__(
else:
raise ValueError(f"algorithm {algorithm} is not supported.")

if out_format == 0 or out_format == "a":
if out_format in (0, "a"):
self.convert = lambda x: x
elif out_format == 1 or out_format == "p":
elif out_format in (1, "p"):
self.convert = lambda x: 1 - x
elif out_format == 2 or out_format == "a/p":
elif out_format in (2, "a/p"):
self.convert = lambda x: x / (1 - x)
elif out_format == 3 or out_format == "p/a":
elif out_format in (3, "p/a"):
self.convert = lambda x: (1 - x) / x
else:
raise ValueError(f"out_format {out_format} is not supported.")
Expand Down Expand Up @@ -149,7 +149,7 @@ def __init__(
window_length_ms=30,
eps=1e-5,
):
super(AperiodicityExtractionByTandem, self).__init__()
super().__init__()

assert fft_length % 2 == 0
assert 0 <= lower_bound < upper_bound <= 1
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/b2mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ------------------------------------------------------------------------ #

import torch
import torch.nn as nn
from torch import nn
import torch.nn.functional as F

from ..misc.utils import check_size
Expand All @@ -37,7 +37,7 @@ class MLSADigitalFilterCoefficientsToMelCepstrum(nn.Module):
"""

def __init__(self, cep_order, alpha=0):
super(MLSADigitalFilterCoefficientsToMelCepstrum, self).__init__()
super().__init__()

assert 0 <= cep_order
assert abs(alpha) < 1
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/c2acr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ------------------------------------------------------------------------ #

import torch
import torch.nn as nn
from torch import nn

from ..misc.utils import check_size

Expand All @@ -38,7 +38,7 @@ class CepstrumToAutocorrelation(nn.Module):
"""

def __init__(self, cep_order, acr_order, n_fft=512):
super(CepstrumToAutocorrelation, self).__init__()
super().__init__()

assert 0 <= cep_order
assert 0 <= acr_order
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/c2mpir.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ------------------------------------------------------------------------ #

import torch
import torch.nn as nn
from torch import nn

from ..misc.utils import cexp
from ..misc.utils import check_size
Expand All @@ -39,7 +39,7 @@ class CepstrumToMinimumPhaseImpulseResponse(nn.Module):
"""

def __init__(self, cep_order, ir_length, n_fft=512):
super(CepstrumToMinimumPhaseImpulseResponse, self).__init__()
super().__init__()

assert 0 <= cep_order
assert 1 <= ir_length
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/c2ndps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ------------------------------------------------------------------------ #

import torch
import torch.nn as nn
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
Expand All @@ -36,7 +36,7 @@ class CepstrumToNegativeDerivativeOfPhaseSpectrum(nn.Module):
"""

def __init__(self, cep_order, fft_length):
super(CepstrumToNegativeDerivativeOfPhaseSpectrum, self).__init__()
super().__init__()

assert 0 <= cep_order
assert max(1, cep_order) <= fft_length // 2
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/cdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import math

import torch
import torch.nn as nn
from torch import nn


class CepstralDistance(nn.Module):
Expand All @@ -38,7 +38,7 @@ class CepstralDistance(nn.Module):
"""

def __init__(self, full=False, reduction="mean", eps=1e-8):
super(CepstralDistance, self).__init__()
super().__init__()

assert reduction in ("none", "mean", "batchmean", "sum")
assert 0 <= eps
Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/cqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import numpy as np
import torch
import torch.nn as nn
from torch import nn
import torchaudio

from ..misc.utils import Lambda
Expand Down Expand Up @@ -101,7 +101,7 @@ def __init__(
scale=True,
**kwargs,
):
super(ConstantQTransform, self).__init__()
super().__init__()

import librosa

Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/dct.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ------------------------------------------------------------------------ #

import torch
import torch.nn as nn
from torch import nn

from ..misc.utils import check_size
from ..misc.utils import to
Expand All @@ -33,7 +33,7 @@ class DiscreteCosineTransform(nn.Module):
"""

def __init__(self, dct_length):
super(DiscreteCosineTransform, self).__init__()
super().__init__()

assert 1 <= dct_length

Expand Down
4 changes: 2 additions & 2 deletions diffsptk/modules/decimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# ------------------------------------------------------------------------ #

import torch
import torch.nn as nn
from torch import nn


class Decimation(nn.Module):
Expand All @@ -36,7 +36,7 @@ class Decimation(nn.Module):
"""

def __init__(self, period, start=0, dim=-1):
super(Decimation, self).__init__()
super().__init__()

assert 1 <= period
assert 0 <= start
Expand Down

0 comments on commit b318818

Please sign in to comment.