Python + пара библиотек — и ты уже можешь записывать звук с микрофона прямо в .wav файл. Всё просто:
sounddevice — захват аудиоscipy — для сохранения .wav файловpython
import sounddevice as sd
from scipy.io.wavfile import write
def record_voice(duration: int, filename: str = "recording.wav", sample_rate: int = 44100) -> None:
"""
Записывает звук с микрофона и сохраняет его в .wav файл.
:param duration: Время записи в секундах
:param filename: Название выходного файла
:param sample_rate: Частота дискретизации (по умолчанию 44100 Гц)
"""
print(f"🎙 Запись началась на {duration} секунд...")
audio_data = sd.rec(int(duration * sample_rate), samplerate=sample_rate, channels=2)
sd.wait()
write(filename, sample_rate, audio_data)
print(f"✅ Запись завершена. Файл сохранён как: {filename}")
if __name__ == "__main__":
try:
seconds = int(input("⏱️ Введите длительность записи в секундах: "))
record_voice(seconds)
except Exception as e:
print(f"❌ Ошибка: {e}")
Такой скрипт отлично подойдёт для проектов по обработке аудио, голосовым ассистентам или даже создания простого диктофона.
#python #code #soft
Please open Telegram to view this post
VIEW IN TELEGRAM
1👍31🔥12❤9😱1
Можно запугать коллег, троллить друзей или... ну вы поняли. Возможностей — миллион.
Установка простая, а для работы нужна всего одна фотография.
#python #soft #code
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
👍58🔥31❤17
Крутой open-source проект, который позволяет управлять устройствами с помощью движений глаз. Больше не нужно тянуться к клавиатуре – теперь всё решает взгляд!
Что умеет:
Где можно применить?
🔬 Эксперименты с интерфейсами будущего.
$ git clone https://github.com/NativeSensors/EyeGestures.git
$ cd EyeGestures
$ pip install -r requirements.txt
или
python3 -m pip install eyeGestures
Открытый код, документация и примеры использования.
Будущее уже здесь — открываем мир взглядом!
#soft #python #code
Please open Telegram to view this post
VIEW IN TELEGRAM
2🔥30❤12👍11
Как превратить тупое распознавание текста в умную систему, которая сама вытаскивает номера отслеживания, адреса, перевозчика и собирает всё в чистый JSON.
Python, нейросети, автоматизация складов и реальная экономия миллионов на ручной обработке.
#python #article #code
Please open Telegram to view this post
VIEW IN TELEGRAM
👍24❤7🔥7
Этот скрипт превращает твою вебку в систему распознавания лиц и глаз.
Установи OpenCV:
bash
$ pip install opencv-python
haarcascade_frontalface_default.xml
haarcascade_eye.xml
Код:
python
import cv2 as cv
def detect_faces_and_eyes():
"""
Detects faces and eyes in real-time using the webcam.
Press 'q' to exit the program.
"""
# Load the pre-trained classifiers for face and eye detection
face_cascade = cv.CascadeClassifier(r"..\libs\haarcascade_frontalface_default.xml")
eye_cascade = cv.CascadeClassifier(r"..\libs\haarcascade_eye.xml")
# Open the webcam
cap = cv.VideoCapture(0)
while cap.isOpened():
# Read a frame from the webcam
flag, img = cap.read()
# Convert the frame to grayscale for better performance
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# Detect faces in the frame
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=7)
# Detect eyes in the frame
eyes = eye_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=7)
# Draw rectangles around faces and eyes
for x, y, w, h in faces:
cv.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 1)
for a, b, c, d in eyes:
cv.rectangle(img, (a, b), (a + c, b + d), (255, 0, 0), 1)
# Display the resulting frame
cv.imshow("Face and Eye Detection", img)
# Check for the 'q' key to exit the program
key = cv.waitKey(1)
if key == ord("q"):
break
# Release the webcam and close all windows
cap.release()
cv.destroyAllWindows()
if __name__ == "__main__":
# Call the main function
detect_faces_and_eyes()
Сохрани — пригодится!
#python #soft #code
Please open Telegram to view this post
VIEW IN TELEGRAM
👍33🔥14❤7