Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_webrtc import webrtc_streamer, WebRtcMode, ClientSettings
|
3 |
+
|
4 |
+
# Initialize Streamlit app layout
|
5 |
+
st.title("Microphone Input in Streamlit")
|
6 |
+
|
7 |
+
# WebRTC settings
|
8 |
+
webrtc_ctx = webrtc_streamer(
|
9 |
+
key="audio-only",
|
10 |
+
mode=WebRtcMode.SENDONLY,
|
11 |
+
client_settings=ClientSettings(
|
12 |
+
media_stream_constraints={
|
13 |
+
"audio": True,
|
14 |
+
"video": False
|
15 |
+
}
|
16 |
+
)
|
17 |
+
)
|
18 |
+
|
19 |
+
# Placeholder for capturing audio
|
20 |
+
if webrtc_ctx.state.playing:
|
21 |
+
st.write("Microphone is active. Speak into the microphone...")
|
22 |
+
else:
|
23 |
+
st.write("Click to start microphone input.")
|