Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

* joeyh installs debian using only his big toe, for a change of pace -- in #debian-boot


devel / comp.lang.python / RE: Automatic Gain Control in Python?

SubjectAuthor
o RE: Automatic Gain Control in Python?Steve GS

1
RE: Automatic Gain Control in Python?

<mailman.508.1653849172.20749.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18416&group=comp.lang.python#18416

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Groni...@SGA.Ninja (Steve GS)
Newsgroups: comp.lang.python
Subject: RE: Automatic Gain Control in Python?
Date: Sun, 29 May 2022 11:32:28 -0400
Lines: 407
Message-ID: <mailman.508.1653849172.20749.python-list@python.org>
References: <013801d872d9$f8d13700$ea73a500$@SGA.Ninja>
<f167855f-40fe-5f6c-f5ae-ef66b07b46f8@Damon-Family.org>
<015301d872f1$6bf9afc0$43ed0f40$@SGA.Ninja>
<d5893c0a-12a4-b847-4b62-0b97ef1069ae@Damon-Family.org>
<017501d8731a$43882750$ca9875f0$@SGA.Ninja>
<cbb2c13b-2bcf-31f8-bff7-c2b294bc4ede@Damon-Family.org>
<003601d8736d$5cd3e610$167bb230$@SGA.Ninja>
<5148EB0B-A337-4E06-A2B6-FBDDEF0CA594@schollnick.net>
<004f01d87371$4e579150$eb06b3f0$@SGA.Ninja>
Mime-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de TbomgZHQ5zONg/p1yc2WrAMZXsHWphL9CJ6FJiTZzqDg==
Return-Path: <Gronicus@SGA.Ninja>
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=sga.ninja header.i=@sga.ninja header.b=g9o38M/t;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python?': 0.03; 'knows':
0.04; 'stream': 0.04; '2022': 0.05; 'file?': 0.05; 'programming.':
0.05; 'skip:= 10': 0.05; 'assumes': 0.07; 'correct?': 0.07;
'skip:\xc2 30': 0.07; 'suggestion': 0.07; 'task.': 0.07;
'url:courses': 0.07; 'apparently': 0.09; 'audio,': 0.09;
'browser,': 0.09; 'cc:addr:python-list': 0.09; 'controlled': 0.09;
'damon': 0.09; 'describe': 0.09; 'design?': 0.09; 'footnote:':
0.09; 'fundamental': 0.09; 'ok,': 0.09; 'podcast': 0.09;
"shouldn't": 0.09; 'so?': 0.09; 'solving': 0.09; 'timing': 0.09;
'url-ip:13.107.213.67/32': 0.09; 'url-ip:13.107.213/24': 0.09;
'url-ip:13.107.246.67/32': 0.09; 'url-ip:13.107.246/24': 0.09;
'subject:Python': 0.12; 'talks': 0.14; 'url:mailman': 0.15;
'announce': 0.15; 'problem.': 0.15; 'that.': 0.15; '"get': 0.16;
'2022,': 0.16; 'another.': 0.16; 'automation.': 0.16; 'basic,':
0.16; 'broadcast': 0.16; 'c++,': 0.16; 'computers': 0.16;
'confused': 0.16; 'directly,': 0.16; 'edge.': 0.16; 'faster,':
0.16; 'fetch': 0.16; 'from:addr:gronicus': 0.16;
'from:addr:sga.ninja': 0.16; 'hour.': 0.16; 'invested': 0.16;
'invoke': 0.16; 'it\xe2\x80\x99ll': 0.16; 'lesson': 0.16;
'level,': 0.16; 'message-id:@SGA.Ninja': 0.16; 'okay,': 0.16;
'portions': 0.16; 'received:floathosting.com': 0.16;
'received:mars.floathosting.com': 0.16; 'sees': 0.16; 'these.':
0.16; 'url:repositories': 0.16; 'variance': 0.16; 'violation':
0.16; 'voices': 0.16; 'volume,': 0.16; 'want,': 0.16; 'weekend.':
0.16; 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16; 'reached':
0.17; 'speaker': 0.17; 'code.': 0.17; 'probably': 0.17; 'calls':
0.19; 'figure': 0.19; 'pm,': 0.19; 'url': 0.19;
'cc:addr:python.org': 0.20; 'to:addr:python-list': 0.20; 'option':
0.20; 'input': 0.21; 'languages': 0.22; 'maybe': 0.22; 'code':
0.23; 'cc:2**1': 0.23; 'command': 0.23; 'lines': 0.23; 'school':
0.24; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'python,': 0.25; 'url:listinfo': 0.25;
'cannot': 0.25; 'programming': 0.25; 'url-ip:188.166/16': 0.25;
'seems': 0.26; 'again,': 0.26; 'attack': 0.26; 'party': 0.26;
'pattern': 0.26; 'recording': 0.26; 'task': 0.26; 'visual': 0.26;
'analyze': 0.75; 'records': 0.75; 'sources': 0.75; '8bit%:100':
0.76; 'finds': 0.76; '450': 0.76; 'handles': 0.76; 'speech': 0.76;
'sent:': 0.78; 'highly': 0.78; 'discovered': 0.80; '3rd': 0.81;
'monitor': 0.81; 'industry': 0.81; 'editing': 0.84; '"user"':
0.84; 'base,': 0.84; 'blast.': 0.84; 'capturing': 0.84; 'device,':
0.84; 'email name:&lt;python-list': 0.84; 'garden.': 0.84; 'grew':
0.84; 'levels.': 0.84; 'quality,': 0.84; 'recordings': 0.84;
'saturday,': 0.84; 'station': 0.84; 'caused': 0.86; 'assembly,':
0.91; 'channels': 0.91; 'me:': 0.91; 'plays': 0.91; 'question?':
0.91; 'replay': 0.91; 'retained': 0.91; 'said.': 0.91; 'tend':
0.91
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sga.ninja;
s=default;
h=Content-Type:MIME-Version:Message-ID:Date:Subject:In-Reply-To:
References:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
List-Post:List-Owner:List-Archive;
bh=5oSqx87h90uePKyrBRzHhrRYSOoEk/1VOAEaGz7lZO0=; b=g9o38M/t+YRpenwKs77VvNNWfi
zR163YucAxu2+fRnl9mIBa0Bn0kjlaeO2CQI2c0vzDjOcxFe913hykfp0gtj53tB3tHBfWJPSfmLY
6k8C6n+VhdRoHpJpFVddLsggg8/QcLfiTaZzJlFFCnPFY1RnVxPsvnU1rQOlq8GLWqZtBKVoJIB0U
d8plEiaXP2DyUfzk1kIir0Ucp83D4tkbhswXxpCXCSX/gcg7C6KkGWl+6n/NNvLrUYuekmKm5pWZ1
YaKaQBjoouoV/ezNOO5p5bd5xCP9WcXozOSninGqVnDYMFHbP4oGvtxpawuwcNs7gtwRTWG04bXW/
O0WTiCFQ==;
In-Reply-To: <5148EB0B-A337-4E06-A2B6-FBDDEF0CA594@schollnick.net>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQIdyvKawx2xMjKZNRb1MOl52t2tqwJSAGyvAmO85GECCmSigAJLan9PAP9CeXQB5sJbVQF9HOKVrD/VPaA=
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - mars.floathosting.com
X-AntiAbuse: Original Domain - python.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - SGA.Ninja
X-Get-Message-Sender-Via: mars.floathosting.com: authenticated_id:
gronicus@sga.ninja
X-Authenticated-Sender: mars.floathosting.com: gronicus@sga.ninja
X-Source:
X-Source-Args:
X-Source-Dir:
X-Mailman-Approved-At: Sun, 29 May 2022 14:32:51 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <004f01d87371$4e579150$eb06b3f0$@SGA.Ninja>
X-Mailman-Original-References: <013801d872d9$f8d13700$ea73a500$@SGA.Ninja>
<f167855f-40fe-5f6c-f5ae-ef66b07b46f8@Damon-Family.org>
<015301d872f1$6bf9afc0$43ed0f40$@SGA.Ninja>
<d5893c0a-12a4-b847-4b62-0b97ef1069ae@Damon-Family.org>
<017501d8731a$43882750$ca9875f0$@SGA.Ninja>
<cbb2c13b-2bcf-31f8-bff7-c2b294bc4ede@Damon-Family.org>
<003601d8736d$5cd3e610$167bb230$@SGA.Ninja>
<5148EB0B-A337-4E06-A2B6-FBDDEF0CA594@schollnick.net>
 by: Steve GS - Sun, 29 May 2022 15:32 UTC

No, not a digital file. I am playing the podcast/broadcast live to the community using a separate network of smart speakers (Amazon Echo). Commands are being sent hourly through a speaker to the SS from an excel program. I want to monitor the audio level between the line-out of the SS and the input to another computer which then records the audio using Audacity for a single replay during the week.

I think my first post should have started “Fasten your seat belts, it is going to be a bumpy night…)

Genie: You have three wishes.

Me: I wish I had more wishes.
Genie: You cannot wish for more wishes.
Me: I wish I could.

From: Benjamin Schollnick <bschollnick@schollnick.net>
Sent: Sunday, May 29, 2022 11:18 AM
To: Steve GS <Gronicus@SGA.Ninja>
Cc: Richard Damon <Richard@Damon-Family.org>; Python <python-list@python.org>
Subject: Re: Automatic Gain Control in Python?

Okay, you are capturing the audio stream as a digital file somewhere, correct?

Why not just right a 3rd party package to normalize the audio levels in the digital file? It’ll be faster, and probably easier than trying to do it in real time…

eg. https://campus.datacamp.com/courses/spoken-language-processing-in-python/manipulating-audio-files-with-pydub?ex=8

Normalizing an audio file with PyDub

Sometimes you'll have audio files where the speech is loud in some portions and quiet in others. Having this variance in volume can hinder transcription.

Luckily, PyDub's effects module has a function called normalize() which finds the maximum volume of an AudioSegment, then adjusts the rest of the AudioSegment to be in proportion. This means the quiet parts will get a volume boost.

You can listen to an example of an audio file which starts as loud then goes quiet, loud_then_quiet.wav, <https://assets.datacamp.com/production/repositories/4637/datasets/9251c751d3efccf781f3e189d68b37c8d22be9ca/ex3_datacamp_loud_then_quiet.wav> here.

In this exercise, you'll use normalize() to normalize the volume of our file, making it sound <https://assets.datacamp.com/production/repositories/4637/datasets/f0c1ba35ff99f07df8cfeee810c7b12118d9cd0f/ex3_datamcamp_normalized_loud_quiet.wav> more like this.

or

https://stackoverflow.com/questions/57925304/how-to-normalize-a-raw-audio-file-with-python

- Benjamin

On May 29, 2022, at 11:04 AM, Steve GS <Gronicus@SGA.Ninja <mailto:Gronicus@SGA.Ninja> > wrote:

>From your description, your fundamental problem is you are trying to automatically "control" things that weren't designed to be automatically controlled in the way you are attempting.

How so? I am sending commands to a smart speaker and it plays podcasts and broadcasts.
How is this a violation of SS design?

==================

The smart speaker assumes the "user" will adjust the volume either with the controls or with verbal commands, So things will be a bit "clunky" in your results as you command the smart speaker volume level.

So, you want me to sit here for every hour of the weekend and monitor the audio levels for a result that will get, at best, one replay when I believe it can be automated.

==================

Yes, you have an automated system that does most of what you want, but it is based on pieces not designed to be automated in this way, and you are running into the limitations caused by that.

Again, what limitations of the SS am I violating? It is designed to receive commands and play the audio.
Also, what makes you think that you know how my program is based?

==================

Yes, you could split the aux-out to bring it into another computer to listen to the sound level, and then using a sound input package get samples of what is playing, and analyze that data to get an average volume, and then issues the command to adjust the volume level.

Hmmm, is that not my original question? Are you suggesting to monitor the audio, sense it for volume changes and apply those changes to the original audio? One thing that may have to happen is a timed-delay to all for the AGC to work. This may require a correlation circuit.

=================

What you seem to be missing is that you could get the podcasts from a browser, and all a browser is is a program. It isn't that much work to write a rudimentary browser in python, especially if you don't actually need to display the results to a user, but are only trying to automate a particular task.

Writing my own browser in Python might work. Do you have a sample one that I could twerk to fit my needs?
I would have to be able to invoke it and an hour later devoke it least I end up with multiple audio channels playing.

Either way, I would still need an AGC program which was my original question.

==================

You seem to feel strongly invested in your current code base, which is understandable, but it seems you have reached a point where you don't want to live with the limitations CAUSED by that system.

The changes in volume are not CAUSED by my program. The want to fix them is a new development to improve the product. The volume fluctuations are causes, or neglections, by the engineers at the sources of podcasts and broadcasts.

Yes, there is likely a way to tack on another layer of "stuff" to adjust for this issue, but it likely is going to require some real programming.

It may well be the design I am suggesting, of writing a program to fetch the podcast and save it requires a bit more work to get to the level you currently are at, but the results are a system that is actually designed to be controlled by automation. Maybe it is beyond you ability, but then so might the programming to get the volume.

"Real programming"?, REAL PROGRAMMING? Well at this I have to say "Well duh". I have more than 40 years of programming in languages including assembly, Pascal, C, C++, BASIC, Visual BASIC, COBOL, VBA and Python for starters. I even dipped into AT&T's SNOBAL. Starting in the mid-80s, I taught Visual BASIC and VBA for 15 years in high school and at the University level.

I have 2000 lines of code of Python that helped me to bring my A1c reading from 9.0 to 6.1 thank you. I have a program of similar size that tracks the 450 specific plants in my garden. It even monitors degree-days to help me know when certain insects attack and when to tend to individual needs. This Excel/Jukebox program is also about 2000 lines of code. (Seems to be a pattern here). All of these programs are decorated with numerous pops and whistles that make programming and use quite pleasurable,

So, do you I think I am now ready for some "real programming".

==================

I will also add, that the way your describe going to your "community"

gives me questions if this is a violation of copyright. Maybe it is something you can "Get away with", but I am not sure what you are doing is actually legitimate.

Yes, I have been through that. It is totally legal to record NPR broadcasts for replay as long as they are not retained for than a month or for multiple replays. Your suggestion to download and play a podcast or broadcast is legal only for live replay. My want to record them for one replay for my own use. Personal play is a different story.

-----Original Message-----
From: Richard Damon <richard.damon@gmail.com <mailto:richard.damon@gmail.com> > On Behalf Of Richard Damon
Sent: Sunday, May 29, 2022 8:03 AM
To: Steve GS <Gronicus@SGA.Ninja <mailto:Gronicus@SGA.Ninja> >; Python <python-list@python.org <mailto:python-list@python.org> >
Subject: Re: Automatic Gain Control in Python?

>From your description, your fundamental problem is you are trying to automatically "control" things that weren't designed to be automatically controlled in the way you are attempting.

The smart speaker assumes the "user" will adjust the volume either with the controls or with verbal commands, So things will be a bit "clunky"
in your results as you command the smart speaker volume level.

Yes, you have an automated system that does most of what you want, but it is based on pieces not designed to be automated in this way, and you are running into the limitations caused by that.

Yes, you could split the aux-out to bring it into another computer to listen to the sound level, and then using a sound input package get samples of what is playing, and analyze that data to get an average volume, and then issues the command to adjust the volume level.

What you seem to be missing is that you could get the podcasts from a browser, and all a browser is is a program. It isn't that much work to write a rudimentary browser in python, especially if you don't actually need to display the results to a user, but are only trying to automate a particular task.

You seem to feel strongly invested in your current code base, which is understandable, but it seems you have reached a point where you don't want to live with the limitations CAUSED by that system. Yes, there is likely a way to tack on another layer of "stuff" to adjust for this issue, but it likely is going to require some real programming.

It may well be the design I am suggesting, of writing a program to fetch the podcast and save it requires a bit more work to get to the level you currently are at, but the results are a system that is actually designed to be controlled by automation. Maybe it is beyond you ability, but then so might the programming to get the volume.


Click here to read the complete article
1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor