Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,6 @@ from PIL import Image
|
|
5 |
from io import BytesIO
|
6 |
import os
|
7 |
from elevenlabs.client import ElevenLabs
|
8 |
-
import requests
|
9 |
-
import cv2
|
10 |
-
import numpy as np
|
11 |
|
12 |
# Set API keys as environment variables
|
13 |
os.environ["TOGETHER_API_KEY"] = st.secrets['together_api']
|
@@ -72,7 +69,7 @@ def tts(text):
|
|
72 |
f.write(chunk)
|
73 |
|
74 |
# Play the audio in Streamlit
|
75 |
-
st.audio(audio_file_path, format="audio/mp3",
|
76 |
except Exception as e:
|
77 |
st.error(f"Error generating speech: {e}")
|
78 |
|
@@ -129,38 +126,24 @@ st.sidebar.markdown("## About")
|
|
129 |
st.sidebar.markdown("This app uses advanced AI to describe what it sees through your camera in real-time.")
|
130 |
st.sidebar.markdown("Powered by [Together AI](https://together.ai) and Streamlit.")
|
131 |
|
132 |
-
#
|
133 |
-
st.
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
#
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
# Get and display the description
|
155 |
-
with st.spinner('π Analyzing the image...'):
|
156 |
-
description = get_image_description(img)
|
157 |
-
st.success('β
Analysis complete!')
|
158 |
-
st.markdown("### AI Description:")
|
159 |
-
st.write(description)
|
160 |
-
|
161 |
-
# Convert description to speech and play it
|
162 |
-
tts(description)
|
163 |
-
else:
|
164 |
-
st.error("Failed to fetch image from IP Webcam.")
|
165 |
-
except Exception as e:
|
166 |
-
st.error(f"Error capturing image: {e}")
|
|
|
5 |
from io import BytesIO
|
6 |
import os
|
7 |
from elevenlabs.client import ElevenLabs
|
|
|
|
|
|
|
8 |
|
9 |
# Set API keys as environment variables
|
10 |
os.environ["TOGETHER_API_KEY"] = st.secrets['together_api']
|
|
|
69 |
f.write(chunk)
|
70 |
|
71 |
# Play the audio in Streamlit
|
72 |
+
st.audio(audio_file_path, format="audio/mp3",autoplay=True)
|
73 |
except Exception as e:
|
74 |
st.error(f"Error generating speech: {e}")
|
75 |
|
|
|
126 |
st.sidebar.markdown("This app uses advanced AI to describe what it sees through your camera in real-time.")
|
127 |
st.sidebar.markdown("Powered by [Together AI](https://together.ai) and Streamlit.")
|
128 |
|
129 |
+
# Access the camera
|
130 |
+
img_file_buffer = st.camera_input("Take a picture")
|
131 |
+
|
132 |
+
if img_file_buffer is not None:
|
133 |
+
|
134 |
+
# Convert the image file buffer to a PIL Image
|
135 |
+
img = Image.open(img_file_buffer)
|
136 |
+
|
137 |
+
# Display the captured image
|
138 |
+
st.image(img, caption='Captured Image', width=300)
|
139 |
+
|
140 |
+
# Get and display the description
|
141 |
+
with st.spinner('π Analyzing the image...'):
|
142 |
+
description = get_image_description(img)
|
143 |
+
st.success('β
Analysis complete!')
|
144 |
+
st.markdown("### AI Description:")
|
145 |
+
st.write(description)
|
146 |
+
|
147 |
+
# Convert description to speech and play it
|
148 |
+
|
149 |
+
tts(description)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|