Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,27 @@ def read_pdf(pdf_url):
|
|
33 |
def load_html(url):
|
34 |
html=f"""<iframe src="https://docs.google.com/viewer?url={url})&embedded=true" frameborder="0" height="1200px" width="100%"></iframe></div>"""
|
35 |
return html
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
js="""
|
38 |
function () {
|
39 |
const urlParams = new URLSearchParams(window.location.search);
|
@@ -68,13 +88,14 @@ function () {
|
|
68 |
} else {
|
69 |
p_pau = "1";
|
70 |
};
|
|
|
71 |
return [p_pdf, p_mod, p_len, p_nos, p_wid, p_pau];
|
72 |
}
|
73 |
"""
|
74 |
|
75 |
-
with gr.Blocks() as app:
|
76 |
a=gr.Audio(streaming=True,autoplay=True)
|
77 |
-
h=gr.HTML()
|
78 |
with gr.Column(visible=False):
|
79 |
t=gr.Textbox(label="url",interactive=False,visible=True)
|
80 |
m=gr.Textbox(label="mod",value="en_US-joe-medium",interactive=False,visible=True)
|
@@ -84,8 +105,7 @@ with gr.Blocks() as app:
|
|
84 |
p=gr.Textbox(label="pau",value="1",interactive=False,visible=True)
|
85 |
bulk=gr.Textbox(label="bulk",interactive=False,visible=True)
|
86 |
|
87 |
-
app.load(None,None,[t,m,l,n,w,p],js=js)
|
88 |
-
|
89 |
t.change(read_pdf,t,bulk)
|
90 |
m.change(pp.load_mod,m,None)
|
91 |
bulk.change(pp.stream_tts,[bulk,m,l,n,w,p],a)
|
|
|
33 |
def load_html(url):
|
34 |
html=f"""<iframe src="https://docs.google.com/viewer?url={url})&embedded=true" frameborder="0" height="1200px" width="100%"></iframe></div>"""
|
35 |
return html
|
36 |
+
head = """
|
37 |
+
<script>
|
38 |
+
function run(url_in) {
|
39 |
+
let url = String(url_in)
|
40 |
+
console.log(url);
|
41 |
+
|
42 |
+
var framediv = document.getElementById('cap');
|
43 |
+
let child = framediv.lastElementChild;
|
44 |
+
while (child) {
|
45 |
+
framediv.removeChild(child);
|
46 |
+
child=framediv.lastElementChild;
|
47 |
+
}
|
48 |
+
const iframediv = document.createElement('iframe');
|
49 |
+
iframediv.src = 'https://docs.google.com/viewer?url=' + url +'&embedded=true';
|
50 |
+
iframediv.width = '100%';
|
51 |
+
iframediv.height = '1000px';
|
52 |
+
iframediv.frameborder="0";
|
53 |
+
framediv.appendChild(iframediv);
|
54 |
+
}
|
55 |
+
</script>
|
56 |
+
"""
|
57 |
js="""
|
58 |
function () {
|
59 |
const urlParams = new URLSearchParams(window.location.search);
|
|
|
88 |
} else {
|
89 |
p_pau = "1";
|
90 |
};
|
91 |
+
run(p_pdf)
|
92 |
return [p_pdf, p_mod, p_len, p_nos, p_wid, p_pau];
|
93 |
}
|
94 |
"""
|
95 |
|
96 |
+
with gr.Blocks(head=head) as app:
|
97 |
a=gr.Audio(streaming=True,autoplay=True)
|
98 |
+
h=gr.HTML("""<div id='cap'></div>""")
|
99 |
with gr.Column(visible=False):
|
100 |
t=gr.Textbox(label="url",interactive=False,visible=True)
|
101 |
m=gr.Textbox(label="mod",value="en_US-joe-medium",interactive=False,visible=True)
|
|
|
105 |
p=gr.Textbox(label="pau",value="1",interactive=False,visible=True)
|
106 |
bulk=gr.Textbox(label="bulk",interactive=False,visible=True)
|
107 |
|
108 |
+
app.load(None,None,[t,m,l,n,w,p],js=js)
|
|
|
109 |
t.change(read_pdf,t,bulk)
|
110 |
m.change(pp.load_mod,m,None)
|
111 |
bulk.change(pp.stream_tts,[bulk,m,l,n,w,p],a)
|