Spaces:
Runtime error
Runtime error
Use speechsynthesizer to play audio in client side.
Browse files- app.py +1 -1
- audiobot.py +13 -4
- packages.txt +0 -2
- requirements.txt +1 -2
app.py
CHANGED
@@ -7,13 +7,13 @@ import os
|
|
7 |
|
8 |
|
9 |
def run():
|
10 |
-
os.environ['TOKENIZERS_PARALLELISM'] = 'false'
|
11 |
st.set_page_config(
|
12 |
page_title='Visual Question Answering - Bot',
|
13 |
page_icon=':robot:',
|
14 |
layout='wide'
|
15 |
)
|
16 |
|
|
|
17 |
st.session_state['predictor'] = predictor.Predictor()
|
18 |
|
19 |
st.sidebar.title('VQA Bot')
|
|
|
7 |
|
8 |
|
9 |
def run():
|
|
|
10 |
st.set_page_config(
|
11 |
page_title='Visual Question Answering - Bot',
|
12 |
page_icon=':robot:',
|
13 |
layout='wide'
|
14 |
)
|
15 |
|
16 |
+
os.environ['TOKENIZERS_PARALLELISM'] = 'false'
|
17 |
st.session_state['predictor'] = predictor.Predictor()
|
18 |
|
19 |
st.sidebar.title('VQA Bot')
|
audiobot.py
CHANGED
@@ -4,7 +4,6 @@ from PIL import Image
|
|
4 |
from bokeh.models.widgets import Button
|
5 |
from bokeh.models import CustomJS
|
6 |
from streamlit_bokeh_events import streamlit_bokeh_events
|
7 |
-
import pyttsx3
|
8 |
|
9 |
def show():
|
10 |
st.title('Visual Question Answering - Audiobot')
|
@@ -24,7 +23,8 @@ def show():
|
|
24 |
|
25 |
# Speech recognition based in streamlit based on
|
26 |
# https://discuss.streamlit.io/t/speech-to-text-on-client-side-using-html5-and-streamlit-bokeh-events/7888
|
27 |
-
stt_button = Button(label='Ask', width=100)
|
|
|
28 |
stt_button.js_on_event('button_click', CustomJS(code='''
|
29 |
var recognition = new webkitSpeechRecognition();
|
30 |
recognition.continuous = false;
|
@@ -47,7 +47,7 @@ def show():
|
|
47 |
result = streamlit_bokeh_events(
|
48 |
stt_button,
|
49 |
events='GET_TEXT',
|
50 |
-
key='
|
51 |
refresh_on_update=False,
|
52 |
override_height=75,
|
53 |
debounce_time=0)
|
@@ -56,4 +56,13 @@ def show():
|
|
56 |
if 'GET_TEXT' in result:
|
57 |
answer = st.session_state.predictor.predict_answer_from_text(
|
58 |
st.session_state.image, result.get('GET_TEXT'))
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from bokeh.models.widgets import Button
|
5 |
from bokeh.models import CustomJS
|
6 |
from streamlit_bokeh_events import streamlit_bokeh_events
|
|
|
7 |
|
8 |
def show():
|
9 |
st.title('Visual Question Answering - Audiobot')
|
|
|
23 |
|
24 |
# Speech recognition based in streamlit based on
|
25 |
# https://discuss.streamlit.io/t/speech-to-text-on-client-side-using-html5-and-streamlit-bokeh-events/7888
|
26 |
+
stt_button = Button(label='Ask Question', width=100)
|
27 |
+
|
28 |
stt_button.js_on_event('button_click', CustomJS(code='''
|
29 |
var recognition = new webkitSpeechRecognition();
|
30 |
recognition.continuous = false;
|
|
|
47 |
result = streamlit_bokeh_events(
|
48 |
stt_button,
|
49 |
events='GET_TEXT',
|
50 |
+
key='stt_listen',
|
51 |
refresh_on_update=False,
|
52 |
override_height=75,
|
53 |
debounce_time=0)
|
|
|
56 |
if 'GET_TEXT' in result:
|
57 |
answer = st.session_state.predictor.predict_answer_from_text(
|
58 |
st.session_state.image, result.get('GET_TEXT'))
|
59 |
+
|
60 |
+
tts_button = Button(label="Get Answer", width=100)
|
61 |
+
tts_button.js_on_event("button_click", CustomJS(code=f"""
|
62 |
+
var u = new SpeechSynthesisUtterance();
|
63 |
+
u.text = "{answer}";
|
64 |
+
u.lang = 'en-US';
|
65 |
+
|
66 |
+
speechSynthesis.speak(u);
|
67 |
+
"""))
|
68 |
+
st.bokeh_chart(tts_button)
|
packages.txt
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
alsa-utils
|
2 |
-
espeak
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -10,7 +10,7 @@ backcall==0.2.0
|
|
10 |
beautifulsoup4==4.11.1
|
11 |
bleach==5.0.0
|
12 |
blinker==1.4
|
13 |
-
bokeh==2.4.
|
14 |
cachetools==5.2.0
|
15 |
certifi==2022.6.15
|
16 |
cffi==1.15.0
|
@@ -75,7 +75,6 @@ Pympler==1.0.1
|
|
75 |
pyparsing==3.0.9
|
76 |
pyrsistent==0.18.1
|
77 |
python-dateutil==2.8.2
|
78 |
-
pyttsx3==2.90
|
79 |
pytz==2022.1
|
80 |
pytz-deprecation-shim==0.1.0.post0
|
81 |
PyYAML==6.0
|
|
|
10 |
beautifulsoup4==4.11.1
|
11 |
bleach==5.0.0
|
12 |
blinker==1.4
|
13 |
+
bokeh==2.4.1
|
14 |
cachetools==5.2.0
|
15 |
certifi==2022.6.15
|
16 |
cffi==1.15.0
|
|
|
75 |
pyparsing==3.0.9
|
76 |
pyrsistent==0.18.1
|
77 |
python-dateutil==2.8.2
|
|
|
78 |
pytz==2022.1
|
79 |
pytz-deprecation-shim==0.1.0.post0
|
80 |
PyYAML==6.0
|