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

0.1.0 #1

Merged
merged 7 commits into from
Aug 10, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mp3 filter=lfs diff=lfs merge=lfs -text
53 changes: 53 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches:
- main
tags:
- "releases/**"
pull_request:
branches:
- "*"

jobs:
python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pipenv"

- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
shell: bash

- name: Install Pipfile packages
run: pipenv sync --python 3.10 --dev
shell: bash

- name: Reinstall CPU version of PyTorch
run: |
pipenv run pip uninstall --yes torch torchaudio
pipenv run pip install torch~=2.0 torchaudio~=2.0 --index-url https://download.pytorch.org/whl/cpu

- name: Formatting
run: pipenv run black --diff .

- name: Sort imports
run: pipenv run isort --check --diff .

- name: Lint
run: pipenv run flake8

- name: Type check
run: pipenv run mypy --strict --junit-xml=mypy-results.xml music_interpolation/

- name: Test
run: pipenv run pytest --junit-xml=pytest-results.xml
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,9 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# JUnit
*-results.xml

# OS files
.DS_Store
14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// -*- jsonc -*-
{
"recommendations": [
"esbenp.prettier-vscode",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-renderers"
]
}
27 changes: 27 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// -*- jsonc -*-
{
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,

"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},

"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.tabSize": 4
},
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingTypeStubs": "none",
"reportUnknownMemberType": "none"
},
"python.analysis.typeCheckingMode": "strict",

"search.exclude": {
"**/build": true,
"**/*.lock": true
}
}
26 changes: 26 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
audiocraft = "*"
librosa = "*"
music_interpolation = { editable = true, path = "." }
numpy = "*"
soundfile = "*"
torch = "~=2.0"
torchaudio = "~=2.0"
transformers = "~=4.0"

[dev-packages]
argparse = "==1.4.0"
black = "==23.7.0"
flake8 = "==6.1.0"
isort = "==5.12.0"
mypy = "==1.5.0"
pytest = "==7.4.0"
ipykernel = "*"

[requires]
python_version = "3.10"
3,751 changes: 3,751 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# music-interpolation
Mix between music tracks using machine learning

> Mix between music tracks using machine learning

## Introduction

This repository is a sandbox to experiment with machine learning techniques for smoothly transitioning between music tracks.

## Development

1. `git clone https://github.com/jhurliman/music-interpolation.git`
2. `cd music-interpolation`
3. Install pipenv if you have not already: `pip install pipenv`
4. Install dependencies: `pipenv sync --python 3.10 --dev`
5. Run tests: `pipenv run pytest`

## Usage

```python
import librosa
from IPython.display import Audio
from music_interpolation import EncodecInterpolation

# Instantiate the interpolation class, fetching and loading the pre-trained
# Encodec model
interp = EncodecInterpolation()

# Load two audio tracks, resampling to the sampling rate of the Encodec model
# (defaults to 48kHz)
audio_a, _ = librosa.load('audio_a.mp3', sr=interp.sampling_rate, mono=False)
audio_b, _ = librosa.load('audio_b.mp3', sr=interp.sampling_rate, mono=False)

# Transition between two audio tracks using linear interpolation between
# embedding vectors generated by a pre-trained Encodec model
audio_c = interp.interpolate(audio_a, audio_b)
Audio(data=audio_c, rate=interp.sampling_rate)
```

## Contributing

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
1 change: 1 addition & 0 deletions music_interpolation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
Loading