Spaces:
Sleeping
Sleeping
Nico8800
commited on
Commit
·
e87f4b7
1
Parent(s):
61c21b1
add video transcribe and chat display
Browse files
app.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from moviepy.editor import AudioClip
|
| 3 |
-
import tempfile
|
| 4 |
-
import os
|
| 5 |
from st_audiorec import st_audiorec
|
|
|
|
|
|
|
| 6 |
|
| 7 |
st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
|
| 8 |
# Create two columns
|
|
@@ -11,22 +10,46 @@ col1, col2 = st.columns(2)
|
|
| 11 |
# First column containers
|
| 12 |
with col1:
|
| 13 |
st.subheader("Audio Recorder")
|
|
|
|
|
|
|
| 14 |
wav_audio_data = st_audiorec()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
st.subheader("LLM answering")
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
st.subheader("Movement Analysis")
|
| 20 |
-
# Add your content here
|
| 21 |
|
| 22 |
# Second column containers
|
| 23 |
with col2:
|
| 24 |
st.subheader("Sports Agenda")
|
| 25 |
-
# Add your content here
|
| 26 |
|
| 27 |
st.subheader("Video Analysis")
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
st.subheader("Graph Displayer")
|
| 32 |
-
# Add your content here
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
from st_audiorec import st_audiorec
|
| 3 |
+
from Modules.Speech2Text.transcribe import transcribe
|
| 4 |
+
import base64
|
| 5 |
|
| 6 |
st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
|
| 7 |
# Create two columns
|
|
|
|
| 10 |
# First column containers
|
| 11 |
with col1:
|
| 12 |
st.subheader("Audio Recorder")
|
| 13 |
+
recorded = False
|
| 14 |
+
temp_path = 'data/temp_audio/audio_file.wav'
|
| 15 |
wav_audio_data = st_audiorec()
|
| 16 |
+
if wav_audio_data is not None:
|
| 17 |
+
with open(temp_path, 'wb') as f:
|
| 18 |
+
# Write the audio data to the file
|
| 19 |
+
f.write(wav_audio_data)
|
| 20 |
+
instruction = transcribe(temp_path)
|
| 21 |
+
print(instruction)
|
| 22 |
+
recorded = True
|
| 23 |
+
|
| 24 |
|
| 25 |
st.subheader("LLM answering")
|
| 26 |
+
if recorded:
|
| 27 |
+
if "messages" not in st.session_state:
|
| 28 |
+
st.session_state.messages = []
|
| 29 |
+
for message in st.session_state.messages:
|
| 30 |
+
with st.chat_message(message["role"]):
|
| 31 |
+
st.markdown(message["content"])
|
| 32 |
+
|
| 33 |
+
st.session_state.messages.append({"role": "user", "content": instruction})
|
| 34 |
+
with st.chat_message("user"):
|
| 35 |
+
st.markdown(instruction)
|
| 36 |
+
|
| 37 |
+
with st.chat_message("assistant"):
|
| 38 |
+
# Build answer from LLM
|
| 39 |
+
response = " to be DEFINED - TO DO"
|
| 40 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 41 |
|
| 42 |
st.subheader("Movement Analysis")
|
|
|
|
| 43 |
|
| 44 |
# Second column containers
|
| 45 |
with col2:
|
| 46 |
st.subheader("Sports Agenda")
|
|
|
|
| 47 |
|
| 48 |
st.subheader("Video Analysis")
|
| 49 |
+
_left, mid, _right = st.columns(3)
|
| 50 |
+
with mid:
|
| 51 |
+
video_path = "./data/pose/squat_inference.mp4"
|
| 52 |
+
# Display the video
|
| 53 |
+
st.video(video_path)
|
| 54 |
|
| 55 |
st.subheader("Graph Displayer")
|
|
|