Skip to main content

tokensynth

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokensynth-0.0.4.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokensynth-0.0.4-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file tokensynth-0.0.4.tar.gz.

File metadata

  • Download URL: tokensynth-0.0.4.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for tokensynth-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ec3d382fca796bf79e43ef278a124ed9888aa0d884a6cd84fac85e9734dbcc95
MD5 6c30255a05de14ef25b8f2df7ac3497c
BLAKE2b-256 8e7cff28a9e371ba0c1bfcff83bd566f1892abb9f8d97c27615852c42b7cee50

See more details on using hashes here.

File details

Details for the file tokensynth-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: tokensynth-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for tokensynth-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 991d893e8e995829a752b034c48dba17fe07c152fac9cb40665c1e63bf48fabd
MD5 33920dd12bdd3ca9d75df5d489ea1e03
BLAKE2b-256 906d558b130d464891b38690184970ac2990140eb9ff37b50ee4925b61f687ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page