masadonline commited on
Commit
460b753
·
verified ·
1 Parent(s): cc78e03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -18
app.py CHANGED
@@ -54,24 +54,39 @@ def find_image_path(name):
54
  def display_sign_language(english_text):
55
  st.markdown("### 👐 Sign Language Representation")
56
 
57
- for word in english_text.split():
58
- st.markdown(f"**{word}**")
59
- for idx, char in enumerate(word):
60
- if char.isalpha():
61
- char_img_path = find_image_path(char.lower())
62
- if char_img_path:
63
- st.image(char_img_path, caption=char.upper(), width=80)
64
- else:
65
- st.warning(f"Missing image for: {char.upper()}")
66
- elif char == " ":
67
- space_img = find_image_path("space")
68
- if space_img:
69
- st.image(space_img, caption="SPACE", width=40)
70
-
71
- # Add space image between words
72
- space_img = find_image_path("space")
73
- if space_img:
74
- st.image(space_img, caption="SPACE", width=40)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  # --- Streamlit UI ---
77
  urdu_text = st.text_area("📝 Enter Urdu Text", height=150)
 
54
  def display_sign_language(english_text):
55
  st.markdown("### 👐 Sign Language Representation")
56
 
57
+ current_word = []
58
+ for char in english_text:
59
+ if char.isalpha():
60
+ current_word.append(char)
61
+ elif char == " ":
62
+ # Display current word vertically
63
+ if current_word:
64
+ st.markdown(f"**{''.join(current_word)}**")
65
+ for c in current_word:
66
+ img_path = find_image_path(c.lower())
67
+ if img_path:
68
+ st.image(img_path, caption=c.upper(), width=80)
69
+ else:
70
+ st.warning(f"Missing image for: {c.upper()}")
71
+ current_word = []
72
+
73
+ # Show space image
74
+ space_img = find_image_path("space")
75
+ if space_img:
76
+ st.image(space_img, caption="SPACE", width=40)
77
+ else:
78
+ continue # Skip punctuation
79
+
80
+ # Handle last word if any
81
+ if current_word:
82
+ st.markdown(f"**{''.join(current_word)}**")
83
+ for c in current_word:
84
+ img_path = find_image_path(c.lower())
85
+ if img_path:
86
+ st.image(img_path, caption=c.upper(), width=80)
87
+ else:
88
+ st.warning(f"Missing image for: {c.upper()}")
89
+
90
 
91
  # --- Streamlit UI ---
92
  urdu_text = st.text_area("📝 Enter Urdu Text", height=150)