Re: How to check whether audio bytes contain empty noise or actual voice/signal?

Liste des GroupesRevenir à cl python 
Sujet : Re: How to check whether audio bytes contain empty noise or actual voice/signal?
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 25. Oct 2024, 19:00:14
Autres entêtes
Organisation : Stefan Ram
Message-ID : <flatness-20241025175506@ram.dialup.fu-berlin.de>
References : 1 2
ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
marc nicole <mk1853387@gmail.com> wrote or quoted:
I hope this question is not very far from the main topic of this list, but
I have a hard time finding a way to check whether audio data samples are
containing empty noise or actual significant voice/noise.
The Spectral Flatness Measure (SFM), also called Wiener entropy, can
separate the wheat from the chaff when it comes to how noise-like
a signal is.

  You can also peep the envelope flatness (the flatness of the
  volume). If you've got some white noise that's not bringing much to
  the table, that envelope should be flatter than a pancake at IHOP.

import librosa
import numpy as np

def measure_volume_flatness(audio_path, sr=None):
    # Load the audio file
    y, sr = librosa.load(audio_path, sr=sr)
   
    # Calculate the root mean square (RMS) energy for each frame
    frame_length = 2048
    hop_length = 512
    rms = librosa.feature.rms(y=y, frame_length=frame_length, hop_length=hop_length)[0]
   
    # Calculate the dynamic range
    db_range = librosa.amplitude_to_db(np.max(rms)) - librosa.amplitude_to_db(np.min(rms))
   
    # Normalize the dynamic range to a 0-1 scale
    # Assuming a maximum possible dynamic range of 120 dB
    flatness = 1 - (db_range / 120)
   
    return flatness



Date Sujet#  Auteur
25 Oct 24 * How to check whether audio bytes contain empty noise or actual voice/signal?4marc nicole
25 Oct 24 +* Re: How to check whether audio bytes contain empty noise or actual voice/signal?2Stefan Ram
25 Oct 24 i`- Re: How to check whether audio bytes contain empty noise or actual voice/signal?1Stefan Ram
26 Oct 24 `- Re: How to check whether audio bytes contain empty noise or actual voice/signal?1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal