Update handler.py
Browse files- handler.py +6 -10
handler.py
CHANGED
@@ -29,13 +29,9 @@ class EndpointHandler:
|
|
29 |
prompt_input_ids = self.tokenizer(prompt, return_tensors="pt").input_ids.to(self.device)
|
30 |
|
31 |
set_seed(42)
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
except Exception as e:
|
40 |
-
logger.error(str(e))
|
41 |
-
return {"error": str(e)}
|
|
|
29 |
prompt_input_ids = self.tokenizer(prompt, return_tensors="pt").input_ids.to(self.device)
|
30 |
|
31 |
set_seed(42)
|
32 |
+
generation = self.model.generate(input_ids=input_ids, prompt_input_ids=prompt_input_ids)
|
33 |
+
audio_arr = generation.cpu().numpy().squeeze()
|
34 |
+
sf.write("parler_tts_out.wav", audio_arr, self.model.config.sampling_rate)
|
35 |
+
with open("parler_tts_out.wav", "rb") as f:
|
36 |
+
return base64.b64encode(f.read()).decode()
|
37 |
+
|
|
|
|
|
|
|
|