osekit 1.3.0__tar.gz → 1.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {osekit-1.3.0 → osekit-1.5.1}/CITATION.cff +1 -1
- {osekit-1.3.0 → osekit-1.5.1}/PKG-INFO +1 -1
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/coreapi_usage.rst +7 -9
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_ltas_core.ipynb +1 -1
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_ltas_public.ipynb +3 -3
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_multichannel.ipynb +1 -1
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_multiple_spectrograms_public.ipynb +1 -1
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_spectrogram.ipynb +4 -4
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/examples.rst +2 -2
- osekit-1.5.1/docs/source/job.rst +27 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/jobs.rst +41 -23
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/multichannel.rst +2 -2
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/publicapi_usage.rst +7 -7
- {osekit-1.3.0 → osekit-1.5.1}/pyproject.toml +1 -1
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/audio_data.py +33 -17
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/audio_item.py +24 -3
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/base_dataset.py +13 -7
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/detection.py +25 -2
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/event.py +14 -19
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/frequency_scale.py +4 -4
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/ltas_data.py +4 -4
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/spectro_data.py +34 -26
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/spectro_dataset.py +6 -6
- osekit-1.5.1/src/osekit/job/builder.py +153 -0
- osekit-1.5.1/src/osekit/job/config.py +32 -0
- osekit-1.5.1/src/osekit/job/job.py +237 -0
- osekit-1.5.1/src/osekit/job/scheduler/pbs.py +209 -0
- osekit-1.5.1/src/osekit/job/scheduler/scheduler.py +301 -0
- osekit-1.5.1/src/osekit/job/scheduler/slurm.py +267 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/public/export_transform.py +7 -7
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/public/project.py +2 -2
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/public/transform.py +8 -8
- osekit-1.3.0/tests/sample_dataset/sample1_180701_204453.wav → osekit-1.5.1/tests/__init__.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/_static/aplose_result.csv +2 -1
- osekit-1.5.1/tests/_static/job_status_request_results/pbs.txt +39 -0
- osekit-1.5.1/tests/_static/job_status_request_results/slurm_sacct.txt +1 -0
- osekit-1.5.1/tests/_static/job_status_request_results/slurm_squeue.txt +1 -0
- osekit-1.5.1/tests/_static/retro_compatibility_result.csv +2 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/conftest.py +2 -2
- osekit-1.3.0/tests/sample_dataset/sample1_190222_010000.wav → osekit-1.5.1/tests/helpers/__init__.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/helpers/audio.py +13 -2
- osekit-1.5.1/tests/sample_dataset/sample1_190222_010000.wav +0 -0
- osekit-1.5.1/tests/sample_dataset/sample1_220998_185532.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_audio.py +110 -1
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_core_api_base.py +45 -25
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_detection.py +33 -4
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_event.py +31 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_export_transform.py +2 -2
- osekit-1.5.1/tests/test_job.py +973 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_public_api.py +9 -9
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_serialization.py +9 -6
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_spectro.py +37 -46
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_welch.py +25 -0
- {osekit-1.3.0 → osekit-1.5.1}/uv.lock +248 -203
- osekit-1.3.0/docs/source/job.rst +0 -7
- osekit-1.3.0/src/osekit/core_api/__init__.py +0 -12
- osekit-1.3.0/src/osekit/public_api/__init__.py +0 -12
- osekit-1.3.0/src/osekit/utils/job.py +0 -635
- osekit-1.3.0/tests/test_job.py +0 -799
- {osekit-1.3.0 → osekit-1.5.1}/.github/dependabot.yml +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/.github/workflows/dependabot-auto-merge.yml +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/.github/workflows/documentation.yml +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/.github/workflows/github_ci.yml +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/.github/workflows/publish.yml +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/.gitignore +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/.pre-commit-config.yaml +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/CHANGELOG.md +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/CONTRIBUTING.md +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/LICENSE +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/README.md +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/Makefile +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/logo/osekit.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/logo/osekit_mid.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/logo/osekit_small.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/logo/osmose.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/logo/osmose_texte_sombre.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/logo/osmose_texte_sombre_small.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/make.bat +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/audio_data/ex2.svg +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/audio_data/ex_1.svg +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/audio_data/ex_2.svg +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/custom.css +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/data_structure/data_structure.svg +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/data_structure/optimized_IO.svg +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/detections/aplose_results.csv +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/detections/detection_labelled.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/detections/detection_unlabelled.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/detections/label_anchors.png +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/favicon.ico +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/ltas/ltas.svg +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1829.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1830.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1832.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1833.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1834.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1835.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1836.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1837.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/id/1838.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/multichannel/multichannel_220925_223450.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223450.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223500.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223510.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223520.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223530.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223600.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223610.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223620.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223630.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/sample_audio/timestamped/sample_220925_223640.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/_static/spectrograms/frequency_scale.svg +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/api.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/aplose.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/audiodata.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/audiodataset.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/audiofile.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/audiofilemanager.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/audioitem.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/basedata.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/basedataset.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/basefile.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/baseitem.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/conf.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/contributing.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/coreapi.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/coreapi_home.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/coreapi_introduction.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/detection.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/event.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_aplose_result.ipynb +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_ltas.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_multiple_spectrograms.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_multiple_spectrograms_core.ipynb +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_multiple_spectrograms_id.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_multiple_spectrograms_id_core.ipynb +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_multiple_spectrograms_id_public.ipynb +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_reshaping_multiple_files.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_reshaping_multiple_files_core.ipynb +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_reshaping_multiple_files_public.ipynb +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/example_reshaping_one_file.ipynb +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/export_transform.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/frequencyscale.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/index.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/installation.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/instrument.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/ltasdata.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/multiprocessing.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/normalization.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/project.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/publicapi.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/spectrodata.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/spectrodataset.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/spectrofile.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/spectroitem.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/transform.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/usage.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/docs/source/utils.rst +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/__init__.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/audio_backend/audio_backend.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/audio_backend/audio_file_manager.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/audio_backend/mseed_backend.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/audio_backend/soundfile_backend.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/config.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/__init__.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/audio_dataset.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/audio_file.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/base_data.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/base_file.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/base_item.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/instrument.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/json_serializer.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/ltas_dataset.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/spectro_file.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/core/spectro_item.py +0 -0
- {osekit-1.3.0/src/osekit/public → osekit-1.5.1/src/osekit/job}/__init__.py +0 -0
- {osekit-1.3.0/src/osekit/utils → osekit-1.5.1/src/osekit/job/scheduler}/__init__.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/logging_config.yaml +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/logging_context.py +0 -0
- {osekit-1.3.0/tests → osekit-1.5.1/src/osekit/public}/__init__.py +0 -0
- {osekit-1.3.0/tests/helpers → osekit-1.5.1/src/osekit/utils}/__init__.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/aplose.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/audio.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/core.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/deserialization.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/multiprocess.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/path.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/plot.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/src/osekit/utils/timestamp.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/_static/minimal_detector_result.csv +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/helpers/dummy.py +0 -0
- /osekit-1.3.0/tests/sample_dataset/sample1_220998_185532.wav → /osekit-1.5.1/tests/sample_dataset/sample1_180701_204453.wav +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_audio_file_manager.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_files.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_frequency_scales.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_instrument.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_logging.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_mseed.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_multiprocessing.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_permissions.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_timestamp_utils.py +0 -0
- {osekit-1.3.0 → osekit-1.5.1}/tests/test_utils.py +0 -0
|
@@ -110,8 +110,6 @@ The data is fetched seamlessly on-demand from the audio file(s). The opening/clo
|
|
|
110
110
|
|
|
111
111
|
Eventual time gap between audio items are filled with ``0.`` values.
|
|
112
112
|
|
|
113
|
-
.. _normalization:
|
|
114
|
-
|
|
115
113
|
Normalization
|
|
116
114
|
"""""""""""""
|
|
117
115
|
|
|
@@ -369,20 +367,20 @@ Once again, no audio has yet been fetched: everything happens only on-demand.
|
|
|
369
367
|
NPZ matrices
|
|
370
368
|
""""""""""""
|
|
371
369
|
|
|
372
|
-
The ``SpectroData`` object can be used to compute the
|
|
370
|
+
The ``SpectroData`` object can be used to compute the STFT matrices of the ``AudioData`` with the :meth:`osekit.core.spectro_data.SpectroData.get_value` method.
|
|
373
371
|
|
|
374
|
-
The :attr:`osekit.core.spectro_data.SpectroData.sx_dtype` property can be set to either ``complex`` (default) or ``float`` to return either the
|
|
372
|
+
The :attr:`osekit.core.spectro_data.SpectroData.sx_dtype` property can be set to either ``complex`` (default) or ``float`` to return either the STFT matrices as complex numbers or absolute values, respectively.
|
|
375
373
|
|
|
376
|
-
The
|
|
377
|
-
This method will convert the
|
|
374
|
+
The STFT matrices can be converted to decibels thanks to the :meth:`osekit.core.spectro_data.SpectroData.get_db_value` method.
|
|
375
|
+
This method will convert the STFT values either to dB SPL (re ``Instrument.P_REF``) if an :ref:`Instrument <instrument_calibration>` was provided to the ``AudioData`` or to dB FS otherwise.
|
|
378
376
|
|
|
379
|
-
The
|
|
377
|
+
The STFT matrices can then be exported to npz files thanks to the :meth:`osekit.core.spectro_data.SpectroData.write` method.
|
|
380
378
|
|
|
381
379
|
.. code-block:: python
|
|
382
380
|
|
|
383
381
|
sd = SpectroData.from_audio_data(data=ad, fft=sft)
|
|
384
382
|
|
|
385
|
-
sx_db = sd.get_db_value() # Use sd.get_value() if you want the complex
|
|
383
|
+
sx_db = sd.get_db_value() # Use sd.get_value() if you want the complex STFT matrix
|
|
386
384
|
|
|
387
385
|
# If sx has already been computed, you can pass it as a parameter to avoid re-computing it.
|
|
388
386
|
# Otherwise, it will just be computed from scratch.
|
|
@@ -463,7 +461,7 @@ LTAS Data
|
|
|
463
461
|
|
|
464
462
|
OSEkit provides the :class:`osekit.core.ltas_data.LTASData` class for computing and plotting long-term spectral averages.
|
|
465
463
|
|
|
466
|
-
When computing an STFT over a long audio recording, the resulting
|
|
464
|
+
When computing an STFT over a long audio recording, the resulting STFT matrix can contain a very large number of time bins. ``LTASData`` reduces this temporal resolution by averaging STFT time bins while preserving the spectral information along the frequency axis.
|
|
467
465
|
|
|
468
466
|
The target number of time bins is specified with the ``n_bins`` parameter. OSEkit computes the result recursively so that the full STFT matrix never needs to be materialized when it would exceed this target size.
|
|
469
467
|
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"cell_type": "markdown",
|
|
139
139
|
"id": "7bacba4e52a531c9",
|
|
140
140
|
"metadata": {},
|
|
141
|
-
"source": "Checking the required RAM to store the
|
|
141
|
+
"source": "Checking the required RAM to store the STFT matrix can give a hint on when to switch to a LTAS computation:"
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
144
|
"cell_type": "code",
|
|
@@ -144,8 +144,8 @@
|
|
|
144
144
|
"\n",
|
|
145
145
|
"transform = Transform(\n",
|
|
146
146
|
" output_type=OutputType.SPECTROGRAM\n",
|
|
147
|
-
" | OutputType.
|
|
148
|
-
" nb_ltas_time_bins=3000, # This will turn the regular
|
|
147
|
+
" | OutputType.STFT_MATRIX, # we want to export both the spectrogram and the sx STFT matrix\n",
|
|
148
|
+
" nb_ltas_time_bins=3000, # This will turn the regular STFT matrix computation in a LTAS\n",
|
|
149
149
|
" sample_rate=sample_rate,\n",
|
|
150
150
|
" normalization=Normalization.DC_REJECT, # Removes the DC component\n",
|
|
151
151
|
" fft=sft,\n",
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
"cell_type": "markdown",
|
|
174
174
|
"id": "8271f118422f38dc",
|
|
175
175
|
"metadata": {},
|
|
176
|
-
"source": "As for regular
|
|
176
|
+
"source": "As for regular STFT transforms, the output LTAS is stored in a `SpectroDataset` named after `transform.name`:"
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
"cell_type": "code",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"id": "1b00f1600c66e3c6",
|
|
102
102
|
"metadata": {},
|
|
103
103
|
"source": [
|
|
104
|
-
"## Computing the
|
|
104
|
+
"## Computing the spectrogram of a specific channel\n",
|
|
105
105
|
"\n",
|
|
106
106
|
"`SpectroData` target **a specific** channel of a file:"
|
|
107
107
|
]
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"from pandas import Timestamp, Timedelta\n",
|
|
145
145
|
"\n",
|
|
146
146
|
"transform = Transform(\n",
|
|
147
|
-
" output_type=OutputType.
|
|
147
|
+
" output_type=OutputType.STFT_MATRIX\n",
|
|
148
148
|
" | OutputType.SPECTROGRAM\n",
|
|
149
149
|
" | OutputType.WELCH, # we want to export these three spectrum outputs\n",
|
|
150
150
|
" begin=Timestamp(\"2022-09-25 22:35:15\"),\n",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"cell_type": "markdown",
|
|
100
100
|
"id": "8ae4db7363a92148",
|
|
101
101
|
"metadata": {},
|
|
102
|
-
"source": "Instantiate an **OSEkit** `SpectroData`, which is the object that will be used to plot spectrograms, export
|
|
102
|
+
"source": "Instantiate an **OSEkit** `SpectroData`, which is the object that will be used to plot spectrograms, export STFT matrices etc."
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
"cell_type": "code",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"source": [
|
|
134
134
|
"import matplotlib.pyplot as plt\n",
|
|
135
135
|
"\n",
|
|
136
|
-
"# We store the
|
|
136
|
+
"# We store the STFT matrix here to reuse it later in the notebook, this is not mandatory\n",
|
|
137
137
|
"sx = spectro_data.get_value()\n",
|
|
138
138
|
"\n",
|
|
139
139
|
"spectro_data.plot(sx=sx)\n",
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"cell_type": "markdown",
|
|
183
183
|
"id": "93eae4edd8bb8bb5",
|
|
184
184
|
"metadata": {},
|
|
185
|
-
"source": "You can export both the PNG spectrogram and the NPZ
|
|
185
|
+
"source": "You can export both the PNG spectrogram and the NPZ STFT matrix to file:"
|
|
186
186
|
},
|
|
187
187
|
{
|
|
188
188
|
"cell_type": "code",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
},
|
|
196
196
|
"outputs": [],
|
|
197
197
|
"source": [
|
|
198
|
-
"# Write a NPZ file with the
|
|
198
|
+
"# Write a NPZ file with the STFT matrix:\n",
|
|
199
199
|
"spectro_data.write(folder=audio_folder / \"export\", sx=sx)\n",
|
|
200
200
|
"\n",
|
|
201
201
|
"# Write a PNG image of the spectrogram\n",
|
|
@@ -34,7 +34,7 @@ In the ``docs/source/_static/sample_audio/timestamped`` folder, files are just n
|
|
|
34
34
|
|
|
35
35
|
.. topic:: :doc:`Compute/plot a spectrogram <example_spectrogram>`
|
|
36
36
|
|
|
37
|
-
| Compute the
|
|
37
|
+
| Compute the STFT matrix and/or Power Spectral Density estimates of an ``AudioData``.
|
|
38
38
|
| Export the matrices and/or plot a spectrogram.
|
|
39
39
|
|
|
40
40
|
===========
|
|
@@ -59,7 +59,7 @@ In the ``docs/source/_static/sample_audio/timestamped`` folder, files are just n
|
|
|
59
59
|
|
|
60
60
|
.. topic:: :doc:`Work with multichannel audio files <example_multichannel>`
|
|
61
61
|
|
|
62
|
-
Work on multichannel audio, compute
|
|
62
|
+
Work on multichannel audio, compute STFTs from specific channels...
|
|
63
63
|
|
|
64
64
|
===========
|
|
65
65
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.. _job:
|
|
2
|
+
|
|
3
|
+
Job
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
.. automodule:: osekit.job.job
|
|
7
|
+
:members: Job
|
|
8
|
+
|
|
9
|
+
Job Config
|
|
10
|
+
----------
|
|
11
|
+
|
|
12
|
+
.. automodule:: osekit.job.config
|
|
13
|
+
:members: JobConfig
|
|
14
|
+
|
|
15
|
+
Job Scheduler
|
|
16
|
+
-------------
|
|
17
|
+
|
|
18
|
+
.. automodule:: osekit.job.scheduler.pbs
|
|
19
|
+
:members: Pbs
|
|
20
|
+
.. automodule:: osekit.job.scheduler.slurm
|
|
21
|
+
:members: Slurm
|
|
22
|
+
|
|
23
|
+
Job Builder
|
|
24
|
+
-----------
|
|
25
|
+
|
|
26
|
+
.. automodule:: osekit.job.builder
|
|
27
|
+
:members: JobBuilder
|
|
@@ -2,51 +2,65 @@ Working with jobs
|
|
|
2
2
|
-----------------
|
|
3
3
|
|
|
4
4
|
**OSEkit** can be set to send transform instructions to be computed on a remote server
|
|
5
|
-
through
|
|
5
|
+
through queuing systems.
|
|
6
6
|
|
|
7
7
|
This feature has mainly be thought for the Public API, but it can nonetheless be used for
|
|
8
8
|
any Core API operation.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This is done thanks to the job package, located in :mod:`osekit.job`.
|
|
11
11
|
|
|
12
12
|
Public API
|
|
13
13
|
^^^^^^^^^^
|
|
14
14
|
|
|
15
|
-
Running Public API Analyses through
|
|
16
|
-
instance to the :attr:`osekit.public.project.Project.job_builder` attribute
|
|
15
|
+
Running Public API Analyses through jobs only requires adding a :class:`osekit.job.builder.JobBuilder`
|
|
16
|
+
instance to the :attr:`osekit.public.project.Project.job_builder` attribute.
|
|
17
|
+
|
|
18
|
+
The :class:`osekit.job.builder.JobBuilder`
|
|
19
|
+
|
|
20
|
+
Here is an example for running a transform on a PBS queue:
|
|
17
21
|
|
|
18
22
|
.. code-block:: python
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
import os
|
|
25
|
+
|
|
26
|
+
from pandas import Timedelta
|
|
27
|
+
|
|
28
|
+
from osekit.job.builder import JobBuilder
|
|
29
|
+
from osekit.job.config import JobConfig
|
|
30
|
+
from osekit.job.scheduler.pbs import Pbs
|
|
21
31
|
from osekit.public.project import Project
|
|
22
32
|
|
|
23
|
-
project = Project(...)
|
|
33
|
+
project = Project(...) # See the Project documentation
|
|
24
34
|
|
|
25
35
|
job_config = JobConfig(
|
|
26
|
-
nb_nodes=1,
|
|
27
|
-
ncpus=28,
|
|
28
|
-
ngpus=1,
|
|
29
|
-
mem="60gb",
|
|
30
|
-
walltime=Timedelta(
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
nb_nodes=1, # Number of nodes on which the job runs
|
|
37
|
+
ncpus=28, # Number of total cores used per node
|
|
38
|
+
ngpus=1, # Number of total GPU used per node
|
|
39
|
+
mem="60gb", # Maximum amount of physical memory used by the job
|
|
40
|
+
walltime=Timedelta(
|
|
41
|
+
hours=5
|
|
42
|
+
), # Maximum amount of real itime during which the job can be running
|
|
43
|
+
venv_name=os.environ["CONDA_DEFAULT_ENV"], # Works only for conda venvs
|
|
33
44
|
)
|
|
34
45
|
|
|
46
|
+
scheduler = Pbs(queue="omp") # Scheduler in which the job is submitted
|
|
47
|
+
|
|
35
48
|
project.job_builder = JobBuilder(
|
|
36
49
|
config=job_config,
|
|
50
|
+
scheduler=scheduler,
|
|
37
51
|
)
|
|
38
52
|
|
|
39
53
|
# Now the dataset has a non-None job_builder attribute,
|
|
40
54
|
# running a transform will write a PBS file in the logs directory
|
|
41
|
-
# and submit it
|
|
55
|
+
# and submit it through the selected scheduler.
|
|
42
56
|
|
|
43
|
-
project.run(...)
|
|
57
|
+
project.run(...) # See the Transform documentation
|
|
44
58
|
|
|
45
59
|
|
|
46
60
|
Core API
|
|
47
61
|
^^^^^^^^
|
|
48
62
|
|
|
49
|
-
Exporting Core API datasets with jobs is doable by explicitly instantiating a :class:`osekit.
|
|
63
|
+
Exporting Core API datasets with jobs is doable by explicitly instantiating a :class:`osekit.job.job.Job` object.
|
|
50
64
|
|
|
51
65
|
The export parameters are specified in the ``script_args`` parameter of the ``Job`` constructor,
|
|
52
66
|
and follow the console arguments of the :mod:`osekit.public.export` script.
|
|
@@ -60,11 +74,13 @@ and follow the console arguments of the :mod:`osekit.public.export` script.
|
|
|
60
74
|
|
|
61
75
|
from osekit.core.audio_dataset import AudioDataset
|
|
62
76
|
from osekit.core.spectro_dataset import SpectroDataset
|
|
77
|
+
from osekit.job.config import JobConfig
|
|
78
|
+
from osekit.job.job import Job
|
|
79
|
+
from osekit.job.scheduler.pbs import Pbs
|
|
63
80
|
from osekit.public import export_transform
|
|
64
81
|
|
|
65
82
|
# Some Public API imports are required
|
|
66
83
|
from osekit.public.transform import OutputType
|
|
67
|
-
from osekit.utils.job import Job, JobConfig
|
|
68
84
|
|
|
69
85
|
ads = AudioDataset(...) # See the AudioDataset doc
|
|
70
86
|
sds = SpectroDataset(...) # See the SpectroDataset doc
|
|
@@ -109,9 +125,11 @@ and follow the console arguments of the :mod:`osekit.public.export` script.
|
|
|
109
125
|
mem="60gb",
|
|
110
126
|
walltime=Timedelta(hours=1),
|
|
111
127
|
venv_name=os.environ["CONDA_DEFAULT_ENV"],
|
|
112
|
-
queue="omp",
|
|
113
128
|
)
|
|
114
129
|
|
|
130
|
+
# Scheduler configuration
|
|
131
|
+
scheduler = Pbs(queue="omp")
|
|
132
|
+
|
|
115
133
|
job = Job(
|
|
116
134
|
script_path=Path(export_transform.__file__),
|
|
117
135
|
script_args=args,
|
|
@@ -120,12 +138,12 @@ and follow the console arguments of the :mod:`osekit.public.export` script.
|
|
|
120
138
|
output_folder=Path(...), # Path in which the .out and .err files are written
|
|
121
139
|
)
|
|
122
140
|
|
|
123
|
-
# Write the
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
# Write the job file and submit it through the scheduler
|
|
142
|
+
scheduler.write(job=job, path=Path(...) / f"{job.name}.pbs")
|
|
143
|
+
scheduler.submit(job=job)
|
|
126
144
|
|
|
127
|
-
You can then follow the status of the submitted job:
|
|
145
|
+
You can then follow the status of the submitted job through the scheduler:
|
|
128
146
|
|
|
129
147
|
.. code-block:: python
|
|
130
148
|
|
|
131
|
-
|
|
149
|
+
scheduler.update_status(job=job)
|
|
@@ -37,10 +37,10 @@ Finally, a ``SpectroData`` that has a linked ``AudioData`` targets a **specific
|
|
|
37
37
|
from scipy.signal import ShortTimeFFT
|
|
38
38
|
|
|
39
39
|
sd = SpectroData.from_audio_data(data=ad, ...)
|
|
40
|
-
sd.audio_channel = 2 # The
|
|
40
|
+
sd.audio_channel = 2 # The STFT will be computed on the channel 2 of the file
|
|
41
41
|
|
|
42
42
|
.. important::
|
|
43
43
|
|
|
44
44
|
The :attr:`osekit.core.spectro_data.SpectroData.audio_channel` value refers to the index of the channel of the **file**.
|
|
45
45
|
|
|
46
|
-
If, as in the example above, the ``AudioFile`` has 3 channels ``[0,1,2]``, the ``AudioData`` targets channels ``[0,2]`` and the ``SpectroData`` targets the channel ``2``, the
|
|
46
|
+
If, as in the example above, the ``AudioFile`` has 3 channels ``[0,1,2]``, the ``AudioData`` targets channels ``[0,2]`` and the ``SpectroData`` targets the channel ``2``, the STFT will be computed on the **third channel** of the file (with index ``2``).
|
|
@@ -154,7 +154,7 @@ audio dataset (which could then be stored in another disk or partition):
|
|
|
154
154
|
Running an ``Transform``
|
|
155
155
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
156
156
|
|
|
157
|
-
In **OSEkit**, **Analyses** are run with the :meth:`osekit.public.project.Project.run` method to process and export spectrogram images,
|
|
157
|
+
In **OSEkit**, **Analyses** are run with the :meth:`osekit.public.project.Project.run` method to process and export spectrogram images, STFT matrices and audio files from original audio files.
|
|
158
158
|
|
|
159
159
|
.. note::
|
|
160
160
|
|
|
@@ -175,8 +175,8 @@ The ``output_type`` parameter passed to the initializer is a :class:`osekit.publ
|
|
|
175
175
|
- Output
|
|
176
176
|
* - ``OutputType.AUDIO``
|
|
177
177
|
- Reshaped audio files
|
|
178
|
-
* - ``OutputType.
|
|
179
|
-
- `STFT <https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.ShortTimeFFT.stft.html#scipy.signal.ShortTimeFFT.stft>`_ NPZ
|
|
178
|
+
* - ``OutputType.STFT_MATRIX``
|
|
179
|
+
- `STFT <https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.ShortTimeFFT.stft.html#scipy.signal.ShortTimeFFT.stft>`_ NPZ STFT files
|
|
180
180
|
* - ``OutputType.WELCH``
|
|
181
181
|
- `Welch <https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.welch.html>`_ NPZ files
|
|
182
182
|
* - ``OutputType.SPECTROGRAM``
|
|
@@ -199,7 +199,7 @@ The remaining parameters of the transform (begin and end **Timestamps**, duratio
|
|
|
199
199
|
|
|
200
200
|
.. note::
|
|
201
201
|
|
|
202
|
-
If the ``Transform`` contains spectral computations (either ``OutputType.
|
|
202
|
+
If the ``Transform`` contains spectral computations (either ``OutputType.STFT_MATRIX``, ``OutputType.SPECTROGRAM`` or ``OutputType.WELCH`` is in ``output_type``), a `scipy ShortTimeFFT instance <https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.ShortTimeFFT.html#scipy.signal.ShortTimeFFT>`_ should be passed to the ``Transform`` initializer.
|
|
203
203
|
|
|
204
204
|
.. _editing_transform:
|
|
205
205
|
|
|
@@ -321,7 +321,7 @@ The ``cool_reshape`` folder has been created, containing the freshly created ``1
|
|
|
321
321
|
Example: full transform
|
|
322
322
|
"""""""""""""""""""""""
|
|
323
323
|
|
|
324
|
-
Let's now say we want to export audio,
|
|
324
|
+
Let's now say we want to export audio, STFT matrices and spectrograms with the following parameters:
|
|
325
325
|
|
|
326
326
|
.. list-table:: Example transform parameters
|
|
327
327
|
:widths: 40 60
|
|
@@ -367,9 +367,9 @@ Then we are all set for running the transform:
|
|
|
367
367
|
|
|
368
368
|
transform = Transform(
|
|
369
369
|
output_type=OutputType.AUDIO
|
|
370
|
-
| OutputType.
|
|
370
|
+
| OutputType.STFT_MATRIX
|
|
371
371
|
| OutputType.WELCH
|
|
372
|
-
| OutputType.SPECTROGRAM, # Full transform : audio files,
|
|
372
|
+
| OutputType.SPECTROGRAM, # Full transform : audio files, STFT matrices and spectrograms will be exported.
|
|
373
373
|
begin=project.origin_dataset.begin
|
|
374
374
|
+ Timedelta(minutes=30), # 30m after the begin of the original dataset
|
|
375
375
|
end=project.origin_dataset.begin
|
|
@@ -135,18 +135,13 @@ class AudioData(BaseData[AudioItem, AudioFile]):
|
|
|
135
135
|
|
|
136
136
|
@property
|
|
137
137
|
def channels(self) -> list[int]:
|
|
138
|
-
"""The
|
|
139
|
-
return self.
|
|
138
|
+
"""The channels targeted by this ``AudioData``."""
|
|
139
|
+
return list({channel for i in self.items for channel in i.channels})
|
|
140
140
|
|
|
141
141
|
@channels.setter
|
|
142
142
|
def channels(self, value: list[int] | None) -> None:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
[1]
|
|
146
|
-
+ [item.nb_channels for item in self.items if type(item) is AudioItem],
|
|
147
|
-
)
|
|
148
|
-
value = list(range(nb_channels_max))
|
|
149
|
-
self._channels = value
|
|
143
|
+
for item in self.items:
|
|
144
|
+
item.channels = value
|
|
150
145
|
|
|
151
146
|
@classmethod
|
|
152
147
|
def _make_item(
|
|
@@ -261,16 +256,20 @@ class AudioData(BaseData[AudioItem, AudioFile]):
|
|
|
261
256
|
else self.butter.filter(sig=output, fs=self.sample_rate)
|
|
262
257
|
)
|
|
263
258
|
|
|
264
|
-
@staticmethod
|
|
265
259
|
def _flush(
|
|
260
|
+
self: AudioData,
|
|
266
261
|
resampler: soxr.ResampleStream,
|
|
267
262
|
remaining_samples: int,
|
|
268
263
|
) -> np.ndarray:
|
|
269
|
-
|
|
264
|
+
empty_values = np.empty((0, self.nb_channels))
|
|
265
|
+
flush = resampler.resample_chunk(
|
|
266
|
+
empty_values,
|
|
267
|
+
last=True,
|
|
268
|
+
)
|
|
270
269
|
if len(flush) == 0:
|
|
271
|
-
return
|
|
270
|
+
return empty_values
|
|
272
271
|
if not remaining_samples:
|
|
273
|
-
return
|
|
272
|
+
return empty_values
|
|
274
273
|
flush = flush[:remaining_samples]
|
|
275
274
|
return flush[:, None] if flush.ndim == 1 else flush
|
|
276
275
|
|
|
@@ -297,9 +296,16 @@ class AudioData(BaseData[AudioItem, AudioFile]):
|
|
|
297
296
|
for item in self.items:
|
|
298
297
|
if item.is_empty:
|
|
299
298
|
silence_length = round(item.duration.total_seconds() * self.sample_rate)
|
|
300
|
-
yield
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
yield (
|
|
300
|
+
item.get_value()
|
|
301
|
+
.repeat(
|
|
302
|
+
silence_length,
|
|
303
|
+
axis=0,
|
|
304
|
+
)
|
|
305
|
+
.repeat(
|
|
306
|
+
self.nb_channels,
|
|
307
|
+
axis=1,
|
|
308
|
+
)
|
|
303
309
|
)
|
|
304
310
|
produced_samples += silence_length
|
|
305
311
|
continue
|
|
@@ -326,7 +332,8 @@ class AudioData(BaseData[AudioItem, AudioFile]):
|
|
|
326
332
|
)
|
|
327
333
|
|
|
328
334
|
for chunk in item.stream(chunk_size=chunk_size):
|
|
329
|
-
y = chunk[
|
|
335
|
+
y = np.zeros((chunk.shape[0], self.nb_channels))
|
|
336
|
+
y[:, self._get_item_channel_mapping(item=item)] = chunk
|
|
330
337
|
if item.sample_rate != self.sample_rate:
|
|
331
338
|
y = resampler.resample_chunk(x=chunk)
|
|
332
339
|
|
|
@@ -347,6 +354,15 @@ class AudioData(BaseData[AudioItem, AudioFile]):
|
|
|
347
354
|
remaining_samples=total_samples - produced_samples,
|
|
348
355
|
)
|
|
349
356
|
|
|
357
|
+
def _get_item_channel_mapping(self, item: AudioItem) -> list[int]:
|
|
358
|
+
"""Return the mapping of the item channels in the AudioData channels.
|
|
359
|
+
|
|
360
|
+
If the AudioItem targets channels [2,4] and the AudioData target channels
|
|
361
|
+
[0,2,3,4], the channels with indexes 0 and 1 of the item data (channels 2 and 4) must be mapped
|
|
362
|
+
to the channels with indexes 1 and 3 of the AudioData (channels 2 and 4).
|
|
363
|
+
"""
|
|
364
|
+
return [self.channels.index(channel) for channel in item.channels]
|
|
365
|
+
|
|
350
366
|
def get_value(self) -> np.ndarray:
|
|
351
367
|
"""Return the value of the audio data.
|
|
352
368
|
|
|
@@ -22,6 +22,7 @@ class AudioItem(BaseItem[AudioFile]):
|
|
|
22
22
|
file: AudioFile | None = None,
|
|
23
23
|
begin: Timestamp | None = None,
|
|
24
24
|
end: Timestamp | None = None,
|
|
25
|
+
channels: list[int] | None = None,
|
|
25
26
|
) -> None:
|
|
26
27
|
"""Initialize an ``AudioItem`` from an ``AudioFile`` and begin/end timestamps.
|
|
27
28
|
|
|
@@ -35,9 +36,12 @@ class AudioItem(BaseItem[AudioFile]):
|
|
|
35
36
|
end: pandas.Timestamp (optional)
|
|
36
37
|
The timestamp at which this item ends.
|
|
37
38
|
It is defaulted to ``file.end``.
|
|
39
|
+
channels: list[int]
|
|
40
|
+
Considered channels of the linked audio file.
|
|
38
41
|
|
|
39
42
|
"""
|
|
40
43
|
super().__init__(file=file, begin=begin, end=end)
|
|
44
|
+
self.channels = channels
|
|
41
45
|
|
|
42
46
|
@property
|
|
43
47
|
def sample_rate(self) -> float:
|
|
@@ -46,8 +50,25 @@ class AudioItem(BaseItem[AudioFile]):
|
|
|
46
50
|
|
|
47
51
|
@property
|
|
48
52
|
def nb_channels(self) -> int:
|
|
49
|
-
"""Number of channels in the associated ``AudioFile``."""
|
|
50
|
-
return
|
|
53
|
+
"""Number of channels targeted in the associated ``AudioFile``."""
|
|
54
|
+
return len(self.channels)
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def channels(self) -> list[int]:
|
|
58
|
+
"""The channels targeted by this ``AudioItem``."""
|
|
59
|
+
return self._channels
|
|
60
|
+
|
|
61
|
+
@channels.setter
|
|
62
|
+
def channels(self, value: list[int] | None) -> None:
|
|
63
|
+
if self.is_empty:
|
|
64
|
+
self._channels = [0]
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
if value is None:
|
|
68
|
+
self._channels = list(range(self.file.channels))
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
self._channels = [channel for channel in value if channel < self.file.channels]
|
|
51
72
|
|
|
52
73
|
@property
|
|
53
74
|
def shape(self) -> tuple[int, int]:
|
|
@@ -78,5 +99,5 @@ class AudioItem(BaseItem[AudioFile]):
|
|
|
78
99
|
|
|
79
100
|
while remaining > 0:
|
|
80
101
|
frames_to_read = min(chunk_size, remaining)
|
|
81
|
-
yield self.file.stream(chunk_size=frames_to_read)
|
|
102
|
+
yield self.file.stream(chunk_size=frames_to_read)[:, self.channels]
|
|
82
103
|
remaining -= frames_to_read
|
|
@@ -330,15 +330,16 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
|
|
|
330
330
|
End of the last data object.
|
|
331
331
|
Defaulted to the end of the last file.
|
|
332
332
|
mode: Literal["files", "timedelta_total", "timedelta_file"]
|
|
333
|
-
Mode of creation of the dataset data from the
|
|
333
|
+
Mode of creation of the dataset data from the files.
|
|
334
334
|
``"files"``: one data will be created for each file.
|
|
335
335
|
``"timedelta_total"``: data objects of duration equal to ``data_duration`` will
|
|
336
336
|
be created from the ``begin`` timestamp to the ``end`` timestamp.
|
|
337
337
|
``"timedelta_file"``: data objects of duration equal to ``data_duration`` will
|
|
338
|
-
be created from the
|
|
339
|
-
|
|
338
|
+
be created from the ``begin`` timestamp, until it would resume in a data
|
|
339
|
+
beginning between two files.
|
|
340
340
|
Then, the next data object will be created from the
|
|
341
|
-
beginning of the next
|
|
341
|
+
beginning of the next file and so on until the ``end`` timestamp (if
|
|
342
|
+
specified) or the last file's end is reached.
|
|
342
343
|
data_duration: Timedelta | None
|
|
343
344
|
Duration of the data objects.
|
|
344
345
|
If mode is set to ``"files"``, this parameter has no effect.
|
|
@@ -481,14 +482,16 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
|
|
|
481
482
|
continue
|
|
482
483
|
files_chunk = [file]
|
|
483
484
|
|
|
485
|
+
next_jump = None
|
|
484
486
|
for next_file in files[idx + 1 :]:
|
|
485
487
|
upper_data_limit = last_window_end(
|
|
486
|
-
begin=
|
|
488
|
+
begin=begin,
|
|
487
489
|
end=files_chunk[-1].end,
|
|
488
490
|
window_hop=data_hop,
|
|
489
491
|
window_duration=data_duration,
|
|
490
492
|
)
|
|
491
493
|
if upper_data_limit < next_file.begin:
|
|
494
|
+
next_jump = next_file
|
|
492
495
|
break
|
|
493
496
|
files_chunk.append(next_file)
|
|
494
497
|
|
|
@@ -500,13 +503,16 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
|
|
|
500
503
|
**kwargs,
|
|
501
504
|
)
|
|
502
505
|
for data_begin in date_range(
|
|
503
|
-
|
|
504
|
-
files_chunk[-1].end,
|
|
506
|
+
begin,
|
|
507
|
+
min(files_chunk[-1].end, end),
|
|
505
508
|
freq=data_hop,
|
|
506
509
|
inclusive="left",
|
|
507
510
|
)
|
|
508
511
|
)
|
|
509
512
|
|
|
513
|
+
if next_jump:
|
|
514
|
+
begin = next_jump.begin
|
|
515
|
+
|
|
510
516
|
return output
|
|
511
517
|
|
|
512
518
|
@classmethod
|