Skip to content

Commit

Permalink
changed name to tcae
Browse files Browse the repository at this point in the history
  • Loading branch information
am1tyadav committed Aug 5, 2021
1 parent e68f369 commit 24f615d
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 24 deletions.
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,59 @@
# Timbre Conditioned (Variational) Auto Encoder

## Training
# Timbre Conditioned Auto Encoder

TBD

## Dataset
## Data Preparation

TBD

## Training

Use a `LocalConfig` instance to control architecture and training parameters

```python
from tcae import localconfig, train

conf = localconfig.LocalConfig()

conf.batch_size = 8

conf.simple_encoder = True
conf.simple_decoder = True

conf.mt_outputs["mag_env"]["enabled"] = True
conf.mt_outputs["h_freq_shifts"]["enabled"] = True
conf.mt_outputs["f0_shifts"]["enabled"] = True
conf.mt_outputs["h_mag_dist"]["enabled"] = True
conf.mt_outputs["h_phase_diff"]["enabled"] = False

conf.save_config()

train.train(conf)
```

## Sound Generator

Get audio prediction
Deploy a trained model as a `SoundGenerator`

```python
from sound_generator import SoundGenerator


sg = SoundGenerator()

sg.config_path = "/path/to/config"
sg.checkpoint_path = "/path/to/checkpoint.h5"

success, audio = sg.get_prediction({
"input_pitch": 40,
"pitch": 40,
"velocity": 100,
# A list of sg.conf.num_measures values between 0 and 1
"heuristic_measures": [0.1] * sg.conf.num_measures,
# A list of sg.conf.latent_dim values between 0 and 1
"latent_sample": [0.5] * sg.conf.latent_dim
"latent_sample": [0.5] * sg.conf.latent_dim,
# A list of words describing timbre qualities
"qualities": ["dark", "soft"]
})

```
Expand All @@ -40,6 +68,8 @@ Required keys in the input dictionary:

**latent_sample**: Values for z input to decoder

**qualities**: Timbre qualities from use speech, used to find initial heuristic configurations

**heuristic_measures**: List of values for following measures used in decoder in the sequence shown:
```python
['inharmonicity',
Expand Down
18 changes: 8 additions & 10 deletions SOUND_GENERATOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ Requires python >= 3.6

Clone repository

`git clone https://github.com/TheSoundOfAIOSR/rg_sound_generation.git`

Go to the right directory

`cd rg_sound_generation\timbre_conditioned_vae`
```
git clone https://github.com/TheSoundOfAIOSR/rg_sound_generation.git
cd rg_sound_generation
```

Create virtual environment

`python -m venv env`

Activate the environment

`env\Scripts\activate`
```
python -m venv env
env\Scripts\activate
```

Install required packages

Expand Down
2 changes: 1 addition & 1 deletion heuristic_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import numpy as np\n",
"from tcvae.compute_measures import heuristic_names\n",
"from tcae.compute_measures import heuristic_names\n",
"\n",
"plt.style.use(\"dark_background\")"
]
Expand Down
4 changes: 2 additions & 2 deletions predict.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"import numpy as np\n",
"import soundfile as sf\n",
"import tsms\n",
"from tcvae import dataset, localconfig, model, train\n",
"from tcvae.compute_measures import heuristic_names\n",
"from tcae import dataset, localconfig, model, train\n",
"from tcae.compute_measures import heuristic_names\n",
"from IPython.display import Audio"
]
},
Expand Down
2 changes: 1 addition & 1 deletion predict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from tcvae import predict, dataset, localconfig
from tcae import predict, dataset, localconfig
from matplotlib import pyplot as plt

conf = localconfig.LocalConfig()
Expand Down
4 changes: 2 additions & 2 deletions sound_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pprint import pprint
import warnings
from typing import Dict, Any
from tcvae import model, localconfig, train
from tcvae.compute_measures import heuristic_names
from tcae import model, localconfig, train
from tcae.compute_measures import heuristic_names


warnings.simplefilter("ignore")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion train_from_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tcvae import localconfig, train
from tcae import localconfig, train


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion train_on_colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
},
"source": [
"import json\n",
"from tcvae import localconfig, train\n",
"from tcae import localconfig, train\n",
"\n",
"data_handler_type = \"data_handler\"\n",
"conf = localconfig.LocalConfig(data_handler_type)"
Expand Down

0 comments on commit 24f615d

Please sign in to comment.