Opened 3 weeks ago

Last modified 2 weeks ago

#5610 new defect

Re-Enable Audio Spectrogram for Python 3

Reported by: Fernando Gutierrez Owned by:
Priority: major Milestone:
Component: programming Keywords:
Cc: Parent Tickets:

Description

I propose a fix for the audio spectrogram code that works with Python 3.

I wrote a replacement that does not rely on the old unsupported third party code.

This new implementation only depends on numpy and soundfile/PySoundFile (PySoundFile was renamed to just soundfile in version 0.10, my implementation handles both)

Attached to this ticket is the patch

Subtickets

Attachments (1)

fix_spectrogram.diff (51.8 KB) - added by Fernando Gutierrez 2 weeks ago.
Second version of proposed fix: Added license header to new file, removed extlib/freesound, fixed soundfile package name in setup.py

Download all attachments as: .zip

Change History (4)

comment:1 Changed 3 weeks ago by Ben Sturmfels

Wonderful, thanks Fenrando, this is really impressive. I'd like to take a little bit of time to test this out, so will be a week or two if that's ok with you.

Is audiotospectrogram.py all your own work or do we need to add any attribution or licensing info? Either way, could you please stick a license header on the file? You can see an example in mediagoblin/media_types/audio/models.py.

Would you mind verifying that test_audio.py runs successfully with your changes? You can run that with something like bin/python -m pytest ./mediagoblin/tests/test_audio.py --boxed.

While you're there, can you please also remove extlib/freesound (which is what mediagoblin/media_types/audio/audioprocessing.py was linked to).

Thanks again!

NOTE TO SELF: We'll need to re-add numpy to the media-types.rst docs and to the Dockerfiles.

comment:2 Changed 3 weeks ago by Fernando Gutierrez

audiotospectrogram.py is my own work, I only copied the color = [] array from the old file to keep the same [blue, green, yellow, red] scheme for the spectrograms.

I'll run the tests. It may take a few days since I'm busy with other tasks.

Changed 2 weeks ago by Fernando Gutierrez

Attachment: fix_spectrogram.diff added

Second version of proposed fix: Added license header to new file, removed extlib/freesound, fixed soundfile package name in setup.py

comment:3 Changed 2 weeks ago by Fernando Gutierrez

I ran the test and it passed:

mediagoblin@opochtli:/srv/mediagoblin/media.nil.mx/mediagoblin$ ./bin/python -m pytest ./mediagoblin/tests/test_audio.py --boxed
================================================= test session starts ==================================================
platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /srv/mediagoblin/media.nil.mx/mediagoblin/mediagoblin/tests, inifile: pytest.ini
plugins: xdist-1.32.0, celery-4.2.2, forked-1.1.3
collected 2 items                                                                                                      

mediagoblin/tests/test_audio.py ..

================================================== 2 passed in 0.63s ===================================================

I could not test changes to setup.py because I hit this bug https://issues.mediagoblin.org/ticket/5611

Note: See TracTickets for help on using tickets.