TokenSynth: A Token-based Neural Synthesizer for Instrument Cloning and Text-to-Instrument
This is the official implementation of "TokenSynth: A Token-based Neural Synthesizer for Instrument Cloning and Text-to-Instrument", accepted to ICASSP 2025 (in press).
Installation
To install TokenSynth, simply run:
pip install tokensynth
Quickstart
from tokensynth import TokenSynth, CLAP, DACDecoder
import audiofile
import torch
# Set file paths
ref_audio = "media/reference_audio.wav"
midi = "media/input_midi.mid"
# Initialize models
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
synth = TokenSynth.from_pretrained(aug=True)
clap = CLAP(device=device)
decoder = DACDecoder(device=device)
with torch.no_grad():
# Extract timbre embeddings from audio and text
timbre_audio = clap.encode_audio(ref_audio)
timbre_text = clap.encode_text("warm smooth electronic bass")
timbre_audio_text = 0.5 * timbre_audio + 0.5 * timbre_text
# Generate audio tokens
tokens_audio = synth.synthesize(timbre_audio, midi, top_k=10)
tokens_text = synth.synthesize(timbre_text, midi, top_p=0.6, guidance_scale=1.6)
tokens_audio_text = synth.synthesize(timbre_audio_text, midi, top_p=0.6, guidance_scale=1.6)
# Decode tokens into audio waveforms
audio_audio = decoder.decode(tokens_audio)
audio_text = decoder.decode(tokens_text)
audio_audio_text = decoder.decode(tokens_audio_text)
# Save audio files
audiofile.write("media/output_audio.wav", audio_audio.cpu().numpy(), 16000)
audiofile.write("media/output_text.wav", audio_text.cpu().numpy(), 16000)
audiofile.write("media/output_audio_text.wav", audio_audio_text.cpu().numpy(), 16000)
You can also run python quickstart.py from the project root directory.
Citation
A formal citation (BibTeX) will be available once this work is published.
For now, please cite this repository as:
Kyungsu Kim, Junghyun Koo, Sungho Lee, Haesun Joung, Kyogu Lee.
TokenSynth: A Token-Based Neural Synthesizer for Instrument Cloning and Text-to-Instrument.
GitHub repository, 2024. Available at: https://github.com/kyungsukim42/tokensynth
Metadata
Release files for tokensynth 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tokensynth-0.0.4.tar.gz | 12.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tokensynth-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.2 kB
Release files / tokensynth-0.0.4.tar.gz
| Download URL | tokensynth-0.0.4.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec3d382fca796bf79e43ef278a124ed9888aa0d884a6cd84fac85e9734dbcc95
|
|
BLAKE2b-256 checksum How to use checksums |
8e7cff28a9e371ba0c1bfcff83bd566f1892abb9f8d97c27615852c42b7cee50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|
Release files / tokensynth-0.0.4-py3-none-any.whl
| Download URL | tokensynth-0.0.4-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
991d893e8e995829a752b034c48dba17fe07c152fac9cb40665c1e63bf48fabd
|
|
BLAKE2b-256 checksum How to use checksums |
906d558b130d464891b38690184970ac2990140eb9ff37b50ee4925b61f687ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|