Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -117,13 +117,13 @@ function readfn(inn, url_in, payload) {
|
|
117 |
</script>
|
118 |
"""
|
119 |
|
120 |
-
def search(q,rn,st):
|
121 |
payload={
|
122 |
-
"model":
|
123 |
-
"length":
|
124 |
-
"noise":
|
125 |
-
"width":
|
126 |
-
"pause":
|
127 |
}
|
128 |
api=f"http://export.arxiv.org/api/query?search_query={str(q)}&start={str(st)}&max_results={str(rn)}"
|
129 |
r=requests.get(api)
|
@@ -159,12 +159,7 @@ def show_num(cur):
|
|
159 |
new=int(cur)+10
|
160 |
html_out=f"<div><center>Showing {cur} through {new}</center></div>"
|
161 |
return html_out
|
162 |
-
|
163 |
-
txt=inp[0]['text']
|
164 |
-
pp=PyPiper()
|
165 |
-
pp.load_mod()
|
166 |
-
yield(pp.stream_tts(in_text=txt,model="en_US-joe-medium"))
|
167 |
-
|
168 |
with gr.Blocks(css=style,head=head) as b:
|
169 |
gr.HTML("""<center><div><h1 style='font-size:xxx-large;font-weight:900;'>arXiv Reader with Voice</h1>
|
170 |
<h2>Read arXiv papers using Piper Text-to-Voice</h2></div><br>
|
@@ -177,6 +172,12 @@ with gr.Blocks(css=style,head=head) as b:
|
|
177 |
with gr.Column(scale=3):
|
178 |
query=gr.Textbox(label="Query",info="Search arXiv papers")
|
179 |
sub=gr.Button(elem_id='big_btn')
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
with gr.Group():
|
181 |
with gr.Row():
|
182 |
prev_btn=gr.Button("Previous",interactive=False)
|
@@ -194,5 +195,5 @@ with gr.Blocks(css=style,head=head) as b:
|
|
194 |
next_btn.click(next_show,[hid_start],[prev_btn,hid_start]).then(show_num,hid_start,show_html).then(search,[query,num,hid_start],[html_out])
|
195 |
prev_btn.click(prev_show,[hid_start],[prev_btn,hid_start]).then(show_num,hid_start,show_html).then(search,[query,num,hid_start],[html_out])
|
196 |
|
197 |
-
sub.click(search,[query,num,hid_start],[html_out]).then(show_num,hid_start,show_html)
|
198 |
b.queue(default_concurrency_limit=20).launch(max_threads=40)
|
|
|
117 |
</script>
|
118 |
"""
|
119 |
|
120 |
+
def search(q,rn,st,names,length,noise,width,sen_pause):
|
121 |
payload={
|
122 |
+
"model": names,
|
123 |
+
"length": length,
|
124 |
+
"noise": noise,
|
125 |
+
"width": width,
|
126 |
+
"pause": sen_pause
|
127 |
}
|
128 |
api=f"http://export.arxiv.org/api/query?search_query={str(q)}&start={str(st)}&max_results={str(rn)}"
|
129 |
r=requests.get(api)
|
|
|
159 |
new=int(cur)+10
|
160 |
html_out=f"<div><center>Showing {cur} through {new}</center></div>"
|
161 |
return html_out
|
162 |
+
|
|
|
|
|
|
|
|
|
|
|
163 |
with gr.Blocks(css=style,head=head) as b:
|
164 |
gr.HTML("""<center><div><h1 style='font-size:xxx-large;font-weight:900;'>arXiv Reader with Voice</h1>
|
165 |
<h2>Read arXiv papers using Piper Text-to-Voice</h2></div><br>
|
|
|
172 |
with gr.Column(scale=3):
|
173 |
query=gr.Textbox(label="Query",info="Search arXiv papers")
|
174 |
sub=gr.Button(elem_id='big_btn')
|
175 |
+
with gr.Accordion("Voice Controls"):
|
176 |
+
names=gr.Dropdown(choices=pp.key_list,value="en_US-lessac-high")
|
177 |
+
length=gr.Slider(label="Length", minimum=0.01, maximum=10.0, value=1)
|
178 |
+
noise=gr.Slider(label="Noise", minimum=0.01, maximum=3.0, value=0.5)
|
179 |
+
width=gr.Slider(label="Noise Width", minimum=0.01, maximum=3.0, value=0.5)
|
180 |
+
sen_pause=gr.Slider(label="Sentence Pause", minimum=0.1, maximum=10.0, value=1)
|
181 |
with gr.Group():
|
182 |
with gr.Row():
|
183 |
prev_btn=gr.Button("Previous",interactive=False)
|
|
|
195 |
next_btn.click(next_show,[hid_start],[prev_btn,hid_start]).then(show_num,hid_start,show_html).then(search,[query,num,hid_start],[html_out])
|
196 |
prev_btn.click(prev_show,[hid_start],[prev_btn,hid_start]).then(show_num,hid_start,show_html).then(search,[query,num,hid_start],[html_out])
|
197 |
|
198 |
+
sub.click(search,[query,num,hid_start,names,length,noise,width,sen_pause],[html_out]).then(show_num,hid_start,show_html)
|
199 |
b.queue(default_concurrency_limit=20).launch(max_threads=40)
|