1

My goal is to be able to detect a specific noise that comes through the speakers of a PC using Python. That means the following, in pseudo code:

  1. Sounds is being played out of the speakers, by applications such as games for example
  2. My "audio to detect" sound happens, and I want to detect that, and take an action

The specific sound I want to detect for example can be found here.

If I break that down, i believe I need two things:

  1. A way to sample the audio that is being streamed to an audio device -- perhaps something based on this? or potentially sounddevice - but I can't determine how to make this work by looking at their api?
  2. A way to compare each sample with my "audio to detect" sound file.

The detection does not need to be exact - it just needs to be close. For example there will be lots of other noises happening at the same time, so its more being able to detect the footprint of the "audio to detect" within the audio stream of a variety of sounds.

Having investigated this, I found technologies mentioned in this post on SO and also this interesting article on Chromaprint. The Chromaprint article uses fpcalc to generate fingerprints, but because my "audio to detect" is around 1 - 2 seconds, fpcalc can't generate the fingerprint. I need something which works across smaller timespaces.

My question is - can somebody help me with the two parts to my question:

  1. How do I sample the audio device on my PC using python
  2. How should I attempt this comparison (ideally with a little example)

Many thanks in advance.

RenegadeAndy
  • 5,440
  • 18
  • 70
  • 130
  • First, please only ask one question per post. Second, what you are looking for is called “audio fingerprinting”. Google should give you some good leads.m, you can then ask for help with here. – szatmary Nov 09 '19 at 03:20
  • OK @szatmary you got it. The first part of the question split out and asked here : https://stackoverflow.com/questions/58780206/using-sounddevice-how-can-i-sample-all-audio-being-sent-to-the-speakers-in-pytho please help – RenegadeAndy Nov 09 '19 at 14:27
  • Can you show us what you've tried so far? – Anil_M Nov 12 '19 at 18:07
  • For anyone who lands here, I haven't tested it, but [this answer](https://stackoverflow.com/a/52682780/435253) sounds like it'd work for samples that short. – ssokolow Mar 21 '21 at 09:29

0 Answers0