skroed
commited on
Commit
•
1c28486
1
Parent(s):
e1735f5
Fix: endpoint passing speaker.
Browse files- handler.py +12 -9
handler.py
CHANGED
@@ -20,15 +20,18 @@ class EndpointHandler:
|
|
20 |
"""
|
21 |
# process input
|
22 |
text = data.pop("inputs", data)
|
23 |
-
|
24 |
-
if
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
with torch.autocast("cuda"):
|
34 |
outputs = self.model.generate(**inputs)
|
|
|
20 |
"""
|
21 |
# process input
|
22 |
text = data.pop("inputs", data)
|
23 |
+
voice_preset = data.get("voice_preset", None)
|
24 |
+
if voice_preset:
|
25 |
+
inputs = self.processor(
|
26 |
+
text=[text],
|
27 |
+
return_tensors="pt",
|
28 |
+
voice_preset=voice_preset,
|
29 |
+
).to("cuda")
|
30 |
+
else:
|
31 |
+
inputs = self.processor(
|
32 |
+
text=[text],
|
33 |
+
return_tensors="pt",
|
34 |
+
).to("cuda")
|
35 |
|
36 |
with torch.autocast("cuda"):
|
37 |
outputs = self.model.generate(**inputs)
|