-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexample.py
More file actions
31 lines (26 loc) · 1 KB
/
Copy pathexample.py
File metadata and controls
31 lines (26 loc) · 1 KB
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
import torch
from pathlib import Path
import os
from mellow import MellowWrapper
if __name__ == "__main__":
# setup cuda and device
cuda = torch.cuda.is_available()
device = 0 if cuda else "cpu"
# setup mellow
mellow = MellowWrapper(
config = "v0",
model = "v0",
device=device,
use_cuda=cuda,
)
# pick up audio file paths
parent_path = Path(os.path.realpath(__file__)).parent
path1 = os.path.join(parent_path, "resource", "1.wav")
path2 = os.path.join(parent_path, "resource", "2.wav")
# list of filepaths and prompts
examples = [
[path1, path2, "what is the primary sound event present in the clip? a) dog barking b) chirping birds c) car engine d) clapping"], # defaults to first audio
]
# generate response
response = mellow.generate(examples=examples, max_len=300, top_p=0.8, temperature=1.0)
print(f"\noutput: {response}")