Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import hashlib
|
| 3 |
-
import tempfile
|
| 4 |
-
import requests
|
| 5 |
import pandas as pd
|
| 6 |
from datatable import (dt, f,fread, by, ifelse, update, sort,count, min, max, mean, sum, rowsum,rowmean,rowcount,shift,rbind,cbind,union)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from TTS.utils.manage import ModelManager
|
| 8 |
from TTS.utils.synthesizer import Synthesizer
|
|
|
|
| 9 |
def fx(x:str):
|
| 10 |
hash=hashlib.md5()
|
| 11 |
hash.update(x.encode(encoding='utf-8'))
|
|
@@ -23,7 +25,7 @@ def inference(text: str):
|
|
| 23 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 24 |
synthesizer.save_wav(wavs, fp)
|
| 25 |
return fp.name
|
| 26 |
-
|
| 27 |
def fx_m(s:str):
|
| 28 |
headers= {"Content-Type": "application/json"}
|
| 29 |
url="https://m-formatter.azurewebsites.net/api/v2"
|
|
@@ -46,7 +48,7 @@ def fx_datatable(code:str):
|
|
| 46 |
fun = compile(code,'<string>','exec')
|
| 47 |
exec(fun,namespace)
|
| 48 |
return namespace['py_exe']
|
| 49 |
-
|
| 50 |
def fx_dd(tk:str,s:str):
|
| 51 |
headers= {"Content-Type": "application/json"}
|
| 52 |
url="https://oapi.dingtalk.com/robot/send?access_token="+tk
|
|
@@ -67,11 +69,12 @@ def fx_dt(dc,x,y):
|
|
| 67 |
gr.JSON(DT.names)
|
| 68 |
D_table=DT[:,sum(f[int(y-1)]),by(f[int(x-1)])]
|
| 69 |
return D_table.to_pandas()
|
| 70 |
-
|
| 71 |
demo=gr.Blocks(css="#jsc:hover{background-color: red;}")
|
| 72 |
with demo:
|
| 73 |
with gr.Tabs(selected=5):
|
| 74 |
with gr.TabItem("测试1"):
|
|
|
|
| 75 |
with gr.Column():
|
| 76 |
text_input=gr.Textbox(placeholder='请输入测试字符串',label="请输入需要MD5加密的测试内容")
|
| 77 |
text_output=gr.Textbox(label="输出",visible=False)
|
|
@@ -82,7 +85,7 @@ with demo:
|
|
| 82 |
gr.Markdown("# TTS文本字符串转语音合成训练")
|
| 83 |
TTS_input=gr.Textbox(label="输入文本")
|
| 84 |
TTS_button=gr.Button("合成")
|
| 85 |
-
TTS_button.click(inference, inputs=TTS_input, outputs=gr.Audio(label="输出合成结果"),api_name='tts')
|
| 86 |
with gr.TabItem("M-Formatter"):
|
| 87 |
gr.Markdown("# PowerQuery M语言脚本格式化测试")
|
| 88 |
M_input=gr.Textbox(label="请填写需要格式化的M脚本",lines=18)
|
|
@@ -104,7 +107,7 @@ with demo:
|
|
| 104 |
d_output=gr.DataFrame(label="输出>")
|
| 105 |
d_button=gr.Button("开始编译>>")
|
| 106 |
d_button.click(fx_datatable, inputs=d_input, outputs=d_output,api_name='pyexe')
|
| 107 |
-
|
| 108 |
with gr.TabItem("钉钉群消息推送"):
|
| 109 |
gr.Markdown("# 推送测试")
|
| 110 |
dd_input=[gr.Textbox(label="请填写机器人token"),gr.Textbox(label="请填写需要推送的信息",lines=10)]
|
|
@@ -125,7 +128,7 @@ with demo:
|
|
| 125 |
dt_output=gr.DataFrame(label="输出",max_rows=10,wrap=True)
|
| 126 |
dt_button=gr.Button("分类汇总")
|
| 127 |
dt_button.click(fx_dt, inputs=dt_input, outputs=dt_output,api_name='datatable')
|
| 128 |
-
|
| 129 |
with gr.TabItem("js"):
|
| 130 |
gr.Markdown("# js处理测试")
|
| 131 |
a=gr.Textbox(label='请输入需要js处理的字符串')
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from datatable import (dt, f,fread, by, ifelse, update, sort,count, min, max, mean, sum, rowsum,rowmean,rowcount,shift,rbind,cbind,union)
|
| 4 |
+
import requests
|
| 5 |
+
'''
|
| 6 |
+
import hashlib
|
| 7 |
+
import tempfile
|
| 8 |
from TTS.utils.manage import ModelManager
|
| 9 |
from TTS.utils.synthesizer import Synthesizer
|
| 10 |
+
|
| 11 |
def fx(x:str):
|
| 12 |
hash=hashlib.md5()
|
| 13 |
hash.update(x.encode(encoding='utf-8'))
|
|
|
|
| 25 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 26 |
synthesizer.save_wav(wavs, fp)
|
| 27 |
return fp.name
|
| 28 |
+
'''
|
| 29 |
def fx_m(s:str):
|
| 30 |
headers= {"Content-Type": "application/json"}
|
| 31 |
url="https://m-formatter.azurewebsites.net/api/v2"
|
|
|
|
| 48 |
fun = compile(code,'<string>','exec')
|
| 49 |
exec(fun,namespace)
|
| 50 |
return namespace['py_exe']
|
| 51 |
+
'''
|
| 52 |
def fx_dd(tk:str,s:str):
|
| 53 |
headers= {"Content-Type": "application/json"}
|
| 54 |
url="https://oapi.dingtalk.com/robot/send?access_token="+tk
|
|
|
|
| 69 |
gr.JSON(DT.names)
|
| 70 |
D_table=DT[:,sum(f[int(y-1)]),by(f[int(x-1)])]
|
| 71 |
return D_table.to_pandas()
|
| 72 |
+
'''
|
| 73 |
demo=gr.Blocks(css="#jsc:hover{background-color: red;}")
|
| 74 |
with demo:
|
| 75 |
with gr.Tabs(selected=5):
|
| 76 |
with gr.TabItem("测试1"):
|
| 77 |
+
'''
|
| 78 |
with gr.Column():
|
| 79 |
text_input=gr.Textbox(placeholder='请输入测试字符串',label="请输入需要MD5加密的测试内容")
|
| 80 |
text_output=gr.Textbox(label="输出",visible=False)
|
|
|
|
| 85 |
gr.Markdown("# TTS文本字符串转语音合成训练")
|
| 86 |
TTS_input=gr.Textbox(label="输入文本")
|
| 87 |
TTS_button=gr.Button("合成")
|
| 88 |
+
TTS_button.click(inference, inputs=TTS_input, outputs=gr.Audio(label="输出合成结果"),api_name='tts')'''
|
| 89 |
with gr.TabItem("M-Formatter"):
|
| 90 |
gr.Markdown("# PowerQuery M语言脚本格式化测试")
|
| 91 |
M_input=gr.Textbox(label="请填写需要格式化的M脚本",lines=18)
|
|
|
|
| 107 |
d_output=gr.DataFrame(label="输出>")
|
| 108 |
d_button=gr.Button("开始编译>>")
|
| 109 |
d_button.click(fx_datatable, inputs=d_input, outputs=d_output,api_name='pyexe')
|
| 110 |
+
'''
|
| 111 |
with gr.TabItem("钉钉群消息推送"):
|
| 112 |
gr.Markdown("# 推送测试")
|
| 113 |
dd_input=[gr.Textbox(label="请填写机器人token"),gr.Textbox(label="请填写需要推送的信息",lines=10)]
|
|
|
|
| 128 |
dt_output=gr.DataFrame(label="输出",max_rows=10,wrap=True)
|
| 129 |
dt_button=gr.Button("分类汇总")
|
| 130 |
dt_button.click(fx_dt, inputs=dt_input, outputs=dt_output,api_name='datatable')
|
| 131 |
+
'''
|
| 132 |
with gr.TabItem("js"):
|
| 133 |
gr.Markdown("# js处理测试")
|
| 134 |
a=gr.Textbox(label='请输入需要js处理的字符串')
|