test1 / app.py
arshtech's picture
Create app.py
43b7d70 verified
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()