Ailyth commited on
Commit
ff8b33b
1 Parent(s): 434981a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -96,6 +96,9 @@ def tts_generator(text, speaker, sdp_ratio, noise_scale, noise_scale_w, length_s
96
  except Exception as e:
97
  return "生成语音失败:" + str(e), None, None
98
 
 
 
 
99
  if __name__ == "__main__":
100
  hps = utils.get_hparams_from_file("./configs/config.json")
101
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
@@ -119,7 +122,7 @@ if __name__ == "__main__":
119
  text = gr.TextArea(label="Text", placeholder="Input Text Here",
120
  value="在不在?能不能借给我三百块钱买可乐",
121
  info="使用huggingface的免费CPU进行推理,因此速度不快,一次性不要输入超过500汉字")
122
- gr.Markdown(value="当前字数:")
123
  model = gr.Radio(choices=list(models.keys()), value=list(models.keys())[0], label='音声模型')
124
  #model = gr.Dropdown(choices=models,value=models[0], label='音声模型')
125
  speaker = gr.Radio(choices=speakers, value=speakers[0], label='Speaker')
@@ -142,4 +145,6 @@ if __name__ == "__main__":
142
  outputs=[text_output, audio_output,MP3_output]
143
  )
144
 
145
- app.launch(show_error=True)
 
 
 
96
  except Exception as e:
97
  return "生成语音失败:" + str(e), None, None
98
 
99
+ def count_chars(text):
100
+ return f"已输入:{len(text)}"
101
+
102
  if __name__ == "__main__":
103
  hps = utils.get_hparams_from_file("./configs/config.json")
104
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
 
122
  text = gr.TextArea(label="Text", placeholder="Input Text Here",
123
  value="在不在?能不能借给我三百块钱买可乐",
124
  info="使用huggingface的免费CPU进行推理,因此速度不快,一次性不要输入超过500汉字")
125
+ char_count = gr.Textbox(label="当前字数")
126
  model = gr.Radio(choices=list(models.keys()), value=list(models.keys())[0], label='音声模型')
127
  #model = gr.Dropdown(choices=models,value=models[0], label='音声模型')
128
  speaker = gr.Radio(choices=speakers, value=speakers[0], label='Speaker')
 
145
  outputs=[text_output, audio_output,MP3_output]
146
  )
147
 
148
+ app.launch(live=True,show_error=True)
149
+ itface = gr.Interface(fn=count_chars, inputs=text, outputs=char_count)
150
+ itface.launch()