Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You like to form new friendships and make new acquaintances.


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

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

1
Subject: Re: How to check whether audio bytes contain empty noise or actual voice/signal?
From: Thomas Passin
Newsgroups: comp.lang.python
Date: Sat, 26 Oct 2024 16:07 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: How to check whether audio bytes contain empty noise or actual
voice/signal?
Date: Sat, 26 Oct 2024 12:07:10 -0400
Lines: 57
Message-ID: <mailman.51.1729958836.4695.python-list@python.org>
References: <CAGJtH9TqEpGjQi+KYNrSV3+UtVO-jjFLK02N9MEA0uuQvr11qQ@mail.gmail.com>
<0cb64539-790f-40e8-818a-74e32bd476a0@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de 9BR5bHu1ho8UZ8CmKsFyRgLR4FzsHorcacpOFm/1V8gg==
Cancel-Lock: sha1:PwTzKMIBTD36NyqINcSFAZfjBXM= sha256:0LmqVQ0Yef0oClXDgy9WHVcEtPgVY7jX/HrDXEzPGsU=
Return-Path: <list1@tompassin.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tompassin.net header.i=@tompassin.net header.b=zP92sjT7;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.140
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.72; '*S*': 0.00; 'stream': 0.04;
'containing': 0.05; 'variable': 0.05; 'else.': 0.07; 'tests':
0.07; 'everywhere': 0.09; 'filled': 0.09; 'obviously': 0.09;
'1024': 0.16; 'artifacts': 0.16; 'mic': 0.16; 'noise': 0.16;
'noisy': 0.16; 'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 's/n': 0.16; 'sounds': 0.16;
'url:latest': 0.16; 'voices': 0.16; 'wrote:': 0.16; 'python':
0.16; 'libraries': 0.19; 'pm,': 0.19; 'to:addr:python-list': 0.20;
'list,': 0.24; 'actual': 0.25; 'follows:': 0.26; 'background':
0.28; 'example,': 0.28; 'header:User-Agent:1': 0.30;
'subject:How': 0.31; 'question': 0.32; 'empty': 0.32; 'python-
list': 0.32; 'received:10.0': 0.32; 'received:mailchannels.net':
0.32; 'received:relay.mailchannels.net': 0.32; 'signal': 0.32;
'transform': 0.32; 'but': 0.32; 'there': 0.33; 'header:In-Reply-
To:1': 0.34; 'possibly': 0.36; 'people': 0.36; 'main': 0.37;
'using': 0.37; "it's": 0.37; 'could': 0.37; 'hard': 0.37; 'way':
0.38; 'use': 0.39; 'finding': 0.39; 'received:100': 0.39;
'statistical': 0.40; 'want': 0.40; 'including': 0.60; 'skip:i 20':
0.62; 'format': 0.62; 'lower': 0.62; 'here': 0.63; 'less': 0.64;
'your': 0.64; 'url-ip:104.16/16': 0.65; 'numbers': 0.67; 'rate':
0.67; 'worked': 0.67; 'entire': 0.67; 'header:Received:6': 0.67;
'received:64': 0.68; 'right': 0.68; 'clear.': 0.69; 'collect':
0.69; 'enhance': 0.69; 'small,': 0.69; 'voice': 0.69; 'audio':
0.70; 'skip:f 30': 0.71; 'chance': 0.71; 'chain': 0.76; 'speech':
0.76; 'significant': 0.78; 'practical': 0.84; 'easy.': 0.84;
'frequency': 0.84; 'means,': 0.84; 'signals': 0.84; 'subject: \n
': 0.84; 'subject:voice': 0.84; 'vocal': 0.84; 'channels': 0.91;
'fool': 0.91; 'somebody': 0.91; 'tend': 0.91; 'aspects': 0.93
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1729958831; a=rsa-sha256;
cv=none;
b=KIv4cWo2eQYLul7U87gqNqKGfKMKr5XwUKO6sScEIosu7wyrhmeReBHVu2qurGT7tiV8uC
c9owsy3Iq2ZLq6yf2usRWQQ87Xq+2QRAzo/fcbgThTgdU3X1rlTICO1BnIlYVN+MNFSpdi
Gg3v7Bjr2M8FRKScyNyj68wt7ClgtpyogOFrj+3sVQ0KqtqLR+npT2mkkXu2uaGCiPb7fW
J56RfkS/duVB0yBQ7ECW0D/zp1ynV4PgjwNah41BYFihbglAFsjP4CUqGyT76OnBXhKZrF
r1VWTHdJI9VKgEtItUYFEE6X2QA17DqNWCJZahzwlJXc7ITTugxwWc/ZWlHT+Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1729958831;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=LwbaEiR8wpGnydn8b8O18LXYGL8KeVYP6BJ7aZ2im64=;
b=S96D0czKhl1yj/XhwfT+IVOf8Xg4xTJxMBxnFdRx7FBKIVzU793GUyFCgSdo7wZ8QnIl5v
uca7RqwVqLKffay73gO2bb5E1RbSRDuWyDFC+agw4gqpKr0NMN33KX+gV84QC+gubApo0s
IOk5RPvogrgLQbiplPniRtBI3ej7OoDL4ORCuTFOOzCPYF4Bw50cbCVmHPIUc86ZXFK4Td
A/GXqW11+BG8RboLmD/T6gnutWeg6ywu+IpyDeksnoeKmFf7nWJ+BwfZ0PkOCqe93kixZR
brq037bENRJRRg//RqxBspJHnltvGAjRAhwKNlshIFYL6qAPSDFOYUazx72p7g==
ARC-Authentication-Results: i=1; rspamd-7c89d756bb-sw796;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Cure-Cooperative: 558f6e405b97b4ff_1729958831311_220670376
X-MC-Loop-Signature: 1729958831311:223940129
X-MC-Ingress-Time: 1729958831311
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1729958831;
bh=LwbaEiR8wpGnydn8b8O18LXYGL8KeVYP6BJ7aZ2im64=;
h=Date:From:Subject:To:Content-Type:Content-Transfer-Encoding;
b=zP92sjT7A9aCRvWm11PhFJ5mGfESni0M6WcCsiAMNW2AdieG2HOgVB5RpQ+Kgwl6X
Hx8Kc6fE01hTFjzO+EFPPjMrceylb0b5TN/Xf5ADmiQtBpabGVDwQadLz0bZuAGyJZ
/CJQkcUCx54O+7E61iMd8PC1UazDu9GRZCgkAlVuXQcDocKbDF3EDMZ0N56c+lsscf
YO4rLwO7WcLKgir3AQEVcP+UGeQm86HOCq+auLY7IgEM60svy+KkI7KuBtQ8NjuSnC
JRedyoXYOyJAWNv6qB4BmbBfqpf3FCHkNol0YEZeMAdaoeCkJI/PlAYUqJF6XkAvr1
EjLyfRL3g58pA==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <CAGJtH9TqEpGjQi+KYNrSV3+UtVO-jjFLK02N9MEA0uuQvr11qQ@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <0cb64539-790f-40e8-818a-74e32bd476a0@tompassin.net>
X-Mailman-Original-References: <CAGJtH9TqEpGjQi+KYNrSV3+UtVO-jjFLK02N9MEA0uuQvr11qQ@mail.gmail.com>
View all headers

On 10/25/2024 12:25 PM, marc nicole via Python-list wrote:
> Hello Python fellows,
>
> 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.
>
> I am using PyAudio to collect the sound through my PC mic as follows:
>
> FRAMES_PER_BUFFER = 1024
> FORMAT = pyaudio.paInt16
> CHANNELS = 1
> RATE = 48000
> RECORD_SECONDS = 2import pyaudio
> audio = pyaudio.PyAudio()
> stream = audio.open(format=FORMAT,
> channels=CHANNELS,
> rate=RATE,
> input=True,
> frames_per_buffer=FRAMES_PER_BUFFER,
> input_device_index=2)
> data = stream.read(FRAMES_PER_BUFFER)
>
>
> I want to know whether or not data contains voice signals or empty sound,
> To note that the variable always contains bytes (empty or sound) if I print
> it.
>
> Is there an straightforward "easy way" to check whether data is filled with
> empty noise or that somebody has made noise/spoke?

It's not always so easy. The Fast Fourier Transform will be your
friend. The most straightforward way would be to do an autocorrelation
on the recorded interval, possibly with some pre-filtering to enhance
the typical vocal frequency range. If the data is only noise, the
autocorrelation will show a large signal at point 0 and only small,
obviously noisy numbers everywhere else. There are practical aspects
that make things less clear. For example, voices tend to be spiky and
erratic so you need to use small intervals to have a better chance of
getting an interval with a good S/N ratio, but small intervals will have
a lower signal to noise ratio.

Human speech is produced with various statistical regularities and these
can sometimes be detected with various means, including the autocorrelation.

You also will need to test-record your entire signal chain because it
might be producing artifacts that could fool some tests. And background
sounds could fool some tests as well.

Here are some Python libraries that could be very helpful:

librosa (I have not worked with this but it sounds right on target);
scipy.signal (I have used scypi but not specifically scipy.signal);
python-speech-features (another I haven't used);
https://python-speech-features.readthedocs.io/en/latest/

Other people will know of others.

1

rocksolid light 0.9.8
clearnet tor