H-H-E commited on
Commit
62f977c
1 Parent(s): f067669

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +4 -3
handler.py CHANGED
@@ -1,10 +1,10 @@
1
  from typing import Dict, List, Any
2
- from bark import SAMPLE_RATE, generate_audio, preload_models
3
 
4
 
5
  class EndpointHandler:
6
  def __init__(self, path=""):
7
- preload_models()
8
 
9
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
10
  """
@@ -18,5 +18,6 @@ class EndpointHandler:
18
  text_prompt = data.pop("inputs", data)
19
 
20
  # run normal prediction
21
- speech_array = generate_audio(text_prompt)
22
  return speech_array
 
 
1
  from typing import Dict, List, Any
2
+ from transformers import pipeline
3
 
4
 
5
  class EndpointHandler:
6
  def __init__(self, path=""):
7
+ self.model = pipeline("text-to-speech", "suno/bark")
8
 
9
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
10
  """
 
18
  text_prompt = data.pop("inputs", data)
19
 
20
  # run normal prediction
21
+ speech_array = self.model(text_prompt,forward_params={"do_sample": True})
22
  return speech_array
23
+