skytnt commited on
Commit
c86d965
β€’
1 Parent(s): 1f9f8f9
Files changed (2) hide show
  1. app.py +14 -2
  2. text/__init__.py +0 -1
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import json
2
  import os
 
 
3
  import librosa
4
  import numpy as np
5
  import torch
@@ -24,8 +26,17 @@ def get_text(text, hps, is_phoneme):
24
 
25
  def create_tts_fn(model, hps, speaker_ids):
26
  def tts_fn(text, speaker, speed, is_phoneme):
27
- if limitation and ((len(text) > 60 and not is_phoneme) or (len(text) > 120 and is_phoneme)):
28
- return "Error: Text is too long", None
 
 
 
 
 
 
 
 
 
29
  speaker_id = speaker_ids[speaker]
30
  stn_tst = get_text(text, hps, is_phoneme)
31
  with no_grad():
@@ -76,6 +87,7 @@ def create_vc_fn(model, hps, speaker_ids):
76
  def create_to_phoneme_fn(hps):
77
  def to_phoneme_fn(text):
78
  return _clean_text(text, hps.data.text_cleaners) if text != "" else ""
 
79
  return to_phoneme_fn
80
 
81
 
 
1
  import json
2
  import os
3
+ import re
4
+
5
  import librosa
6
  import numpy as np
7
  import torch
 
26
 
27
  def create_tts_fn(model, hps, speaker_ids):
28
  def tts_fn(text, speaker, speed, is_phoneme):
29
+ if limitation:
30
+ text_len = len(text)
31
+ max_len = 60
32
+ if is_phoneme:
33
+ max_len *= 3
34
+ else:
35
+ if len(hps.data.text_cleaners) > 0 and hps.data.text_cleaners[0] == "zh_ja_mixture_cleaners":
36
+ text_len = len(re.sub("(\[ZH\]|\[JA\])", "", text))
37
+ if text_len > max_len:
38
+ return "Error: Text is too long", None
39
+
40
  speaker_id = speaker_ids[speaker]
41
  stn_tst = get_text(text, hps, is_phoneme)
42
  with no_grad():
 
87
  def create_to_phoneme_fn(hps):
88
  def to_phoneme_fn(text):
89
  return _clean_text(text, hps.data.text_cleaners) if text != "" else ""
90
+
91
  return to_phoneme_fn
92
 
93
 
text/__init__.py CHANGED
@@ -29,5 +29,4 @@ def _clean_text(text, cleaner_names):
29
  if not cleaner:
30
  raise Exception('Unknown cleaner: %s' % name)
31
  text = cleaner(text)
32
- print(text, cleaner_names)
33
  return text
 
29
  if not cleaner:
30
  raise Exception('Unknown cleaner: %s' % name)
31
  text = cleaner(text)
 
32
  return text