Skip to content

Commit

Permalink
Fix hidden manual mic input issue
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovcmedeiros committed Mar 2, 2024
1 parent 6c36fe4 commit 545706b
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions pyrobbot/app/multipage.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,6 @@ def __init__(self, **kwargs) -> None:
"""Initialise streamlit page configs."""
st.set_page_config(**kwargs)

hide_zero_height_elements = """
<style>
.element-container:has(iframe[height="0"]) {
display: none;
overflow: hidden;
max-height: 0;
}
</style>
"""
st.markdown(hide_zero_height_elements, unsafe_allow_html=True)

self.listen_thread = listen_thread
self.continuous_user_prompt_thread = continuous_user_prompt_thread
self.handle_stt_thread = handle_stt_thread
Expand Down Expand Up @@ -371,16 +360,28 @@ def audio_frame_callback(frame):
add_script_run_ctx(audio_frame_callback)

logger.debug("Initialising input audio stream...")
hide_webrtc_streamer_button = """
<style>
.element-container:has(
iframe[title="streamlit_webrtc.component.webrtc_streamer"]
) {
display: none;
overflow: hidden;
max-height: 0;
}
</style>
"""
st.markdown(hide_webrtc_streamer_button, unsafe_allow_html=True)

try:
with st.container(height=0, border=False):
self.stream_audio_context = streamlit_webrtc.component.webrtc_streamer(
key="sendonly-audio",
mode=WebRtcMode.SENDONLY,
rtc_configuration=rtc_configuration,
media_stream_constraints={"audio": True, "video": False},
desired_playing_state=True,
audio_frame_callback=audio_frame_callback,
)
self.stream_audio_context = streamlit_webrtc.component.webrtc_streamer(
key="sendonly-audio",
mode=WebRtcMode.SENDONLY,
rtc_configuration=rtc_configuration,
media_stream_constraints={"audio": True, "video": False},
desired_playing_state=True,
audio_frame_callback=audio_frame_callback,
)
except TypeError:
logger.opt(exception=True).error("Failed to initialise audio stream")
logger.error("Failed to initialise audio stream")
Expand Down

0 comments on commit 545706b

Please sign in to comment.