Ich beabsichtige, den Versand von E-Mails zu stoppen, wenn eine Benachrichtigung ertönt. oder was das Gleiche ist, machen Sie ein automatisches Klicken, wenn ein Ton vom PC selbst kommt.
Ich habe versucht, Python im Rahmen meiner Grundkenntnisse und mit der Hilfe eines Freundes zu verwenden, aber ich Ich weiß nicht, wie ich den spezifischen Sound in die „Sounddevice“-Bibliothek einfügen und das Skript auf meinem PC ausführen soll. Wenn uns jemand helfen kann, wären wir dankbar. Das Skript, das wir zum Laufen bringen möchten, sieht in etwa so aus:
Code: Select all
import sounddevice as sd
import numpy as np
import pyautogui
import time
# Volume threshold to detect sound
VOLUME_THRESHOLD = 0.5 # Adjust this value according to the alarm intensity
# Function to capture system audio
def monitor_audio():
print("Monitoring audio...")
def callback(indata, frames, time, status):
# Calculate the volume
volume_norm = np.linalg.norm(indata) * 10
print(f"Volumen: {volume_norm}") # show volume (opcional to calibrate)
if volume_norm > VOLUME_THRESHOLD:
print("Sound detected! Stop process.")
stop_automation()
exit(0) # Program ends
# Open an audio stream
with sd.InputStream(callback=callback):
while True:
time.sleep(0.1) # Small delay to reduce CPU usage
# Function to stop the automated process
def stop_automation():
# Simulate a click in the application area (adjusts the coordinates)
pyautogui.click(100, 100) # Change (100, 100) to the coordinates of the stop button
print("Automation stopped.")
# Start monitoring
monitor_audio()