patrickvonplaten
commited on
Commit
•
83caed0
1
Parent(s):
716099a
Update README.md
Browse files
README.md
CHANGED
@@ -1,17 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
## FP32
|
2 |
|
3 |
```python
|
4 |
-
# !pip install
|
5 |
from diffusers import DiffusionPipeline
|
6 |
-
import
|
7 |
|
8 |
model_id = "harmonai/jmann-small-190k"
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
```
|
16 |
|
17 |
## FP16
|
@@ -19,16 +34,23 @@ scipy.io.wavfile.write("maestro_test.wav", pipe.unet.sample_rate, audios)
|
|
19 |
Faster at a small loss of quality
|
20 |
|
21 |
```python
|
22 |
-
# !pip install
|
23 |
from diffusers import DiffusionPipeline
|
24 |
-
import
|
25 |
import torch
|
26 |
|
27 |
model_id = "harmonai/jmann-small-190k"
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
```
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
tags:
|
4 |
+
- audio-generation
|
5 |
+
---
|
6 |
+
|
7 |
+
[Dance Diffusion](https://github.com/Harmonai-org/sample-generator) is now available in 🧨 Diffusers.
|
8 |
+
|
9 |
## FP32
|
10 |
|
11 |
```python
|
12 |
+
# !pip install diffusers[torch] accelerate scipy
|
13 |
from diffusers import DiffusionPipeline
|
14 |
+
from scipy.io.wavfile import write
|
15 |
|
16 |
model_id = "harmonai/jmann-small-190k"
|
17 |
+
pipe = DiffusionPipeline.from_pretrained(model_id)
|
18 |
+
pipe = pipe.to("cuda")
|
19 |
+
|
20 |
+
audios = pipe(audio_length_in_s=4.0).audios
|
21 |
+
|
22 |
+
# To save locally
|
23 |
+
for i, audio in enumerate(audios):
|
24 |
+
write(f"test_{i}.wav", pipe.unet.sample_rate, audio.transpose())
|
25 |
+
|
26 |
+
# To dislay in google colab
|
27 |
+
import IPython.display as ipd
|
28 |
+
for audio in audios:
|
29 |
+
display(ipd.Audio(audio, rate=pipe.unet.sample_rate))
|
30 |
```
|
31 |
|
32 |
## FP16
|
|
|
34 |
Faster at a small loss of quality
|
35 |
|
36 |
```python
|
37 |
+
# !pip install diffusers[torch] accelerate scipy
|
38 |
from diffusers import DiffusionPipeline
|
39 |
+
from scipy.io.wavfile import write
|
40 |
import torch
|
41 |
|
42 |
model_id = "harmonai/jmann-small-190k"
|
43 |
+
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
44 |
+
pipe = pipe.to("cuda")
|
45 |
+
|
46 |
+
audios = pipeline(audio_length_in_s=4.0).audios
|
47 |
+
|
48 |
+
# To save locally
|
49 |
+
for i, audio in enumerate(audios):
|
50 |
+
write(f"{i}.wav", pipe.unet.sample_rate, audio.transpose())
|
51 |
+
|
52 |
+
# To dislay in google colab
|
53 |
+
import IPython.display as ipd
|
54 |
+
for audio in audios:
|
55 |
+
display(ipd.Audio(audio, rate=pipe.unet.sample_rate))
|
56 |
```
|