Spaces:
Sleeping
Sleeping
hugo flores garcia
commited on
Commit
•
ee4b45b
1
Parent(s):
41b9d24
quickstart
Browse files
README.md
CHANGED
@@ -36,6 +36,52 @@ pip install -e ./vampnet
|
|
36 |
|
37 |
# Usage
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
## Launching the Gradio Interface
|
|
|
36 |
|
37 |
# Usage
|
38 |
|
39 |
+
quick start!
|
40 |
+
```python
|
41 |
+
import random
|
42 |
+
import vampnet
|
43 |
+
import audiotools as at
|
44 |
+
|
45 |
+
# load the default vampnet model
|
46 |
+
interface = vampnet.interface.Interface.default()
|
47 |
+
|
48 |
+
# list available finetuned models
|
49 |
+
finetuned_model_choices = interface.available_models()
|
50 |
+
print(f"available finetuned models: {finetuned_model_choices}")
|
51 |
+
|
52 |
+
# pick a random finetuned model
|
53 |
+
model_choice = random.choice(finetuned_model_choices)
|
54 |
+
print(f"choosing model: {model_choice}")
|
55 |
+
|
56 |
+
# load a finetuned model
|
57 |
+
interface.load_finetuned(model_choice)
|
58 |
+
|
59 |
+
# load an example audio file
|
60 |
+
signal = at.AudioSignal("assets/example.wav")
|
61 |
+
|
62 |
+
# get the tokens for the audio
|
63 |
+
codes = interface.encode(signal)
|
64 |
+
|
65 |
+
# build a mask for the audio
|
66 |
+
mask = interface.build_mask(
|
67 |
+
codes, signal,
|
68 |
+
periodic_prompt=7,
|
69 |
+
upper_codebook_mask=3,
|
70 |
+
)
|
71 |
+
|
72 |
+
# generate the output tokens
|
73 |
+
output_tokens = interface.vamp(
|
74 |
+
codes, mask, return_mask=False,
|
75 |
+
temperature=1.0,
|
76 |
+
typical_filtering=True,
|
77 |
+
)
|
78 |
+
|
79 |
+
# convert them to a signal
|
80 |
+
output_signal = interface.decode(output_tokens)
|
81 |
+
|
82 |
+
# save the output signal
|
83 |
+
output_signal.write("scratch/output.wav")
|
84 |
+
```
|
85 |
|
86 |
|
87 |
## Launching the Gradio Interface
|