Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,22 @@
|
|
1 |
import streamlit as st
|
2 |
-
import os
|
3 |
-
import time
|
4 |
-
import re
|
5 |
-
from openai import OpenAI
|
6 |
from streamlit_webrtc import webrtc_streamer, AudioProcessorBase
|
7 |
import av
|
8 |
import numpy as np
|
9 |
import tempfile
|
10 |
import soundfile as sf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# ------------------ App Configuration ------------------
|
13 |
st.set_page_config(page_title="Document AI Assistant", layout="wide")
|
@@ -60,14 +69,6 @@ with col1:
|
|
60 |
st.session_state.image_updated = False
|
61 |
|
62 |
# ------------------ Voice Input Processing ------------------
|
63 |
-
class AudioRecorder(AudioProcessorBase):
|
64 |
-
def __init__(self):
|
65 |
-
self.recorded_frames = []
|
66 |
-
|
67 |
-
def recv(self, frame: av.AudioFrame) -> av.AudioFrame:
|
68 |
-
self.recorded_frames.append(frame)
|
69 |
-
return frame
|
70 |
-
|
71 |
with col2:
|
72 |
st.markdown("### 🎙️ Voice Input (Optional)")
|
73 |
webrtc_ctx = webrtc_streamer(
|
@@ -163,4 +164,4 @@ with col2:
|
|
163 |
|
164 |
for message in reversed(st.session_state.messages):
|
165 |
role, content = message["role"], message["content"]
|
166 |
-
st.chat_message(role).write(content)
|
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
2 |
from streamlit_webrtc import webrtc_streamer, AudioProcessorBase
|
3 |
import av
|
4 |
import numpy as np
|
5 |
import tempfile
|
6 |
import soundfile as sf
|
7 |
+
import os
|
8 |
+
import time
|
9 |
+
import re
|
10 |
+
from openai import OpenAI
|
11 |
+
|
12 |
+
# ------------------ Audio Processor ------------------
|
13 |
+
class AudioRecorder(AudioProcessorBase):
|
14 |
+
def __init__(self):
|
15 |
+
self.recorded_frames = []
|
16 |
+
|
17 |
+
def recv(self, frame: av.AudioFrame) -> av.AudioFrame:
|
18 |
+
self.recorded_frames.append(frame)
|
19 |
+
return frame
|
20 |
|
21 |
# ------------------ App Configuration ------------------
|
22 |
st.set_page_config(page_title="Document AI Assistant", layout="wide")
|
|
|
69 |
st.session_state.image_updated = False
|
70 |
|
71 |
# ------------------ Voice Input Processing ------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
with col2:
|
73 |
st.markdown("### 🎙️ Voice Input (Optional)")
|
74 |
webrtc_ctx = webrtc_streamer(
|
|
|
164 |
|
165 |
for message in reversed(st.session_state.messages):
|
166 |
role, content = message["role"], message["content"]
|
167 |
+
st.chat_message(role).write(content)
|