Skip to content

Commit

Permalink
Merge pull request #11 from marl/bz2model
Browse files Browse the repository at this point in the history
Fix bug where model not loaded in python, update readme, bump to v0.0.4
Fixes #10
  • Loading branch information
justinsalamon committed May 4, 2018
2 parents a9eaf32 + e2b04ee commit a8c4155
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Further details are provided in the following paper:
We kindly request that academic publications making use of CREPE cite the aforementioned paper.


## Using CREPE
## Installing CREPE

CREPE is hosted on PyPI. To install, run the following command in your Python environment:

Expand All @@ -23,6 +23,15 @@ $ pip install --upgrade tensorflow # if you don't already have tensorflow >= 1.
$ pip install crepe
```

To install the latest version from source clone the repository and from the top-level `crepe` folder call:

```bash
$ python setup.py install
```

## Using CREPE
### Using CREPE from the command line

This package includes a command line utility `crepe` and a pre-trained version of the CREPE model for easy use. To estimate the pitch of `audio_file.wav`, run:

```bash
Expand Down Expand Up @@ -65,6 +74,16 @@ For more information on the usage, please refer to the help message:
$ python crepe.py --help
```

### Using CREPE inside Python
CREPE can be imported as module to be used directly in Python. Here's a minimal example:
```python
import crepe
from scipy.io import wavfile

sr, audio = wavfile.read('/path/to/audiofile.wav')
time, frequency, confidence, activation = crepe.predict(audio, sr, viterbi=True)
```

## Argmax-local Weighted Averaging

This release of CREPE uses the following weighted averaging formula, which is slightly different from the paper. This only focuses on the neighborhood around the maximum activation, which is shown to further improve the pitch accuracy:
Expand Down
4 changes: 4 additions & 0 deletions crepe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def get_activation(audio, sr):
activation : np.ndarray [shape=(T, 360)]
The raw activation matrix
"""
global model
if model is None:
build_and_load_model()

if len(audio.shape) == 2:
audio = audio.mean(1) # make mono
audio = audio.astype(np.float32)
Expand Down
2 changes: 1 addition & 1 deletion crepe/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.0.3'
version = '0.0.4'

0 comments on commit a8c4155

Please sign in to comment.