File size: 1,583 Bytes
43b7d70 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import streamlit as st
import cv2
import numpy as np
# -------------------------------
# Page Configuration
# -------------------------------
st.set_page_config(
page_title="Hand2Voice",
layout="wide"
)
st.title("π€ Hand2Voice")
st.subheader("Hand Gestures to Speech Interface")
# -------------------------------
# Layout: Two Columns
# -------------------------------
col1, col2 = st.columns(2)
# -------------------------------
# Camera Section (Left)
# -------------------------------
with col1:
st.markdown("### π· Camera Feed")
camera_placeholder = st.empty()
# -------------------------------
# Text & Speech Section (Right)
# -------------------------------
with col2:
st.markdown("### π Recognized Text")
text_placeholder = st.markdown(
"<h2 style='color:#333;'>HELLO <span style='background-color:yellow;'>HOW</span> ARE YOU</h2>",
unsafe_allow_html=True
)
st.markdown("### π Spoken Output")
st.info("Currently speaking: HOW")
# -------------------------------
# Status Bar
# -------------------------------
st.markdown("---")
st.success("Show your hand clearly in front of the camera")
# -------------------------------
# OpenCV Camera Loop
# -------------------------------
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, frame = cap.read()
if not ret:
st.error("Camera not accessible")
break
# Convert BGR to RGB for Streamlit
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Display frame
camera_placeholder.image(frame, channels="RGB")
cap.release()
|