Adding voice+chat feature
Browse files
app.py
CHANGED
@@ -18,9 +18,15 @@ def frontend():
|
|
18 |
recorded_audio = audio_recorder(sample_rate=8000)
|
19 |
text = st.chat_input()
|
20 |
if text:
|
|
|
21 |
response = answer(text)
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
status_placeholder.write("Converting audio...")
|
25 |
data_to_file(recorded_audio)
|
26 |
status_placeholder.write("Audio conversion done.")
|
|
|
18 |
recorded_audio = audio_recorder(sample_rate=8000)
|
19 |
text = st.chat_input()
|
20 |
if text:
|
21 |
+
status_placeholder.write("Getting response...")
|
22 |
response = answer(text)
|
23 |
+
status_placeholder.write("Coverting response in audio")
|
24 |
+
asyncio.run(convert_audio(response))
|
25 |
+
status_placeholder.write("Press mic button again to ask more questions")
|
26 |
+
st.write("Q:" + text)
|
27 |
+
st.write("A: " + response)
|
28 |
+
st.audio("output.mp3", format="audio/mp3", loop=False, autoplay=True)
|
29 |
+
elif recorded_audio:
|
30 |
status_placeholder.write("Converting audio...")
|
31 |
data_to_file(recorded_audio)
|
32 |
status_placeholder.write("Audio conversion done.")
|