Ive seen other questions similar to this, but they all involve detecting audio and then recording. I'd like my microphone connected to my computer to always be recording, and any time audio is detected it runs another part of a script. What modules would I need? How would I do this? Im pretty sure this would involve seeing when the audio volume goes above a certain point and then activating the rest of the script, because obviously there will always be some sort of sound coming from the microphone.
This might help if you want them to say something and then if they say the right word or whatever run the script.
https://pypi.org/project/SpeechRecognition/
Related
Project Aim: Create a seat that when you sit on it, audio starts. When you leave, the audio stops. Next time someone sits down, the audio begins again. Each time it is a random track, different from the last.
Context: Outside with access to power
How it can work (I think): I’m wondering if it is possible with using a Raspberry Pi and PIR Sensor (plus some other bits and pieces?). Basically, when someone moves into the range of the PIR sensor, this event is detected and sends an input to a GPIO pin on the Pi. With the right script, this can then fire an event – e.g. play a random audio file from micro SD card. Does this sound correct/doable?
Help!: I believe its not too abstract an idea or function, that has probably been done before. But I just can’t seem to find exactly what I’m looking for, where someone has already written a script I can use/modify. So I’d love to know, do you think this idea is doable/achievable? And, where acatly do you recommend I can track down a pre-made script/instruction on making it a reality.
If you know someone who could write such a script, please do put me in contact.
Thanks!
This is actually not that hard to realize. You have to come up with an idea for a sensor that you can build into your chair, I would recommend just a simple one that works like a push button: when someone sits down, you got a connection the RasPi can recognize. After doing that make sure, your RaspberryPi has power, a GPIO connection to the sensor and speakers attached.
The Script is also quite simple and its structure would look like this:
import RPi.GPIO as GPIO
import simpleaudio # just as an example, was the first one I found online
sound = 'path/to/your/soundfile.wav'
def playSound(directory):
play = simpleaudio.WaveObject.from_wave_file(directory)
play.play()
try:
while True:
if GPIO.input(numberofyourgpio):
play_sound(sound)
except KeyboardInterrupt:
pass
Finally you can set this to start after booting the RaspberryPi and you will never have to care about it not being started anymore.
TL;DR- Python listens to live audio and reacts accordingly on the go.
I am a complete beginner to Python, this is my first idea i'd love to work on. So it all began with me "hacking" my LED strips i have connected to WiFi. I can easily switch their color by launching a file and make them do certain pattern one time (haven't tried repeated/infinite patterns). My goal is to make it listen to music played on computer (essentially listen to system sounds one could say) and analyze the low bands and depending on the intensity of them, change the LED colors. As example music plays and lights switch color on each beat.
I haven't tried anything so far.
Lights work completely fine as i enter custom RGB and brightness values.
Essentially, what I want to achieve is upon triggering, the previous two seconds and further audio should be recorded, until silence.
For this, of course, the microphone has to listen all the time and record to a circular buffer. Upon triggering, current audio shall be recorded until there is a long enough span of silence. In the end, both streams should be combined to a single audio file/stream.
Unfortunately, I can't seem to wrap my head around how to achieve this with pyaudio.
I would be great if you had some advice for me.
I'm wondering if there are libraries in Python for audio recording.
Ideally, I need to get a cross-platform solution, how can I record audio through Python.
Ideally, in order that in this library I can either pause with the ability to listen to the recorded fragment and remove it from the audio recording, or record several audio files and after the program work, glue it into 1 audio file.
If someone knows such a decision, I will be happy to receive help.
Thanks in advance!
I would look into python-sounddevice.
https://python-sounddevice.readthedocs.io/en/0.3.11/
It can record and play as well as convert your music into a numpy array if that every interested you. It is a python handler of the PortAudio which is cross-platform.
http://portaudio.com
I began learning Python a few days ago, and i was wondering about a practical use for a program.
Then i came up with the following: if my brother is in his room recording himself playing guitar, a led plugged to the usb and wired so it's outside his door lights up, and then i'll know he's recording and i'll take care not to make any noises.
The main questions are:
How Python can detect any recording going on in the system?
How would i interface with the usb so i can actually turn the led on?
to interact with USB, you can read this related question.
to detect recording, you will have to tell us on which operating system your program is intented to run (but i am not sure it is possible to detect that another application is recording)