Re: Best practices for using super()

2023-07-05 Thread Lars Liedtke via Python-list

Hey,

When you have multiple inheritance and you e.g. want to explicitely call 
__init__ of one of the classes inherited from, that is not the first in the 
list of classes to inherit from.

Cheers,

Lars


Lars Liedtke
Senior Software Developer

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail][email protected]


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany


[Logo Solute]


Marken der solute GmbH | brands of solute GmbH
[Marken]
[Advertising Partner]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de 
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php




Am 04.07.23 um 14:20 schrieb Peter Slížik via Python-list:

As a follow-up to my yesterday's question - are there any recommendations
on the usage of super()?

It's clear that super() can be used to invoke parent's:
- instance methods
- static methods
- constants ("static" attributes in the parent class, e.g. super().NUMBER).

This all works, but are there situations in which calling them explicitly
using a parent class name is preferred?

Best regards,
Peter

--
https://mail.python.org/mailman/listinfo/python-list


Re: pip-sync

2023-07-24 Thread Lars Liedtke via Python-list
This email contains a secure message that can be read by opening the attachment.





Lars Liedtke
Senior Software Developer

[Tel.]
[Fax]   +49 721 98993-
[E-Mail][email protected]


solute gmbh
Zeppelinstraße 15
76185 Karlsruhe
Germany


[Logo Solute]

Marken der solute gmbh | brands of solute gmbh
[Marken]

Triff uns auf der DMEXCO am 20. und 21. September in Köln und sichere dir die 
Chance auf eine brandneue Apple-Watch bei unserer Live-Auslosung!
Vereinbare hier einen Termin mit uns: 
https://outlook.office365.com/owa/calendar/[email protected]/bookings/

[dmexco 
Banner]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de 
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php

--- Begin Message ---
Did maybe pip-sync create the venv with --system-site-packages (at least 
that's the commandline option for pip)


I only saw behaviour like this so far, when my venv was with 
--system-site-packages and a package was installed by the system.


Cheers

Lars

Am 21.07.23 um 20:08 schrieb Larry Martell via Python-list:

I am trying to set up and maintain a venv with pip-sync. On my bare
metal I have the apparmor python package installed, but it is not
installed in my venv and it's not in my requirements file. When I run
pip-sync I get:

Found existing installation: apparmor 2.13.3
ERROR: Cannot uninstall 'apparmor'. It is a distutils installed
project and thus we cannot accurately determine which files belong to
it which would lead to only a partial uninstall.

Since it's not installed in the venv why does it want to uninstall it?


OpenPGP_signature
Description: OpenPGP digital signature
--- End Message ---
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip-sync

2023-07-24 Thread Lars Liedtke via Python-list

Did maybe pip-sync create the venv with --system-site-packages (at least that's 
the commandline option for pip)

I only saw behaviour like this so far, when my venv was with 
--system-site-packages and a package was installed by the system.

Sorry for the first mess.
Cheers

Lars


Lars Liedtke
Senior Software Developer

[Tel.]
[Fax]   +49 721 98993-
[E-Mail][email protected]


solute gmbh
Zeppelinstraße 15
76185 Karlsruhe
Germany


[Logo Solute]

Marken der solute gmbh | brands of solute gmbh
[Marken]

Triff uns auf der DMEXCO am 20. und 21. September in Köln und sichere dir die 
Chance auf eine brandneue Apple-Watch bei unserer Live-Auslosung!
Vereinbare hier einen Termin mit uns: 
https://outlook.office365.com/owa/calendar/[email protected]/bookings/

[dmexco 
Banner]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de 
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php


Am 21.07.23 um 20:08 schrieb Larry Martell via Python-list:

I am trying to set up and maintain a venv with pip-sync. On my bare
metal I have the apparmor python package installed, but it is not
installed in my venv and it's not in my requirements file. When I run
pip-sync I get:

Found existing installation: apparmor 2.13.3
ERROR: Cannot uninstall 'apparmor'. It is a distutils installed
project and thus we cannot accurately determine which files belong to
it which would lead to only a partial uninstall.

Since it's not installed in the venv why does it want to uninstall it?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Lars Liedtke via Python-list

Hey,

As far as I know (might be old news) flask does not support asyncio.

You would have to use a different framework, like e.g. FastAPI or similar. Maybe someone 
has already written "flask with asyncio" but I don't know about that.

Cheers

Lars


Lars Liedtke
Lead Developer

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail][email protected]


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany

[Marken]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de 
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 748044
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php




Am 20.03.24 um 09:22 schrieb Thomas Nyberg via Python-list:

Hello,

I have a simple (and not working) example of what I'm trying to do. This is a 
simplified version of what I'm trying to achieve (obviously the background 
workers and finalizer functions will do more later):

`app.py`

```
import asyncio
import threading
import time
from queue import Queue

from flask import Flask

in_queue = Queue()
out_queue = Queue()


def worker():
   print("worker started running")
   while True:
   future = in_queue.get()
   print(f"worker got future: {future}")
   time.sleep(5)
   print("worker sleeped")
   out_queue.put(future)


def finalizer():
   print("finalizer started running")
   while True:
   future = out_queue.get()
   print(f"finalizer got future: {future}")
   future.set_result("completed")
   print("finalizer set result")


threading.Thread(target=worker, daemon=True).start()
threading.Thread(target=finalizer, daemon=True).start()

app = Flask(__name__)


@app.route("/")
async def root():
   future = asyncio.get_event_loop().create_future()
   in_queue.put(future)
   print(f"root put future: {future}")
   result = await future
   return result


if __name__ == "__main__":
   app.run()
```

If I start up that server, and execute `curl http://localhost:5000`, it prints 
out the following in the server before hanging:

```
$ python3 app.py
worker started running
finalizer started running
* Serving Flask app 'app'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production 
deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
root put future: 
worker got future: 
worker sleeped
finalizer got future: 
finalizer set result
```

Judging by what's printing out, the `final result = await future` doesn't seem 
to be happy here.

Maybe someone sees something obvious I'm doing wrong here? I presume I'm mixing 
threads and asyncio in a way I shouldn't be.

Here's some system information (just freshly installed with pip3 install 
flask[async] in a virtual environment for python version 3.11.2):

```
$ uname -a
Linux x1carbon 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 
(2024-02-01) x86_64 GNU/Linux

$ python3 -V
Python 3.11.2

$ pip3 freeze
asgiref==3.7.2
blinker==1.7.0
click==8.1.7
Flask==3.0.2
itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.5
Werkzeug==3.0.1
```

Thanks for any help!

Cheers,
Thomas
--
https://mail.python.org/mailman/listinfo/python-list


Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Lars Liedtke via Python-list

Sorry, must have missed that :-/


Lars Liedtke
Lead Developer

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail][email protected]<mailto:[email protected]>


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany

[Marken]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de <http://www.solute.de/>
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 748044
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php




Am 22.03.24 um 08:58 schrieb Chris Angelico via Python-list:

On Fri, 22 Mar 2024 at 18:35, Lars Liedtke via Python-list
<mailto:[email protected]> wrote:



Hey,

As far as I know (might be old news) flask does not support asyncio.

You would have to use a different framework, like e.g. FastAPI or similar. Maybe someone 
has already written "flask with asyncio" but I don't know about that.




Did you try searching their documentation?

https://flask.palletsprojects.com/en/3.0.x/async-await/

ChrisA

--
https://mail.python.org/mailman/listinfo/python-list


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

2024-10-28 Thread Lars Liedtke via Python-list

There are also the concepts of Cepstrum 
(https://en.wikipedia.org/wiki/Cepstrum) and Quefrency, which are derivatives 
of Spectrum and Frequency, with which you can even do speaker-recognition, but 
also detection of events.


Lars Liedtke
Lead Developer

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail][email protected]


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany

[Marken]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de 
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 748044
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php




Am 26.10.24 um 18:07 schrieb Thomas Passin via Python-list:
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.
--
https://mail.python.org/mailman/listinfo/python-list