Git Product home page Git Product logo

acids_transforms's Introduction

acids_transforms

Description

A bunch of scriptable audio transforms based on the torchaudio backend, embeddable in Python/C++ with torchscript for real-time purposes. Available transforms:

transform name invertible scriptable
raw
MuLaw  yes  yes
Window  yes  yes
Mono  yes  yes
Stereo yes yes
MidSide yes yes
OneHot  yes yes
spectral
STFT / RealtimeSTFT  yes  yes
DGT / RealtimeDGT  yes  yes
MFCC no  yes
representations
Real / Imaginary  yes  yes
Magnitude / Phase  yes  yes
Instantaneous Frequency  yes  yes
normalization
Normalize  yes  yes
miscalleneous
OverlapAdd yes yes
Squeeze yes  yes
Unsqueeze yes yes
Transpose  yes  yes

Installation

git clone https://github.com/domkirke/acids_transforms.git
cd acids_transforms
pip install -r requirements.txt
python3 setup.py install

Usage

Transforms in acids_transforms are nn.Module with a forward function, and an optional invert functions if the transform is invertible. Besides, some of them can also be scripted to TorchScript. They can also be combined using the __add__ operator, allowing to chain several transforms :

import torch, torchaudio
from acids_transforms.transforms import *

x, sr = torchaudio.load("test/source_files/additive.wav")

transform = Mono() \
    + DGT(sr=sr, n_fft = 1024, hop_length = 256, inversion_mode="pghi") \
    + Magnitude(mel=True, norm="unipolar", contrast="log1p")

print("invertible : ", transform.invertible)
print("scriptable : ", transform.scriptable)
if transform.scriptable:
    transform = torch.jit.script(transform)

# scale normalization
transform.scale_data(x)
# test the transform!
x_transformed = transform(x)
x_inverted = transform.invert(x_transformed)
torchaudio.save("additive_pghi.wav", x_inverted, sample_rate=sr)
Warnings
  • on real-time PGHI : while pghi is usable with RealtimeDGT, there are some known issues with a stream use. This will come very soon!
  • this library is still experimental and changes very often. a first "sure" release will come soon!

acids_transforms's People

Contributors

domkirke avatar nabsara avatar

Stargazers

jdickman avatar oak avatar Giovanni avatar  avatar Jack Armitage avatar

Watchers

 avatar  avatar

Forkers

nabsara dgenova

acids_transforms's Issues

spectral_repr.py class _Representation `mode` cannot be set to `None`

https://github.com/domkirke/acids_transforms/blob/master/acids_transforms/transforms/spectral_repr.py#L23

issue description:

class _Representation(AudioTransform):

    def __init__(self, sr: int = 44100, mode: Union[str, None] = "unipolar", keep_nyquist: bool = True):
        super().__init__(sr=sr)
        if mode is not None:
            self.norm = Normalize(mode)
        else:
            self.norm = Dummy()
        self.keep_nyquist = keep_nyquist

Bug with the typing Union[str, None] Cannot instantiate class _Representation with mode=None instead it is always set to the default value "unipolar"

solution:

change the default value to None instead :
mode: Union[str, None] = None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.