Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #15

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
- id: ruff
name: ruff
language: system
entry: ruff
entry: ruff --fix
types: [python]
- id: mypy
name: mypy
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Denoisers is a denoising library for audio with a focus on simplicity and ease of use. There are two major types of architectures available. WaveUNet for waveform denoising and UNet for spectrogram denoising.

## Demo

Gradio demo [here](https://wrice-denoisers.hf.space)

## Usage/Examples
Expand All @@ -11,7 +12,6 @@ Gradio demo [here](https://wrice-denoisers.hf.space)
pip install denoisers
```


```python
import torch
import torchaudio
Expand Down
47 changes: 0 additions & 47 deletions denoisers/modeling/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,53 +195,6 @@ def forward(self, x: Tensor) -> Tensor:
return x


class ResidualDownBlock1D(nn.Module):
"""1d residual down block."""

def __init__(
self,
in_channels: int,
out_channels: int,
kernel_size: int = 3,
activation: str = "leaky_relu",
dropout: float = 0.0,
) -> None:
super().__init__()
self.conv_1 = DownsampleBlock1D(
in_channels=in_channels,
out_channels=in_channels,
kernel_size=kernel_size,
dropout=dropout,
activation=activation,
bias=False,
)

self.conv_2 = DownsampleBlock1D(
in_channels=in_channels,
out_channels=out_channels,
kernel_size=kernel_size,
dropout=dropout,
activation=activation,
bias=False,
)
self.res_conv = Downsample1D(
in_channels=in_channels,
out_channels=out_channels,
kernel_size=1,
stride=2,
use_conv=True,
bias=False,
)

def forward(self, x: Tensor) -> Tensor:
"""Forward pass."""
residual = x
x = self.conv_1(x)
x = self.conv_2(x)
x = x + self.res_conv(residual)
return x


class Activation(nn.Module):
"""Activation function."""

Expand Down
19 changes: 19 additions & 0 deletions denoisers/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Utility functions for tests."""
import torch
from torch import Tensor


def sine_wave(frequency: float, duration: float, sample_rate: int) -> Tensor:
"""Generate a sine wave.

Args:
frequency: Frequency of the sine wave.
duration: Duration of the sine wave in seconds.
sample_rate: Sample rate of the sine wave.

Returns:
A torch tensor containing the sine wave.
"""
return torch.sin(
2 * torch.pi * torch.arange(sample_rate * duration) * frequency / sample_rate
).unsqueeze(0)
Loading