File size: 1,766 Bytes
386a259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# AudioEditingCode Colab Demo

This notebook demonstrates how to use the `AudioEditingCode` repository in Google Colab.

## 1. Clone the repository



```bash
!git clone https://github.com/HilaManor/AudioEditingCode.git
%cd AudioEditingCode
```

## 2. Install dependencies



```bash
!pip install -r requirements.txt
```

## 3. Demo Usage

Here you can add examples of how to use the code. You might need to download some audio files for demonstration.



### Download example audio

```bash
!wget https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3 -O input_audio.mp3
```

### Text-Based Editing Example

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.

```python
import os

# Replace with your actual Hugging Face token
os.environ["HF_TOKEN"] = "<YOUR_HF_TOKEN>"

!python code/main_run.py \
    --cfg_tar 1.5 \
    --cfg_src 0.5 \
    --init_aud input_audio.mp3 \
    --target_prompt "a dog barking" \
    --tstart 100 \
    --model_id audioldm \
    --results_path results_text_based
```



### Unsupervised Editing Example

First, extract the principal components:

```bash
!python code/main_pc_extract_inv.py \
    --init_aud input_audio.mp3 \
    --model_id audioldm \
    --results_path results_unsupervised_extract \
    --drift_start 0 \
    --drift_end 200 \
    --n_evs 5
```

Then, apply the principal components:

```bash
!python code/main_pc_apply_drift.py \
    --extraction_path results_unsupervised_extract/input_audio_audioldm_inversion_data.pt \
    --drift_start 0 \
    --drift_end 200 \
    --amount 1.0 \
    --evs 0
```