Code Monkey home page Code Monkey logo

audioeditingcode's Introduction

Python 3.8.10 NumPy Matplotlib Notebook torch torchaudio diffusers transformers CC BY-SA 4.0

Zero-Shot Unsupervised and Text-Based Audio Editing Using DDPM Inversion

This repository contains the official code release for Zero-Shot Unsupervised and Text-Based Audio Editing Using DDPM Inversion.

Table of Contents

Requirements

python -m pip install -r requirements.txt

Usage Example

Supported models are AudioLDM, TANGO, and AudioLDM2. For unsupervised editing, Stable Diffusion is also supported.

Text-Based Editing

CUDA_VISIBLE_DEVICES=<gpu_num> python main_run.py --cfg_tar <target_cfg_strength> --cfg_src <source_cfg_strength> --init_aud <input_audio_path> --target_prompt <description of the wanted edited signal> --tstart <edit from timestep> --model_id <model_name> --results_path <path to dump results>

You can supply a source prompt that describes the original audio by using --source_prompt.
Use python main_run.py --help for all options.

use --mode ddim to run DDIM inversion and editing (note that --tstart must be equal to num_diffusion_steps (by default set to 200)).

Unsupervised Editing

First extract the PCs for your wanted timesteps:

CUDA_VISIBLE_DEVICES=<gpu_num> python main_pc_extract_inv.py  --init_aud <input_audio_path> --model_id <model_name> --results_path <path to dump results> --drift_start <start extraction timestep> --drift_end  <end extraction timestep> --n_evs <amount of evs to extract>

You can supply a source prompt that describes the original audio by using --source_prompt.

Then apply the PCs:

CUDA_VISIBLE_DEVICES=<gpu_num> python main_pc_apply_drift.py --extraction_path <path to extracted .pt file> --drift_start <timestep to start apply> --drift_end <timestep to end apply> --amount <edit strength> --evs <ev nums to apply> 

By using --use_specific_ts_pc <timestep num> you choose a different $t$ from $t'$.
Add --combine_evs to apply all the given PCs together.
Changing --evals_pt to empty will try to get the eigenvalues from the extracted path, and will not work unless the applied timesteps were run in extraction.

Use python main_pc_extract_inv.py --help and python main_pc_apply_drift.py --help for all options.

To recreate the random vectors baseline, use --rand_v. Image samples can be recreated using images_pc_extract_inv.py and images_pc_apply_drift.py.

SDEdit

SDEdit can be run similarly with:

CUDA_VISIBLE_DEVICES=<gpu_num> python main_run_sdedit.py --cfg_tar <target_cfg_strength> --init_aud <input_audio_path> --target_prompt <description of the wanted edited signal> --tstart <edit from timestep> --model_id <model_name> --results_path <path to dump results>

Use python main_run_sdedit.py --help for all options.

Image samples can be recreated using images_run_sdedit.py.

Citation

If you use this code for your research, please cite our paper:

@article{manor2024zeroshot,
    title={Zero-Shot Unsupervised and Text-Based Audio Editing Using {DDPM} Inversion}, 
    author={Manor, Hila and Michaeli, Tomer},
    journal={arXiv preprint arXiv:2402.10009},
    year={2024},
}

Acknowledgements

Parts of this code are heavily based on DDPM Inversion and on Gaussian Denoising Posterior.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

audioeditingcode's People

Contributors

hilamanor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.