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( "

HELLO HOW ARE YOU

", 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()