Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -148,36 +148,61 @@ def get_transcript():
|
|
148 |
st.error(f"Error getting transcript: {str(e)}")
|
149 |
return None
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
def integrate_speech_component():
|
152 |
-
"""Integrate speech component with
|
153 |
if "voice_transcript" not in st.session_state:
|
154 |
st.session_state.voice_transcript = ""
|
155 |
if "last_update" not in st.session_state:
|
156 |
st.session_state.last_update = time.time()
|
|
|
|
|
|
|
157 |
|
158 |
# Create the speech component
|
159 |
create_speech_component()
|
160 |
|
161 |
# Create placeholder for transcript display
|
162 |
transcript_container = st.empty()
|
|
|
163 |
|
164 |
# Check for updates every 10 seconds
|
165 |
-
|
|
|
166 |
new_transcript = get_transcript()
|
|
|
|
|
|
|
167 |
if new_transcript and new_transcript != st.session_state.voice_transcript:
|
|
|
|
|
|
|
|
|
|
|
168 |
st.session_state.voice_transcript = new_transcript
|
169 |
-
st.session_state.last_update =
|
170 |
|
171 |
# Display current transcript
|
172 |
transcript_container.text_area(
|
173 |
"Voice Transcript:",
|
174 |
value=st.session_state.voice_transcript,
|
175 |
height=100,
|
176 |
-
key="
|
177 |
)
|
178 |
|
|
|
|
|
|
|
179 |
return st.session_state.voice_transcript
|
180 |
|
|
|
|
|
|
|
181 |
|
182 |
|
183 |
|
|
|
148 |
st.error(f"Error getting transcript: {str(e)}")
|
149 |
return None
|
150 |
|
151 |
+
|
152 |
+
|
153 |
+
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
def integrate_speech_component():
|
158 |
+
"""Integrate speech component with debug output."""
|
159 |
if "voice_transcript" not in st.session_state:
|
160 |
st.session_state.voice_transcript = ""
|
161 |
if "last_update" not in st.session_state:
|
162 |
st.session_state.last_update = time.time()
|
163 |
+
|
164 |
+
# Add debug toggle
|
165 |
+
show_debug = st.checkbox("Show Debug Info")
|
166 |
|
167 |
# Create the speech component
|
168 |
create_speech_component()
|
169 |
|
170 |
# Create placeholder for transcript display
|
171 |
transcript_container = st.empty()
|
172 |
+
debug_container = st.empty()
|
173 |
|
174 |
# Check for updates every 10 seconds
|
175 |
+
current_time = time.time()
|
176 |
+
if current_time - st.session_state.last_update >= 10:
|
177 |
new_transcript = get_transcript()
|
178 |
+
if show_debug:
|
179 |
+
debug_container.write(f"Debug: Checking for updates... Got: {new_transcript}")
|
180 |
+
|
181 |
if new_transcript and new_transcript != st.session_state.voice_transcript:
|
182 |
+
if show_debug:
|
183 |
+
st.write("Debug: Updating transcript")
|
184 |
+
st.write(f"Old: {st.session_state.voice_transcript}")
|
185 |
+
st.write(f"New: {new_transcript}")
|
186 |
+
|
187 |
st.session_state.voice_transcript = new_transcript
|
188 |
+
st.session_state.last_update = current_time
|
189 |
|
190 |
# Display current transcript
|
191 |
transcript_container.text_area(
|
192 |
"Voice Transcript:",
|
193 |
value=st.session_state.voice_transcript,
|
194 |
height=100,
|
195 |
+
key=f"transcript_display_{int(current_time)}" # Force refresh
|
196 |
)
|
197 |
|
198 |
+
if show_debug:
|
199 |
+
st.write("Session State:", st.session_state)
|
200 |
+
|
201 |
return st.session_state.voice_transcript
|
202 |
|
203 |
+
|
204 |
+
|
205 |
+
|
206 |
|
207 |
|
208 |
|