-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from ktonal/develop
v0.2.3
- Loading branch information
Showing
12 changed files
with
216 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = '0.2.2' | ||
__version__ = '0.2.3' | ||
|
||
from . import audios | ||
from . import connectors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
from inspect import getsource | ||
import re | ||
import torch | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import soundfile | ||
|
||
|
||
from mimikit.models.freqnet import demo as fnet | ||
from mimikit.models.sample_rnn import demo as srnn | ||
from mimikit.models.s2s_lstm import demo as s2s | ||
from mimikit.models.wavenet import demo as wnet | ||
|
||
|
||
@pytest.fixture | ||
def example_root(tmp_path): | ||
root = (tmp_path / "models") | ||
root.mkdir() | ||
data = (root / "data") | ||
data.mkdir() | ||
# we need at least 8 sec of audio... | ||
audio = np.random.rand(22050 * 10) - .5 | ||
soundfile.write(str(data / "example.wav"), audio, 22050, 'PCM_24', format="WAV") | ||
return str(root) | ||
|
||
|
||
@pytest.mark.parametrize("model", [fnet, srnn, s2s, wnet]) | ||
def test_models(example_root, monkeypatch, model): | ||
if torch.cuda.is_available(): | ||
monkeypatch.setattr(torch.cuda, "is_available", lambda: False) | ||
src = getsource(model) | ||
|
||
src = re.sub(r"db_path = '.*.h5'\n", f"db_path = '{example_root}/data.h5'\n", src) | ||
src = re.sub(r"sources =.*\n", f"sources = ['{example_root}']\n", src) | ||
src = re.sub(r"every_n_epochs =.*\n", "every_n_epochs=1\n", src) | ||
src = re.sub(r"n_steps =.*\n", "n_steps = 10\n", src) | ||
src = re.sub(r"limit_train_batches=.*\n", "", src) | ||
src = re.sub(r"max_epochs=.*,\n", "max_epochs=1,limit_train_batches=10,\n", src) | ||
src = re.sub(r"root_dir=.*\n", f"root_dir ='{example_root}',\n", src) | ||
exec(src) | ||
locals()["demo"]() | ||
plt.close('all') | ||
# we only need that the demo runs without raising exceptions | ||
assert True | ||
return |