martillopartbsc commited on
Commit
7bcefc4
1 Parent(s): 0734d5a

change to process_text

Browse files
Files changed (1) hide show
  1. infer_onnx.py +8 -7
infer_onnx.py CHANGED
@@ -24,8 +24,15 @@ def intersperse(lst, item):
24
  return result
25
 
26
 
 
 
 
 
 
 
27
  def process_text(i: int, text: str, device: torch.device, cleaner:str):
28
  print(f"[{i}] - Input text: {text}")
 
29
  x = torch.tensor(
30
  intersperse(text_to_sequence(text, [cleaner]), 0),
31
  dtype=torch.long,
@@ -36,12 +43,6 @@ def process_text(i: int, text: str, device: torch.device, cleaner:str):
36
  print(x_phones)
37
  return x.numpy(), x_lengths.numpy()
38
 
39
- def check_input(text):
40
- if len(text) > 500:
41
- raise gr.Error("Wrong input, more than 5 characters")
42
- else:
43
- return text
44
-
45
  # paths
46
  MODEL_PATH_MATCHA_MEL_BAL="matcha_multispeaker_cat_bal_opset_15_10_steps.onnx"
47
  MODEL_PATH_MATCHA_MEL_CAT="matcha_multispeaker_cat_cen_opset_15_10_steps.onnx"
@@ -162,7 +163,7 @@ def tts(text:str, accent:str, spk_name:str, temperature:float, length_scale:floa
162
  denoise=True
163
  spk_id = speaker_id_dict[accent][spk_name]
164
  sid = np.array([int(spk_id)]) if spk_id is not None else None
165
- text_matcha , text_lengths = process_text(0,check_input(text),"cpu",cleaner=cleaners[accent])
166
  model_matcha_mel = models[accent]
167
 
168
  # MATCHA VOCOS
 
24
  return result
25
 
26
 
27
+ def check_input(text):
28
+ if len(text) > 500:
29
+ raise gr.Error("Wrong input, more than 5 characters")
30
+ else:
31
+ return text
32
+
33
  def process_text(i: int, text: str, device: torch.device, cleaner:str):
34
  print(f"[{i}] - Input text: {text}")
35
+ check_input(text)
36
  x = torch.tensor(
37
  intersperse(text_to_sequence(text, [cleaner]), 0),
38
  dtype=torch.long,
 
43
  print(x_phones)
44
  return x.numpy(), x_lengths.numpy()
45
 
 
 
 
 
 
 
46
  # paths
47
  MODEL_PATH_MATCHA_MEL_BAL="matcha_multispeaker_cat_bal_opset_15_10_steps.onnx"
48
  MODEL_PATH_MATCHA_MEL_CAT="matcha_multispeaker_cat_cen_opset_15_10_steps.onnx"
 
163
  denoise=True
164
  spk_id = speaker_id_dict[accent][spk_name]
165
  sid = np.array([int(spk_id)]) if spk_id is not None else None
166
+ text_matcha , text_lengths = process_text(0,text,"cpu",cleaner=cleaners[accent])
167
  model_matcha_mel = models[accent]
168
 
169
  # MATCHA VOCOS