changxin commited on
Commit
92b7644
·
1 Parent(s): 3c96b9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  import pulp
3
  import pandas as pd
4
  import openpyxl
 
5
 
6
  w_style="""
7
  <style>
@@ -28,6 +29,10 @@ def fx3(x):
28
  df=pd.read_excel(x,header=0,engine='openpyxl')
29
  return df
30
 
 
 
 
 
31
  with demo:
32
  gr.Markdown(
33
  """
@@ -47,9 +52,14 @@ with demo:
47
  file_input = gr.File(file_count="single",label="请选择需要读取的excel文件",show_label=True)
48
  table_output = gr.Dataframe(label="输出读取的表格数据",show_label=True)
49
  dq_button = gr.Button("开始读取>>")
50
-
 
 
 
 
51
  tj_button.click(fx1, inputs=text_input, outputs=text_output)
52
  cs_button.click(fx2, inputs=val_input, outputs=json_output)
53
  dq_button.click(fx3, inputs=file_input, outputs=table_output)
 
54
 
55
  demo.launch()
 
2
  import pulp
3
  import pandas as pd
4
  import openpyxl
5
+ import requests
6
 
7
  w_style="""
8
  <style>
 
29
  df=pd.read_excel(x,header=0,engine='openpyxl')
30
  return df
31
 
32
+ def fx4(x):
33
+ url_s="https://tts.baidu.com/text2audio?tex="+x+"&cuid=baike&lan=ZH&ie=utf-8&ctp=1&pdt=301&vol=9&rate=32&per=0"
34
+ return requests.get(url_s)
35
+
36
  with demo:
37
  gr.Markdown(
38
  """
 
52
  file_input = gr.File(file_count="single",label="请选择需要读取的excel文件",show_label=True)
53
  table_output = gr.Dataframe(label="输出读取的表格数据",show_label=True)
54
  dq_button = gr.Button("开始读取>>")
55
+ with gr.TabItem("TTS"):
56
+ TS_input = gr.Textbox(placeholder='请输入测试字符串,如"欢迎测试字符串转语音功能模块"',label="请输入测试内容",show_label=True)
57
+ audio_output = gr.Audio(label="生成音频文件",show_label=True)
58
+ tts_button = gr.Button("开始转换>>")
59
+
60
  tj_button.click(fx1, inputs=text_input, outputs=text_output)
61
  cs_button.click(fx2, inputs=val_input, outputs=json_output)
62
  dq_button.click(fx3, inputs=file_input, outputs=table_output)
63
+ tts_button.click(fx4, inputs=TS_input, outputs=audio_output)
64
 
65
  demo.launch()