changxin commited on
Commit
4cad25d
1 Parent(s): a8c0847

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -11
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import hashlib
3
  import tempfile
 
4
  from TTS.utils.manage import ModelManager
5
  from TTS.utils.synthesizer import Synthesizer
6
  def fx(x:str):
@@ -20,19 +21,34 @@ def inference(text: str):
20
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
21
  synthesizer.save_wav(wavs, fp)
22
  return fp.name
 
 
 
 
 
 
 
23
 
24
  demo=gr.Blocks()
25
  with demo:
26
- with gr.Column():
27
- text_input=gr.Textbox(placeholder='请输入测试字符串',label="请输入需要MD5加密的测试内容")
28
- text_output=gr.Textbox(label="输出",visible=False)
29
- text_input.change(fn=lambda visible: gr.update(visible=True), inputs=text_input, outputs=text_output)
30
- bb_button=gr.Button("运行")
31
- bb_button.click(fx, inputs=text_input, outputs=text_output,api_name='md5')
32
- with gr.Column():
33
- gr.Markdown("# TTS文本字符串转语音合成训练")
34
- TTS_input=gr.Textbox(label="输入文本",default="你好吗?我很好。")
35
- TTS_button=gr.Button("合成")
36
- TTS_button.click(inference, inputs=TTS_input, outputs=gr.Audio(label="输出合成结果"),api_name='tts')
 
 
 
 
 
 
 
 
37
  demo.launch()
38
 
 
1
  import gradio as gr
2
  import hashlib
3
  import tempfile
4
+ import requests
5
  from TTS.utils.manage import ModelManager
6
  from TTS.utils.synthesizer import Synthesizer
7
  def fx(x:str):
 
21
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
22
  synthesizer.save_wav(wavs, fp)
23
  return fp.name
24
+
25
+ headers= {"Content-Type": "application/json"}
26
+ url="https://m-formatter.azurewebsites.net/api/v2"
27
+ def fx_m(s:str):
28
+ data={'code':s,'resultType':'text'}
29
+ respose=requests.post(url, json=data, headers)
30
+ return respose.text
31
 
32
  demo=gr.Blocks()
33
  with demo:
34
+ with gr.Tabs():
35
+ with gr.TabItem("测试1"):
36
+ with gr.Column():
37
+ text_input=gr.Textbox(placeholder='请输入测试字符串',label="请输入需要MD5加密的测试内容")
38
+ text_output=gr.Textbox(label="输出",visible=False)
39
+ text_input.change(fn=lambda visible: gr.update(visible=True), inputs=text_input, outputs=text_output)
40
+ bb_button=gr.Button("运行")
41
+ bb_button.click(fx, inputs=text_input, outputs=text_output,api_name='md5')
42
+ with gr.Column():
43
+ gr.Markdown("# TTS文本字符串转语音合成训练")
44
+ TTS_input=gr.Textbox(label="输入文本",default="你好吗?我很好。")
45
+ TTS_button=gr.Button("合成")
46
+ TTS_button.click(inference, inputs=TTS_input, outputs=gr.Audio(label="输出合成结果"),api_name='tts')
47
+ with gr.TabItem("M-Formatter"):
48
+ gr.Markdown("# PowerQuery M语言脚本格式化测试")
49
+ M_input=gr.Textbox(label="请填写需要格式化的M脚本",default="let a=1,b=2 in a+b",lines=28)
50
+ M_output=gr.Textbox(label="格式化结果",lines=50)
51
+ M_button=gr.Button("开始格式化>>")
52
+ M_button.click(fx_m, inputs=M_input, outputs=M_output,api_name='M')
53
  demo.launch()
54