Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
from datetime import datetime
|
4 |
import cv2
|
5 |
-
import
|
6 |
import wave
|
7 |
import imageio
|
8 |
import av
|
@@ -34,7 +34,7 @@ st.title("πΈποΈ Capture Craze")
|
|
34 |
# ποΈ Sidebar config like a spaceship control panel!
|
35 |
with st.sidebar:
|
36 |
st.header("ποΈπΈ Tune-Up Zone")
|
37 |
-
library_choice = st.selectbox("π Pick a Tool", ["OpenCV", "
|
38 |
resolution = st.select_slider("π Snap Size", options=["320x240", "640x480", "1280x720"], value="640x480")
|
39 |
fps = st.slider("β±οΈ Speed Snap", 1, 60, 30)
|
40 |
|
@@ -98,47 +98,41 @@ with st.expander("1οΈβ£ π· OpenCV Fiesta"):
|
|
98 |
st.image(file_path, caption="π Edge Lord")
|
99 |
cap.release()
|
100 |
|
101 |
-
# 2.
|
102 |
-
with st.expander("2οΈβ£ ποΈ
|
103 |
st.write("π Audio Ace: Sound control ninja!")
|
104 |
st.subheader("π₯ Top Tricks")
|
105 |
|
106 |
st.write("π€π©οΈ Record Jam")
|
107 |
-
if st.button("π΅ Grab Sound", key="
|
108 |
-
# π€π©οΈ Records like a storm-chasing bard! | ποΈ
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
p.terminate()
|
115 |
-
file_path = f"pyaudio_rec_{datetime.now().strftime('%Y%m%d_%H%M%S')}.wav"
|
116 |
with wave.open(file_path, 'wb') as wf:
|
117 |
wf.setnchannels(1)
|
118 |
-
wf.setsampwidth(
|
119 |
-
wf.setframerate(
|
120 |
-
wf.writeframes(
|
121 |
save_to_history("Audio", file_path)
|
122 |
st.audio(file_path)
|
123 |
|
124 |
-
st.write("
|
125 |
-
if st.button("π List
|
126 |
-
#
|
127 |
-
|
128 |
-
|
129 |
-
st.write("ποΈ Mic Squad:", devices)
|
130 |
-
p.terminate()
|
131 |
|
132 |
-
st.write("πΆπΎ
|
133 |
-
if st.button("π§ Quick
|
134 |
-
# πΆπΎ
|
135 |
-
|
136 |
-
|
137 |
-
data =
|
138 |
-
|
139 |
-
|
140 |
-
stream.close()
|
141 |
-
p.terminate()
|
142 |
|
143 |
# 3. ImageIO - πΌοΈ Pixel playtime!
|
144 |
with st.expander("3οΈβ£ πΉ ImageIO Bash"):
|
@@ -248,9 +242,8 @@ with st.expander("5οΈβ£ πΌ MoviePy Gala"):
|
|
248 |
cap.release()
|
249 |
file_path = f"moviepy_seq_{datetime.now().strftime('%Y%m%d_%H%M%S')}.mp4"
|
250 |
clip = mp.ImageSequenceClip(frames, fps=15)
|
251 |
-
clip.
|
252 |
-
save_to_history("Video
|
253 |
-
st.session_state['file_history'].append({"Timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "Type": "Video", "Path": file_path})
|
254 |
st.video(file_path)
|
255 |
|
256 |
st.write("ππ Size Snap")
|
|
|
2 |
import pandas as pd
|
3 |
from datetime import datetime
|
4 |
import cv2
|
5 |
+
import sounddevice as sd
|
6 |
import wave
|
7 |
import imageio
|
8 |
import av
|
|
|
34 |
# ποΈ Sidebar config like a spaceship control panel!
|
35 |
with st.sidebar:
|
36 |
st.header("ποΈπΈ Tune-Up Zone")
|
37 |
+
library_choice = st.selectbox("π Pick a Tool", ["OpenCV", "SoundDevice", "ImageIO", "PyAV", "MoviePy"])
|
38 |
resolution = st.select_slider("π Snap Size", options=["320x240", "640x480", "1280x720"], value="640x480")
|
39 |
fps = st.slider("β±οΈ Speed Snap", 1, 60, 30)
|
40 |
|
|
|
98 |
st.image(file_path, caption="π Edge Lord")
|
99 |
cap.release()
|
100 |
|
101 |
+
# 2. SoundDevice - ποΈ Soundwave showdown!
|
102 |
+
with st.expander("2οΈβ£ ποΈ SoundDevice Party"):
|
103 |
st.write("π Audio Ace: Sound control ninja!")
|
104 |
st.subheader("π₯ Top Tricks")
|
105 |
|
106 |
st.write("π€π©οΈ Record Jam")
|
107 |
+
if st.button("π΅ Grab Sound", key="sounddevice_1"):
|
108 |
+
# π€π©οΈ Records like a storm-chasing bard! | ποΈ sd.rec(44100) - Captures audio like thunder in a bottle!
|
109 |
+
fs = 44100
|
110 |
+
duration = 3 # seconds
|
111 |
+
recording = sd.rec(int(duration * fs), samplerate=fs, channels=1, dtype='int16')
|
112 |
+
sd.wait()
|
113 |
+
file_path = f"sounddevice_rec_{datetime.now().strftime('%Y%m%d_%H%M%S')}.wav"
|
|
|
|
|
114 |
with wave.open(file_path, 'wb') as wf:
|
115 |
wf.setnchannels(1)
|
116 |
+
wf.setsampwidth(2) # 16-bit
|
117 |
+
wf.setframerate(fs)
|
118 |
+
wf.writeframes(recording.tobytes())
|
119 |
save_to_history("Audio", file_path)
|
120 |
st.audio(file_path)
|
121 |
|
122 |
+
st.write("ππ‘ Device Spy")
|
123 |
+
if st.button("π List Gear", key="sounddevice_2"):
|
124 |
+
# ππ‘ Spies audio gear like a tech sleuth! | π‘ sd.query_devices() - Sniffs out sound toys like a pro!
|
125 |
+
devices = sd.query_devices()
|
126 |
+
st.write("ποΈ Gear Squad:", devices)
|
|
|
|
|
127 |
|
128 |
+
st.write("πΆπΎ Play Blast")
|
129 |
+
if st.button("π§ Quick Play", key="sounddevice_3"):
|
130 |
+
# πΆπΎ Blasts tunes faster than a DJ remix! | π΅ sd.play(data) - Drops beats like a party bomb!
|
131 |
+
fs = 44100
|
132 |
+
duration = 1
|
133 |
+
data = np.random.uniform(-1, 1, int(fs * duration)).astype(np.float32)
|
134 |
+
sd.play(data, fs)
|
135 |
+
st.write("π΅ Played a funky noise!")
|
|
|
|
|
136 |
|
137 |
# 3. ImageIO - πΌοΈ Pixel playtime!
|
138 |
with st.expander("3οΈβ£ πΉ ImageIO Bash"):
|
|
|
242 |
cap.release()
|
243 |
file_path = f"moviepy_seq_{datetime.now().strftime('%Y%m%d_%H%M%S')}.mp4"
|
244 |
clip = mp.ImageSequenceClip(frames, fps=15)
|
245 |
+
clip.write_videofile(file_path)
|
246 |
+
save_to_history("Video", file_path)
|
|
|
247 |
st.video(file_path)
|
248 |
|
249 |
st.write("ππ Size Snap")
|