Upload AudioEditingCode_Demo.ipynb
Browse files- AudioEditingCode_Demo.ipynb +81 -0
AudioEditingCode_Demo.ipynb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AudioEditingCode Colab Demo
|
| 2 |
+
|
| 3 |
+
This notebook demonstrates how to use the `AudioEditingCode` repository in Google Colab.
|
| 4 |
+
|
| 5 |
+
## 1. Clone the repository
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
```bash
|
| 10 |
+
!git clone https://github.com/HilaManor/AudioEditingCode.git
|
| 11 |
+
%cd AudioEditingCode
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
## 2. Install dependencies
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
```bash
|
| 19 |
+
!pip install -r requirements.txt
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
## 3. Demo Usage
|
| 23 |
+
|
| 24 |
+
Here you can add examples of how to use the code. You might need to download some audio files for demonstration.
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
### Download example audio
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
!wget https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3 -O input_audio.mp3
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
### Text-Based Editing Example
|
| 35 |
+
|
| 36 |
+
This example uses `main_run.py` for text-based audio editing. You will need a Hugging Face token to use models like Stable Audio Open. Please visit [Hugging Face](https://huggingface.co/settings/tokens) to get your token and replace `<YOUR_HF_TOKEN>` below.
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
import os
|
| 40 |
+
|
| 41 |
+
# Replace with your actual Hugging Face token
|
| 42 |
+
os.environ["HF_TOKEN"] = "<YOUR_HF_TOKEN>"
|
| 43 |
+
|
| 44 |
+
!python code/main_run.py \
|
| 45 |
+
--cfg_tar 1.5 \
|
| 46 |
+
--cfg_src 0.5 \
|
| 47 |
+
--init_aud input_audio.mp3 \
|
| 48 |
+
--target_prompt "a dog barking" \
|
| 49 |
+
--tstart 100 \
|
| 50 |
+
--model_id audioldm \
|
| 51 |
+
--results_path results_text_based
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
### Unsupervised Editing Example
|
| 57 |
+
|
| 58 |
+
First, extract the principal components:
|
| 59 |
+
|
| 60 |
+
```bash
|
| 61 |
+
!python code/main_pc_extract_inv.py \
|
| 62 |
+
--init_aud input_audio.mp3 \
|
| 63 |
+
--model_id audioldm \
|
| 64 |
+
--results_path results_unsupervised_extract \
|
| 65 |
+
--drift_start 0 \
|
| 66 |
+
--drift_end 200 \
|
| 67 |
+
--n_evs 5
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
Then, apply the principal components:
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
!python code/main_pc_apply_drift.py \
|
| 74 |
+
--extraction_path results_unsupervised_extract/input_audio_audioldm_inversion_data.pt \
|
| 75 |
+
--drift_start 0 \
|
| 76 |
+
--drift_end 200 \
|
| 77 |
+
--amount 1.0 \
|
| 78 |
+
--evs 0
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
|