H-H-E commited on
Commit
30290ac
·
1 Parent(s): 8be98a6

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -4
handler.py CHANGED
@@ -1,10 +1,10 @@
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("GPT2ForSequenceClassification", "suno/bark")
8
 
9
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
10
  """
@@ -18,6 +18,10 @@ class EndpointHandler:
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
 
 
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
  text_prompt = data.pop("inputs", data)
19
 
20
  # run normal prediction
21
+ text_prompt = """
22
+ Hello, my name is Suno. And, uh — and I like pizza. [laughs]
23
+ But I also have other interests such as playing tic tac toe.
24
+ """
25
+ audio_array = generate_audio(text_prompt)
26
+ return audio_array
27