Spaces:
Sleeping
Sleeping
Create live_session.py
Browse files- live_session.py +41 -0
live_session.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from audio_recorder_streamlit import audio_recorder
|
3 |
+
import time
|
4 |
+
|
5 |
+
def show_live_session():
|
6 |
+
st.title("Live Session Recording")
|
7 |
+
|
8 |
+
# Session setup
|
9 |
+
if "recording" not in st.session_state:
|
10 |
+
st.session_state.recording = False
|
11 |
+
|
12 |
+
# Recording controls
|
13 |
+
col1, col2 = st.columns(2)
|
14 |
+
|
15 |
+
with col1:
|
16 |
+
if st.button("Start Recording"):
|
17 |
+
st.session_state.recording = True
|
18 |
+
|
19 |
+
with col2:
|
20 |
+
if st.button("Stop Recording"):
|
21 |
+
st.session_state.recording = False
|
22 |
+
|
23 |
+
# Recording interface
|
24 |
+
if st.session_state.recording:
|
25 |
+
audio_bytes = audio_recorder()
|
26 |
+
if audio_bytes:
|
27 |
+
st.audio(audio_bytes, format="audio/wav")
|
28 |
+
|
29 |
+
# Save recording
|
30 |
+
timestamp = time.strftime("%Y%m%d-%H%M%S")
|
31 |
+
filename = f"session_{timestamp}.wav"
|
32 |
+
with open(filename, "wb") as f:
|
33 |
+
f.write(audio_bytes)
|
34 |
+
|
35 |
+
# Process recording
|
36 |
+
analyze_session(audio_bytes)
|
37 |
+
|
38 |
+
def analyze_session(audio_bytes):
|
39 |
+
# Add your session analysis logic here
|
40 |
+
st.write("Processing session...")
|
41 |
+
# Implement real-time analysis using your MI prompts
|