sayashi commited on
Commit
353fbac
1 Parent(s): 426811c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -6,7 +6,12 @@ import argparse
6
  import commons
7
  from models import SynthesizerTrn
8
  from text import text_to_sequence
 
9
  from torch import no_grad, LongTensor
 
 
 
 
10
 
11
  hps_ms = utils.get_hparams_from_file(r'./model/config.json')
12
  net_g_ms = SynthesizerTrn(
@@ -31,7 +36,7 @@ def vits(text, language, speaker_id, noise_scale, noise_scale_w, length_scale):
31
  if not len(text):
32
  return "输入文本不能为空!", None, None
33
  text = text.replace('\n', ' ').replace('\r', '').replace(" ", "")
34
- if len(text) > 100:
35
  return f"输入文字过长!{len(text)}>100", None, None
36
  if language == 0:
37
  text = f"[ZH]{text}[ZH]"
@@ -90,6 +95,7 @@ if __name__ == '__main__':
90
  parser.add_argument('--device', type=str, default='cpu')
91
  parser.add_argument('--api', action="store_true", default=False)
92
  parser.add_argument("--share", action="store_true", default=False, help="share gradio app")
 
93
  args = parser.parse_args()
94
  device = torch.device(args.device)
95
  with gr.Blocks() as app:
@@ -105,7 +111,7 @@ if __name__ == '__main__':
105
  with gr.TabItem("vits"):
106
  with gr.Row():
107
  with gr.Column():
108
- input_text = gr.Textbox(label="Text (100 words limitation)", lines=5, value="今天晚上吃啥好呢。", elem_id=f"input-text")
109
  lang = gr.Dropdown(label="Language", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
110
  type="index", value="中文")
111
  btn = gr.Button(value="Submit")
 
6
  import commons
7
  from models import SynthesizerTrn
8
  from text import text_to_sequence
9
+ import torch
10
  from torch import no_grad, LongTensor
11
+ import webbrowser
12
+ import logging
13
+ logging.getLogger('numba').setLevel(logging.WARNING)
14
+ limitation = os.getenv("SYSTEM") == "spaces" # limit text and audio length in huggingface spaces
15
 
16
  hps_ms = utils.get_hparams_from_file(r'./model/config.json')
17
  net_g_ms = SynthesizerTrn(
 
36
  if not len(text):
37
  return "输入文本不能为空!", None, None
38
  text = text.replace('\n', ' ').replace('\r', '').replace(" ", "")
39
+ if len(text) > 100 and limitation:
40
  return f"输入文字过长!{len(text)}>100", None, None
41
  if language == 0:
42
  text = f"[ZH]{text}[ZH]"
 
95
  parser.add_argument('--device', type=str, default='cpu')
96
  parser.add_argument('--api', action="store_true", default=False)
97
  parser.add_argument("--share", action="store_true", default=False, help="share gradio app")
98
+ parser.add_argument("--colab", action="store_true", default=False, help="share gradio app")
99
  args = parser.parse_args()
100
  device = torch.device(args.device)
101
  with gr.Blocks() as app:
 
111
  with gr.TabItem("vits"):
112
  with gr.Row():
113
  with gr.Column():
114
+ input_text = gr.Textbox(label="Text (100 words limitation) " if limitation else "Text", lines=5, value="今天晚上吃啥好呢。", elem_id=f"input-text")
115
  lang = gr.Dropdown(label="Language", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
116
  type="index", value="中文")
117
  btn = gr.Button(value="Submit")