# Audio comparing

**URL:** <https://discourse.nodered.org/t/audio-comparing/24218>\
**Category:** General\
**Created:** [4 April 2020 14:17 UTC](https://discourse.nodered.org/t/audio-comparing/24218 "2020-04-04T14:17:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpaolojo](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cpaolojo](https://discourse.nodered.org/u/cpaolojo)\
**Post date:** [4 April 2020 14:17 UTC](https://discourse.nodered.org/t/audio-comparing/24218/1 "2020-04-04T14:17:48Z")

</div>

Hi all,  
I have a question for you.  
I would realize a project able to compare the MIC input with an audio file used as reference.  
Do you have any idea? Any project or node to suggest me?  
Thanks in advance  
Paolo

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 April 2020 14:49 UTC](https://discourse.nodered.org/t/audio-comparing/24218/2 "2020-04-04T14:49:21Z")

</div>

Hi Paulo,  
Can you explain a bit more in detzal how you want to use this, with an example use case.  
Bart

---

<div class="post-metadata">

**Author:** ![cpaolojo](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cpaolojo](https://discourse.nodered.org/u/cpaolojo)\
**Post date:** [4 April 2020 15:45 UTC](https://discourse.nodered.org/t/audio-comparing/24218/3 "2020-04-04T15:45:11Z")

</div>

In few words raspberry shall memorize a sound (reference sound) and should be able to understand when this reference sound comes in MIC input

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 April 2020 17:41 UTC](https://discourse.nodered.org/t/audio-comparing/24218/4 "2020-04-04T17:41:34Z")

</div>

This Stackoverflow discussion explains how to get started with this (but seems not an easy task):

> <https://stackoverflow.com/questions/45785231/compare-sound-between-source-and-microphone-in-javascript>

Not sure whether your use case can only be solved by comparing audio samples. Perhaps you can solve it using other techniques, like e.g. speech recognition or sound classification or ...

Based on your "_few words_", unfortunately I won't be able to assist you further.

---

<div class="post-metadata">

**Author:** ![cpaolojo](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cpaolojo](https://discourse.nodered.org/u/cpaolojo)\
**Post date:** [4 April 2020 20:44 UTC](https://discourse.nodered.org/t/audio-comparing/24218/5 "2020-04-04T20:44:46Z")

</div>

Hi Bart, thamks for your replay.  
Sorry for the project poor description but, this is due to a poor experience in projects based on audio management.  
As i've tried to describe, the aim of my project is to convert an 'audio alert' to a visual one. To do this, first of all, i have to know what is the 'audio alert' (for example doorbell ring) i have to convert. For this reason RPi during a 'self learning' procedure shall listen the 'audio alert' (doorbell ring) and analyze it in order to store it as reference audio.  
Then, RPi, thanks to its MIC input, shall analyze all the audio input and compare them with the reference one. When comparison confirm the equivalence between the audio coming from MIC and the reference one, RPI shall active a digital output.  
Is it now more clear?  
Thanks for your support  
Paolo

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 April 2020 21:57 UTC](https://discourse.nodered.org/t/audio-comparing/24218/6 "2020-04-04T21:57:49Z")

</div>

> [@cpaolojo](#):
>
> for example doorbell ring

Hi Paolo,

Now much clearer. Thanks!  
Very interesting question, but I'm not an audio expert unfortunately.  
But we will try to assist you, and hopefully someone with more knowledge joins our discussion...

You will need some acoustic signal recognition, as you can see e.g. in this [article](https://dev.to/devdevcharlie/acoustic-activity-recognition-in-javascript-2go4). If I'm not mistaken you need _ **sound classification** _:. For example Google has - based on youtube movies - created a collection (see [AudioSet](https://research.google.com/audioset/)) of 2,084,320 audio samples of 632 types of audio sounds. They have used this collection to create a training model for their Tensorflow deep learning library. Although when you look at the [list](https://research.google.com/audioset/ontology/index.html) of the audio sounds that they can recognize, then I don't think they support a real doorbell sound (instead they can recognize other types of [bell](https://research.google.com/audioset/ontology/bell_2.html) sounds).

You could have a look at those links:

- [node-red-contrib-max-audio-classifier - npm](https://www.npmjs.com/package/node-red-contrib-max-audio-classifier)
- [Identify sounds in short audio clips (flow) - Node-RED](https://flows.nodered.org/flow/eaef0871ea62242d32f370d9352ee4ca)
- [MAX Audio Classifier Demo (flow) - Node-RED](https://flows.nodered.org/flow/cd64d4bb78a7984f15b3cfa5ac97ae55)
- You could contact the author of the [node-red-contrib-tf-model](https://github.com/yhwang/node-red-contrib-tf-model) node, since he seems to be very experienced in this topic. Perhaps he knows if this is possible somehow.
- IBM offers also an open-source audio classifier [service](https://github.com/IBM/MAX-Audio-Classifier), which can easily be installed locally as a Docker container (but then you need to know a bit about Docker ...).

Please discuss here afterwards your questions, experiences, ...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [5 April 2020 08:37 UTC](https://discourse.nodered.org/t/audio-comparing/24218/7 "2020-04-05T08:37:08Z")

</div>

Morning Paolo,

Just found this [tutorial](https://codelabs.developers.google.com/codelabs/tensorflowjs-audio-codelab/index.html#0): it shows how to use the tensorflow.js library to _ **recognize custom sounds** _:

1. You train the system by giving it a couple of audio fragments of your doorbell sound (which you can capture from your microphone).
2. Once the system is trained, it should be able to recognize your doorbell.

While the tutorial is based on tensorflow.js in the browser, the nodes (see the links in my previous post) also use tensorflow.js. So I assume tensorflow.js is the way to go...

Hopefully someone can help us here, to explain how we can easily train the audio classification in Node-RED.

---

<div class="post-metadata">

**Author:** ![cpaolojo](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cpaolojo](https://discourse.nodered.org/u/cpaolojo)\
**Post date:** [5 April 2020 15:23 UTC](https://discourse.nodered.org/t/audio-comparing/24218/8 "2020-04-05T15:23:34Z")

</div>

Thanks a lot Bart.  
I tested the tutorial you suggested me! Wonderful, it works fine.  
It gives great functionalities! I'm thinking about the possibility to make easier my project: in other words, my idea is compare two sounds in terms of peak amplitude, peak to peak amplitude, rms.  
I know, this strategy is less accurate than the one explained in your tutorial, but, it could make sense as first step.  
Now the question is: does a node able to analyse a sound (in terms described above) already exist?  
Anyone could help me?  
Thanks my friends

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 June 2020 15:23 UTC](https://discourse.nodered.org/t/audio-comparing/24218/9 "2020-06-04T15:23:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
