Hugo Flores Garcia commited on
Commit
e9fd215
1 Parent(s): e5dcb5f
Files changed (1) hide show
  1. sample.py +0 -70
sample.py DELETED
@@ -1,70 +0,0 @@
1
- import yaml
2
- import argbind
3
-
4
- import audiotools as at
5
-
6
- from vampnet.interface import Interface
7
- import logging
8
-
9
- logger = logging.getLogger()
10
- logger.setLevel(logging.DEBUG)
11
-
12
- Interface = argbind.bind(Interface)
13
-
14
- with open("conf/interface/spotdl.yml") as f:
15
- conf = yaml.safe_load(f)
16
-
17
-
18
- with argbind.scope(conf):
19
- interface = Interface()
20
- interface.to("cuda")
21
-
22
- loader = at.data.datasets.AudioLoader(sources=[
23
- "input.wav",
24
- ])
25
-
26
- dataset = at.data.datasets.AudioDataset(
27
- loader,
28
- sample_rate=interface.codec.sample_rate,
29
- duration=interface.coarse.chunk_size_s,
30
- n_examples=200,
31
- without_replacement=True,
32
- )
33
-
34
- import numpy as np
35
- def load_random_audio():
36
- index = np.random.randint(0, len(dataset))
37
- sig = dataset[index]["signal"]
38
- sig = interface.preprocess(sig)
39
-
40
- return sig
41
-
42
-
43
- sig = load_random_audio()
44
- z = interface.encode(sig)
45
-
46
- sig.write('input.wav')
47
-
48
- from vampnet import mask as pmask
49
-
50
- # build the mask
51
- mask = pmask.linear_random(z, 1.0)
52
-
53
- print("coarse")
54
- zv, mask_z = interface.coarse_vamp(
55
- z,
56
- mask=mask,
57
- sampling_steps=36,
58
- temperature=8.0,
59
- return_mask=True,
60
- typical_filtering=False,
61
- # typical_mass=data[typical_mass],
62
- # typical_min_tokens=data[typical_min_tokens],
63
- gen_fn=interface.coarse.generate,
64
- )
65
-
66
- print("coarse2fine")
67
- zv = interface.coarse_to_fine(zv, temperature=0.8)
68
-
69
- sig = interface.to_signal(zv).cpu()
70
- sig.write('output-t=8.wav')