Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
•
183d840
1
Parent(s):
514e91e
feat: first working driver.js guided tour
Browse files- aip_trainer/lambdas/js.py +26 -1
- app.py +3 -3
aip_trainer/lambdas/js.py
CHANGED
@@ -79,4 +79,29 @@ function playAudio(text, language) {
|
|
79 |
});
|
80 |
}
|
81 |
"""
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
});
|
80 |
}
|
81 |
"""
|
82 |
+
|
83 |
+
head_driver_tour = """
|
84 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/driver.js/1.3.1/driver.js.iife.js" integrity="sha512-8EdV4D5VlQLX0dJFcdx6h/oJ/NanAIMlaViz57NDkhzwbQsxabgpFua0gzM4f5vdk60CfRAydhlbfbDThMfh3w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
85 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/driver.js/1.3.1/driver.css" integrity="sha512-jRsM62XMRl33ewZ0Si7yX6ANq+ZiWwUcvPk4H2DKr417W80rPMXzbD/towhs2YEoux/dfOuVRkLB+5Tfzmfolg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
86 |
+
<script type="module">
|
87 |
+
console.log("window driver:", window, "!#")
|
88 |
+
const driver0 = window.driver;
|
89 |
+
console.log("driver0:", driver0, "!#")
|
90 |
+
const driverJs = driver0.js;
|
91 |
+
console.log("driverJs:", driverJs, "!#")
|
92 |
+
const driver = driverJs.driver;
|
93 |
+
|
94 |
+
console.log("driver:", driver, "!#")
|
95 |
+
|
96 |
+
const driverSteps = [
|
97 |
+
{ element: 'id-ai-pronunciation-trainer-gradio-app-container', popover: { title: 'AI Pronunciation Trainer Gradio app', description: 'A quick tour about my Pronunciation Trainer Gradio app functionality' } },
|
98 |
+
{ element: '#btn-run-tts-id-element', popover: { title: 'btn_run_tts', description: 'a button to run btn_run_tts' } },
|
99 |
+
{ element: '#btn-run-tts-backend-id-element', popover: { title: 'btn_run_tts_backend', description: 'a button to run btn_run_tts_backend' } }
|
100 |
+
]
|
101 |
+
const driverObj = driver({
|
102 |
+
showProgress: true,
|
103 |
+
steps: driverSteps
|
104 |
+
});
|
105 |
+
driverObj.drive();
|
106 |
+
</script>
|
107 |
+
"""
|
app.py
CHANGED
@@ -19,7 +19,7 @@ def clear2():
|
|
19 |
return None, None
|
20 |
|
21 |
|
22 |
-
with gr.Blocks(css=css) as gradio_app:
|
23 |
local_storage = gr.BrowserState([0.0, 0.0])
|
24 |
app_logger.info("start gradio app building...")
|
25 |
|
@@ -55,8 +55,8 @@ with gr.Blocks(css=css) as gradio_app:
|
|
55 |
with gr.Row():
|
56 |
audio_tts = gr.Audio(label="Audio TTS")
|
57 |
with gr.Row():
|
58 |
-
btn_run_tts = gr.Button(value="TTS in browser")
|
59 |
-
btn_run_tts_backend = gr.Button(value="TTS backend")
|
60 |
btn_clear_tts = gr.Button(value="Clear TTS backend")
|
61 |
btn_clear_tts.click(clear, inputs=[], outputs=[audio_tts])
|
62 |
with gr.Row():
|
|
|
19 |
return None, None
|
20 |
|
21 |
|
22 |
+
with gr.Blocks(css=css, head=js.head_driver_tour) as gradio_app:
|
23 |
local_storage = gr.BrowserState([0.0, 0.0])
|
24 |
app_logger.info("start gradio app building...")
|
25 |
|
|
|
55 |
with gr.Row():
|
56 |
audio_tts = gr.Audio(label="Audio TTS")
|
57 |
with gr.Row():
|
58 |
+
btn_run_tts = gr.Button(value="TTS in browser", elem_id="btn-run-tts-id-element")
|
59 |
+
btn_run_tts_backend = gr.Button(value="TTS backend", elem_id="btn-run-tts-backend-id-element")
|
60 |
btn_clear_tts = gr.Button(value="Clear TTS backend")
|
61 |
btn_clear_tts.click(clear, inputs=[], outputs=[audio_tts])
|
62 |
with gr.Row():
|