neverlib 0.2.8__py3-none-any.whl → 0.2.9__py3-none-any.whl
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.
- neverlib/QA/ImpactNoiseRejection.py +119 -0
- neverlib/QA/impact_noise_rejection.png +0 -0
- neverlib/QA/out.pcm +0 -0
- neverlib/QA/out.wav +0 -0
- neverlib/audio_aug/README.md +3 -0
- neverlib/audio_aug/__init__.py +0 -54
- neverlib/data_analyze/__init__.py +0 -44
- neverlib/filter/__init__.py +0 -23
- neverlib/filter/auto_eq/__init__.py +0 -36
- neverlib/filter/core.py +8 -5
- neverlib/metrics/README.md +35 -0
- neverlib/metrics/__init__.py +0 -36
- neverlib/metrics/pesq_c/PESQ +0 -0
- neverlib/signal_gen/babble_noise_generate.py +113 -0
- neverlib/tests/__init__.py +0 -17
- neverlib/utils/README.md +29 -0
- neverlib/utils/__init__.py +6 -50
- neverlib/utils/audio_split.py +20 -20
- neverlib/utils/checkGPU.py +52 -79
- neverlib/utils/floder.py +115 -0
- neverlib/utils/pcm.py +42 -0
- neverlib/utils/utils.py +3 -92
- neverlib/vad/__init__.py +0 -38
- {neverlib-0.2.8.dist-info → neverlib-0.2.9.dist-info}/METADATA +15 -1
- neverlib-0.2.9.dist-info/RECORD +119 -0
- neverlib/.claude/settings.local.json +0 -9
- neverlib/.history/Docs/audio_aug/del_20250827162530.py +0 -0
- neverlib/.history/Docs/audio_aug/del_20250827162540.py +0 -2
- neverlib/.history/Docs/audio_aug/del_20250827162541.py +0 -7
- neverlib/.history/Docs/audio_aug/del_20250827162606.py +0 -7
- neverlib/.history/Docs/audio_aug/del_20250827162637.py +0 -8
- neverlib/.history/Docs/audio_aug/del_20250827162645.py +0 -8
- neverlib/.history/Docs/audio_aug/del_20250827162723.py +0 -9
- neverlib/.history/Docs/audio_aug/del_20250827162739.py +0 -9
- neverlib/.history/Docs/audio_aug/test_snr_20250806011311.py +0 -0
- neverlib/.history/Docs/audio_aug/test_snr_20250806011331.py +0 -75
- neverlib/.history/Docs/audio_aug/test_snr_20250806011342.py +0 -57
- neverlib/.history/Docs/audio_aug/test_snr_20250806011352.py +0 -57
- neverlib/.history/Docs/audio_aug/test_snr_20250806011403.py +0 -57
- neverlib/.history/Docs/audio_aug/test_snr_20250806011413.py +0 -57
- neverlib/.history/Docs/audio_aug/test_snr_20250806011435.py +0 -55
- neverlib/.history/Docs/audio_aug/test_snr_20250827161751.py +0 -55
- neverlib/.history/Docs/audio_aug/test_snr_20250827161754.py +0 -55
- neverlib/.history/Docs/audio_aug/test_snr_20250827161833.py +0 -54
- neverlib/.history/Docs/audio_aug/test_snr_20250827162017.py +0 -56
- neverlib/.history/Docs/audio_aug/test_snr_20250827162021.py +0 -57
- neverlib/.history/Docs/audio_aug/test_snr_20250827162028.py +0 -57
- neverlib/.history/Docs/audio_aug/test_snr_20250827162033.py +0 -55
- neverlib/.history/Docs/audio_aug_test/del_20250827162738.py +0 -9
- neverlib/.history/Docs/audio_aug_test/del_20250827162819.py +0 -9
- neverlib/.history/Docs/audio_aug_test/del_20250827162830.py +0 -9
- neverlib/.history/Docs/audio_aug_test/del_20250827162846.py +0 -9
- neverlib/.history/Docs/audio_aug_test/del_20250827162851.py +0 -9
- neverlib/.history/Docs/audio_aug_test/del_20250827162903.py +0 -10
- neverlib/.history/Docs/audio_aug_test/del_20250827162921.py +0 -10
- neverlib/.history/Docs/audio_aug_test/del_20250827162926.py +0 -10
- neverlib/.history/Docs/audio_aug_test/del_20250827163030.py +0 -10
- neverlib/.history/Docs/audio_aug_test/del_20250827163032.py +0 -10
- neverlib/.history/Docs/vad/1_20250810032405.py +0 -0
- neverlib/.history/Docs/vad/1_20250810032417.py +0 -39
- neverlib/.history/QA/html2markdown_20250822234112.md +0 -0
- neverlib/.history/QA/html2markdown_20250822234140.py +0 -9
- neverlib/.history/QA/html2markdown_20250822234141.md +0 -9
- neverlib/.history/QA/html2markdown_20250822234159.py +0 -12
- neverlib/.history/QA/html2markdown_20250822234200.py +0 -17
- neverlib/.history/QA/html2markdown_20250822234236.py +0 -17
- neverlib/.history/QA/html2markdown_20250822234340.py +0 -14
- neverlib/.history/QA/html2markdown_20250822234522.py +0 -18
- neverlib/.history/QA/html2markdown_20250822234601.py +0 -20
- neverlib/.history/QA/html2markdown_20250822234615.py +0 -22
- neverlib/.history/QA/html2markdown_20250822234715.py +0 -28
- neverlib/.history/QA/html2markdown_20250822234720.py +0 -27
- neverlib/.history/QA/html2markdown_20250822234903.py +0 -27
- neverlib/.history/__init___20250805234212.py +0 -41
- neverlib/.history/__init___20250904102635.py +0 -39
- neverlib/.history/__init___20250904102836.py +0 -34
- neverlib/.history/__init___20250904102838.py +0 -39
- neverlib/.history/__init___20250904102851.py +0 -33
- neverlib/.history/audio_aug/audio_aug_20250806010451.py +0 -125
- neverlib/.history/audio_aug/audio_aug_20250806010750.py +0 -138
- neverlib/.history/audio_aug/audio_aug_20250806010759.py +0 -140
- neverlib/.history/audio_aug/audio_aug_20250806010803.py +0 -140
- neverlib/.history/audio_aug/audio_aug_20250806010809.py +0 -140
- neverlib/.history/audio_aug/audio_aug_20250806011108.py +0 -140
- neverlib/.history/audio_aug/audio_aug_20250826155913.py +0 -158
- neverlib/.history/audio_aug/audio_aug_20250826164159.py +0 -159
- neverlib/.history/audio_aug/audio_aug_20250826164217.py +0 -160
- neverlib/.history/audio_aug/audio_aug_20250826164408.py +0 -161
- neverlib/.history/audio_aug/audio_aug_20250826164423.py +0 -161
- neverlib/.history/audio_aug/audio_aug_20250826164529.py +0 -161
- neverlib/.history/audio_aug/audio_aug_20250826164824.py +0 -161
- neverlib/.history/audio_aug/audio_aug_20250826164932.py +0 -162
- neverlib/.history/audio_aug/audio_aug_20250826164947.py +0 -162
- neverlib/.history/audio_aug/audio_aug_20250826165403.py +0 -162
- neverlib/.history/audio_aug/audio_aug_20250826165421.py +0 -162
- neverlib/.history/audio_aug/audio_aug_20250826165509.py +0 -163
- neverlib/.history/audio_aug/audio_aug_20250826165702.py +0 -163
- neverlib/.history/audio_aug/audio_aug_20250826165732.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826170041.py +0 -163
- neverlib/.history/audio_aug/audio_aug_20250826170105.py +0 -164
- neverlib/.history/audio_aug/audio_aug_20250826170154.py +0 -164
- neverlib/.history/audio_aug/audio_aug_20250826170220.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826170221.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826170228.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826170231.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826212001.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826220038.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826220133.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826220148.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826220154.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826220156.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826220314.py +0 -165
- neverlib/.history/audio_aug/audio_aug_20250826220343.py +0 -184
- neverlib/.history/audio_aug/audio_aug_20250826220345.py +0 -184
- neverlib/.history/audio_aug/audio_aug_20250826220349.py +0 -184
- neverlib/.history/audio_aug/audio_aug_20250826220429.py +0 -184
- neverlib/.history/audio_aug/audio_aug_20250826220447.py +0 -184
- neverlib/.history/audio_aug/audio_aug_20250826220601.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220638.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220641.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220647.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220653.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220655.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220731.py +0 -185
- neverlib/.history/audio_aug/audio_aug_20250826220739.py +0 -185
- neverlib/.history/audio_aug/audio_aug_20250826220747.py +0 -185
- neverlib/.history/audio_aug/audio_aug_20250826220801.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220822.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826220901.py +0 -186
- neverlib/.history/audio_aug/audio_aug_20250826221107.py +0 -187
- neverlib/.history/audio_aug/audio_aug_20250826221310.py +0 -188
- neverlib/.history/audio_aug/audio_aug_20250826221353.py +0 -191
- neverlib/.history/audio_aug/audio_aug_20250826221821.py +0 -191
- neverlib/.history/audio_aug/audio_aug_20250826221838.py +0 -191
- neverlib/.history/audio_aug/audio_aug_20250826221906.py +0 -191
- neverlib/.history/audio_aug/audio_aug_20250826221930.py +0 -191
- neverlib/.history/audio_aug/audio_aug_20250826221939.py +0 -191
- neverlib/.history/audio_aug/audio_aug_20250826221955.py +0 -191
- neverlib/.history/audio_aug/audio_aug_20250826222008.py +0 -197
- neverlib/.history/audio_aug/audio_aug_20250826222017.py +0 -200
- neverlib/.history/audio_aug/audio_aug_20250826222046.py +0 -203
- neverlib/.history/audio_aug/audio_aug_20250826222105.py +0 -203
- neverlib/.history/audio_aug/audio_aug_20250826222206.py +0 -203
- neverlib/.history/audio_aug/audio_aug_20250826222302.py +0 -203
- neverlib/.history/audio_aug/audio_aug_20250826222336.py +0 -203
- neverlib/.history/audio_aug/audio_aug_20250826222455.py +0 -204
- neverlib/.history/audio_aug/audio_aug_20250826222526.py +0 -204
- neverlib/.history/audio_aug/audio_aug_20250826222541.py +0 -204
- neverlib/.history/audio_aug/audio_aug_20250826222624.py +0 -202
- neverlib/.history/audio_aug/audio_aug_20250826222714.py +0 -205
- neverlib/.history/audio_aug/audio_aug_20250826222820.py +0 -205
- neverlib/.history/audio_aug/audio_aug_20250826222827.py +0 -205
- neverlib/.history/audio_aug/audio_aug_20250826222927.py +0 -232
- neverlib/.history/audio_aug/audio_aug_20250826223009.py +0 -232
- neverlib/.history/audio_aug/audio_aug_20250826223054.py +0 -232
- neverlib/.history/audio_aug/audio_aug_20250826223225.py +0 -233
- neverlib/.history/audio_aug/audio_aug_20250826223344.py +0 -236
- neverlib/.history/audio_aug/audio_aug_20250826223356.py +0 -236
- neverlib/.history/audio_aug/audio_aug_20250826223955.py +0 -242
- neverlib/.history/audio_aug/audio_aug_20250826224210.py +0 -240
- neverlib/.history/audio_aug/audio_aug_20250826224250.py +0 -242
- neverlib/.history/audio_aug/audio_aug_20250826224323.py +0 -280
- neverlib/.history/audio_aug/audio_aug_20250826224452.py +0 -263
- neverlib/.history/audio_aug/audio_aug_20250826224455.py +0 -263
- neverlib/.history/audio_aug/audio_aug_20250826224502.py +0 -263
- neverlib/.history/audio_aug/audio_aug_20250826224528.py +0 -263
- neverlib/.history/audio_aug/audio_aug_20250826224658.py +0 -263
- neverlib/.history/audio_aug/audio_aug_20250826224833.py +0 -264
- neverlib/.history/audio_aug/audio_aug_20250826225013.py +0 -269
- neverlib/.history/audio_aug/audio_aug_20250826225050.py +0 -269
- neverlib/.history/audio_aug/audio_aug_20250826225241.py +0 -268
- neverlib/.history/audio_aug/audio_aug_20250826225315.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826225404.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826225502.py +0 -265
- neverlib/.history/audio_aug/audio_aug_20250826225950.py +0 -267
- neverlib/.history/audio_aug/audio_aug_20250826225959.py +0 -268
- neverlib/.history/audio_aug/audio_aug_20250826230222.py +0 -271
- neverlib/.history/audio_aug/audio_aug_20250826230248.py +0 -270
- neverlib/.history/audio_aug/audio_aug_20250826230638.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826230755.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826230941.py +0 -265
- neverlib/.history/audio_aug/audio_aug_20250826231054.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826231117.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826231219.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826232330.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250826232352.py +0 -266
- neverlib/.history/audio_aug/audio_aug_20250827152748.py +0 -268
- neverlib/.history/audio_aug/audio_aug_20250827152806.py +0 -268
- neverlib/.history/audio_aug/audio_aug_20250827152808.py +0 -268
- neverlib/.history/audio_aug/audio_aug_20250827152917.py +0 -283
- neverlib/.history/audio_aug/audio_aug_20250827152929.py +0 -281
- neverlib/.history/audio_aug/audio_aug_20250827153100.py +0 -286
- neverlib/.history/audio_aug/audio_aug_20250827153102.py +0 -286
- neverlib/.history/audio_aug/audio_aug_20250827153301.py +0 -295
- neverlib/.history/audio_aug/audio_aug_20250827153331.py +0 -298
- neverlib/.history/audio_aug/audio_aug_20250827153525.py +0 -303
- neverlib/.history/audio_aug/audio_aug_20250827153533.py +0 -304
- neverlib/.history/audio_aug/audio_aug_20250827153541.py +0 -321
- neverlib/.history/audio_aug/audio_aug_20250827153805.py +0 -322
- neverlib/.history/audio_aug/audio_aug_20250827153832.py +0 -323
- neverlib/.history/audio_aug/audio_aug_20250827153836.py +0 -324
- neverlib/.history/audio_aug/audio_aug_20250827153846.py +0 -324
- neverlib/.history/audio_aug/audio_aug_20250827153859.py +0 -325
- neverlib/.history/audio_aug/audio_aug_20250827154453.py +0 -337
- neverlib/.history/audio_aug/audio_aug_20250827154513.py +0 -355
- neverlib/.history/audio_aug/audio_aug_20250827154538.py +0 -356
- neverlib/.history/audio_aug/audio_aug_20250827154541.py +0 -357
- neverlib/.history/audio_aug/audio_aug_20250827154612.py +0 -357
- neverlib/.history/audio_aug/audio_aug_20250827154657.py +0 -360
- neverlib/.history/audio_aug/audio_aug_20250827154708.py +0 -360
- neverlib/.history/audio_aug/audio_aug_20250827154728.py +0 -366
- neverlib/.history/audio_aug/audio_aug_20250827154755.py +0 -367
- neverlib/.history/audio_aug/audio_aug_20250827154800.py +0 -367
- neverlib/.history/audio_aug/audio_aug_20250827154917.py +0 -368
- neverlib/.history/audio_aug/audio_aug_20250827154928.py +0 -369
- neverlib/.history/audio_aug/audio_aug_20250827154932.py +0 -370
- neverlib/.history/audio_aug/audio_aug_20250827154947.py +0 -372
- neverlib/.history/audio_aug/audio_aug_20250827155015.py +0 -375
- neverlib/.history/audio_aug/audio_aug_20250827155106.py +0 -375
- neverlib/.history/audio_aug/audio_aug_20250827155114.py +0 -393
- neverlib/.history/audio_aug/audio_aug_20250827155207.py +0 -415
- neverlib/.history/audio_aug/audio_aug_20250827155300.py +0 -415
- neverlib/.history/audio_aug/audio_aug_20250827155321.py +0 -471
- neverlib/.history/audio_aug/audio_aug_20250827164703.py +0 -471
- neverlib/.history/audio_aug/audio_aug_20250827164749.py +0 -471
- neverlib/.history/audio_aug/audio_aug_20250827165252.py +0 -472
- neverlib/.history/audio_aug/audio_aug_20250827165334.py +0 -472
- neverlib/.history/audio_aug/audio_aug_20250827165404.py +0 -473
- neverlib/.history/audio_aug/audio_aug_20250827165610.py +0 -473
- neverlib/.history/audio_aug/audio_aug_20250827165805.py +0 -473
- neverlib/.history/audio_aug/audio_aug_20250827170056.py +0 -473
- neverlib/.history/audio_aug/audio_aug_20250827170106.py +0 -472
- neverlib/.history/audio_aug/audio_aug_20250827170143.py +0 -472
- neverlib/.history/audio_aug/audio_aug_20250827170216.py +0 -472
- neverlib/.history/audio_aug/audio_aug_20250827170218.py +0 -472
- neverlib/.history/audio_aug/audio_aug_20250827170314.py +0 -472
- neverlib/.history/audio_aug/audio_aug_20250827171500.py +0 -471
- neverlib/.history/audio_aug/audio_aug_20250827172347.py +0 -471
- neverlib/.history/audio_aug/audio_aug_20250827172558.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250827172559.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250827172801.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250827182522.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250827182526.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250827182626.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250827182715.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250904185444.py +0 -470
- neverlib/.history/audio_aug/audio_aug_20250904185538.py +0 -445
- neverlib/.history/dataAnalyze/__init___20250805234204.py +0 -87
- neverlib/.history/dataAnalyze/__init___20250806204125.py +0 -14
- neverlib/.history/dataAnalyze/__init___20250806204139.py +0 -14
- neverlib/.history/dataAnalyze/__init___20250806204159.py +0 -14
- neverlib/.history/data_analyze/__init___20250806204158.py +0 -14
- neverlib/.history/data_analyze/__init___20250827163248.py +0 -14
- neverlib/.history/filter/__init___20250820103351.py +0 -70
- neverlib/.history/filter/__init___20250821102348.py +0 -70
- neverlib/.history/filter/__init___20250821102405.py +0 -14
- neverlib/.history/filter/auto_eq/__init___20250819213121.py +0 -36
- neverlib/.history/filter/auto_eq/__init___20250821102241.py +0 -36
- neverlib/.history/filter/auto_eq/__init___20250821102259.py +0 -36
- neverlib/.history/filter/auto_eq/__init___20250821102307.py +0 -36
- neverlib/.history/filter/auto_eq/__init___20250821102310.py +0 -36
- neverlib/.history/filter/auto_eq/__init___20250821102318.py +0 -36
- neverlib/.history/filter/auto_eq/__init___20250821102507.py +0 -36
- neverlib/.history/filter/auto_eq/de_eq_20250820103848.py +0 -361
- neverlib/.history/filter/auto_eq/de_eq_20250821102422.py +0 -360
- neverlib/.history/filter/auto_eq/freq_eq_20250805234206.py +0 -75
- neverlib/.history/filter/auto_eq/freq_eq_20250820140732.py +0 -75
- neverlib/.history/filter/auto_eq/freq_eq_20250820140745.py +0 -75
- neverlib/.history/filter/auto_eq/freq_eq_20250820140816.py +0 -75
- neverlib/.history/filter/auto_eq/freq_eq_20250820140938.py +0 -77
- neverlib/.history/filter/auto_eq/freq_eq_20250820141003.py +0 -77
- neverlib/.history/filter/auto_eq/freq_eq_20250820141006.py +0 -77
- neverlib/.history/filter/auto_eq/freq_eq_20250820141019.py +0 -77
- neverlib/.history/filter/auto_eq/freq_eq_20250820141049.py +0 -77
- neverlib/.history/filter/auto_eq/freq_eq_20250820141211.py +0 -77
- neverlib/.history/filter/auto_eq/freq_eq_20250820141227.py +0 -77
- neverlib/.history/filter/auto_eq/freq_eq_20250820141311.py +0 -78
- neverlib/.history/filter/auto_eq/freq_eq_20250820141340.py +0 -78
- neverlib/.history/filter/auto_eq/freq_eq_20250820141712.py +0 -78
- neverlib/.history/filter/auto_eq/freq_eq_20250820141733.py +0 -78
- neverlib/.history/filter/auto_eq/freq_eq_20250820141755.py +0 -78
- neverlib/.history/filter/auto_eq/freq_eq_20250821102434.py +0 -76
- neverlib/.history/filter/auto_eq/freq_eq_20250821102500.py +0 -76
- neverlib/.history/filter/auto_eq/freq_eq_20250821102502.py +0 -76
- neverlib/.history/filter/auto_eq/freq_eq_20250821143140.py +0 -76
- neverlib/.history/filter/auto_eq/freq_eq_20250821153208.py +0 -76
- neverlib/.history/filter/auto_eq/freq_eq_20250821153214.py +0 -76
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250820102957.py +0 -380
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113054.py +0 -380
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113150.py +0 -380
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113520.py +0 -385
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113525.py +0 -385
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250821102212.py +0 -385
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110521.py +0 -385
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110652.py +0 -385
- neverlib/.history/filter/common_20250806002134.py +0 -37
- neverlib/.history/filter/common_20250821120448.py +0 -49
- neverlib/.history/filter/common_20250821120453.py +0 -49
- neverlib/.history/metrics/dnsmos_20250806001612.py +0 -160
- neverlib/.history/metrics/dnsmos_20250815180659.py +0 -160
- neverlib/.history/metrics/dnsmos_20250815180701.py +0 -158
- neverlib/.history/metrics/dnsmos_20250815181321.py +0 -154
- neverlib/.history/metrics/dnsmos_20250815181327.py +0 -154
- neverlib/.history/metrics/dnsmos_20250815181331.py +0 -154
- neverlib/.history/metrics/dnsmos_20250815181620.py +0 -154
- neverlib/.history/metrics/dnsmos_20250815181631.py +0 -154
- neverlib/.history/metrics/dnsmos_20250815181742.py +0 -154
- neverlib/.history/metrics/dnsmos_20250815181824.py +0 -153
- neverlib/.history/metrics/dnsmos_20250815181834.py +0 -153
- neverlib/.history/metrics/dnsmos_20250815181922.py +0 -153
- neverlib/.history/metrics/dnsmos_20250815182011.py +0 -147
- neverlib/.history/metrics/dnsmos_20250815182036.py +0 -144
- neverlib/.history/metrics/dnsmos_20250815182936.py +0 -143
- neverlib/.history/metrics/dnsmos_20250815182942.py +0 -143
- neverlib/.history/metrics/dnsmos_20250815183032.py +0 -137
- neverlib/.history/metrics/dnsmos_20250815183101.py +0 -144
- neverlib/.history/metrics/dnsmos_20250815183121.py +0 -144
- neverlib/.history/metrics/dnsmos_20250815183123.py +0 -143
- neverlib/.history/metrics/dnsmos_20250815183214.py +0 -143
- neverlib/.history/metrics/dnsmos_20250815183240.py +0 -143
- neverlib/.history/metrics/dnsmos_20250815183248.py +0 -144
- neverlib/.history/metrics/dnsmos_20250815183407.py +0 -142
- neverlib/.history/metrics/dnsmos_20250815183409.py +0 -142
- neverlib/.history/metrics/dnsmos_20250815183431.py +0 -142
- neverlib/.history/metrics/dnsmos_20250815183507.py +0 -140
- neverlib/.history/metrics/dnsmos_20250815183513.py +0 -139
- neverlib/.history/metrics/dnsmos_20250815183618.py +0 -139
- neverlib/.history/metrics/dnsmos_20250815183709.py +0 -140
- neverlib/.history/metrics/dnsmos_20250815183756.py +0 -137
- neverlib/.history/metrics/dnsmos_20250815183815.py +0 -128
- neverlib/.history/metrics/dnsmos_20250815183827.py +0 -129
- neverlib/.history/metrics/dnsmos_20250815183913.py +0 -117
- neverlib/.history/metrics/dnsmos_20250815183914.py +0 -117
- neverlib/.history/metrics/dnsmos_20250815184003.py +0 -118
- neverlib/.history/metrics/dnsmos_20250815184040.py +0 -118
- neverlib/.history/metrics/dnsmos_20250815184049.py +0 -118
- neverlib/.history/metrics/dnsmos_20250815184104.py +0 -117
- neverlib/.history/metrics/dnsmos_20250815184200.py +0 -117
- neverlib/.history/metrics/lpc_lsp_metric_20250816015944.py +0 -128
- neverlib/.history/metrics/lpc_lsp_metric_20250816020142.py +0 -128
- neverlib/.history/metrics/lpc_lsp_metric_20250816020156.py +0 -128
- neverlib/.history/metrics/lpc_lsp_metric_20250816020554.py +0 -130
- neverlib/.history/metrics/lpc_lsp_metric_20250816020600.py +0 -125
- neverlib/.history/metrics/lpc_lsp_metric_20250816020631.py +0 -120
- neverlib/.history/metrics/lpc_lsp_metric_20250816020746.py +0 -118
- neverlib/.history/metrics/lpc_me_20250816013111.py +0 -0
- neverlib/.history/metrics/lpc_me_20250816013129.py +0 -121
- neverlib/.history/metrics/lpc_me_20250816015430.py +0 -103
- neverlib/.history/metrics/lpc_me_20250816015535.py +0 -96
- neverlib/.history/metrics/lpc_me_20250816015542.py +0 -96
- neverlib/.history/metrics/lpc_me_20250816015636.py +0 -97
- neverlib/.history/metrics/lpc_me_20250816015658.py +0 -104
- neverlib/.history/metrics/lpc_me_20250816015703.py +0 -100
- neverlib/.history/metrics/lpc_me_20250816015945.py +0 -128
- neverlib/.history/metrics/snr_20250806010538.py +0 -177
- neverlib/.history/metrics/snr_20250806211634.py +0 -184
- neverlib/.history/metrics/snr_20250827224201.py +0 -182
- neverlib/.history/metrics/snr_20250827234019.py +0 -186
- neverlib/.history/metrics/snr_20250827234028.py +0 -186
- neverlib/.history/metrics/snr_20250827234030.py +0 -186
- neverlib/.history/metrics/spec_20250805234209.py +0 -45
- neverlib/.history/metrics/spec_20250816135530.py +0 -11
- neverlib/.history/metrics/spec_20250816135654.py +0 -16
- neverlib/.history/metrics/spec_20250816135736.py +0 -68
- neverlib/.history/metrics/spec_20250816135904.py +0 -75
- neverlib/.history/metrics/spec_20250816135921.py +0 -82
- neverlib/.history/metrics/spec_20250816140111.py +0 -82
- neverlib/.history/metrics/spec_20250816140543.py +0 -136
- neverlib/.history/metrics/spec_20250816140559.py +0 -172
- neverlib/.history/metrics/spec_20250816140602.py +0 -172
- neverlib/.history/metrics/spec_20250816140608.py +0 -172
- neverlib/.history/metrics/spec_20250816140654.py +0 -148
- neverlib/.history/metrics/spec_20250816140705.py +0 -144
- neverlib/.history/metrics/spec_20250816140755.py +0 -138
- neverlib/.history/metrics/spec_20250816140823.py +0 -170
- neverlib/.history/metrics/spec_20250816140832.py +0 -170
- neverlib/.history/metrics/spec_20250816140833.py +0 -170
- neverlib/.history/metrics/spec_20250816140922.py +0 -147
- neverlib/.history/metrics/spec_20250816141148.py +0 -107
- neverlib/.history/metrics/spec_20250816141219.py +0 -123
- neverlib/.history/metrics/spec_20250816141732.py +0 -178
- neverlib/.history/metrics/spec_20250816141740.py +0 -178
- neverlib/.history/metrics/spec_20250816142030.py +0 -178
- neverlib/.history/metrics/spec_20250816142107.py +0 -135
- neverlib/.history/metrics/spec_20250816142126.py +0 -135
- neverlib/.history/metrics/spec_20250816142410.py +0 -135
- neverlib/.history/metrics/spec_20250816142415.py +0 -136
- neverlib/.history/metrics/spec_metric_20250816135156.py +0 -0
- neverlib/.history/metrics/spec_metric_20250816135226.py +0 -5
- neverlib/.history/metrics/spec_metric_20250816135227.py +0 -10
- neverlib/.history/metrics/spec_metric_20250816135306.py +0 -15
- neverlib/.history/metrics/spec_metric_20250816135442.py +0 -31
- neverlib/.history/metrics/spec_metric_20250816135448.py +0 -31
- neverlib/.history/metrics/spec_metric_20250816135520.py +0 -29
- neverlib/.history/metrics/spec_metric_20250816135537.py +0 -63
- neverlib/.history/metrics/spec_metric_20250816135653.py +0 -65
- neverlib/.history/utils/audio_split_20250805234209.py +0 -268
- neverlib/.history/utils/audio_split_20250904185309.py +0 -268
- neverlib/.history/utils/utils_20250813165516.py +0 -330
- neverlib/.history/utils/utils_20250904181341.py +0 -328
- neverlib/.history/utils/utils_20250904185546.py +0 -352
- neverlib/.history/utils/utils_20250904185548.py +0 -353
- neverlib/.history/utils/utils_20250904185603.py +0 -353
- neverlib/.history/utils/utils_20250904185636.py +0 -353
- neverlib/.history/utils/utils_20250904185658.py +0 -358
- neverlib/.history/utils/utils_20250904190053.py +0 -359
- neverlib/.history/vad/PreProcess_20250805234211.py +0 -63
- neverlib/.history/vad/PreProcess_20250809232455.py +0 -63
- neverlib/.history/vad/PreProcess_20250816020725.py +0 -66
- neverlib/.history/vad/VAD_Silero_20250805234211.py +0 -50
- neverlib/.history/vad/VAD_Silero_20250809232456.py +0 -50
- neverlib/.history/vad/VAD_WebRTC_20250805234211.py +0 -61
- neverlib/.history/vad/VAD_WebRTC_20250809232456.py +0 -61
- neverlib/.history/vad/VAD_funasr_20250805234211.py +0 -54
- neverlib/.history/vad/VAD_funasr_20250809232456.py +0 -54
- neverlib/.history/vad/VAD_vadlib_20250805234211.py +0 -70
- neverlib/.history/vad/VAD_vadlib_20250809232455.py +0 -70
- neverlib/.history/vad/VAD_whisper_20250805234211.py +0 -55
- neverlib/.history/vad/VAD_whisper_20250809232456.py +0 -55
- neverlib/.specstory/.what-is-this.md +0 -69
- neverlib/.specstory/history/2025-08-05_17-06Z-/350/277/231/344/270/200/346/255/245/347/232/204/347/233/256/347/232/204/346/230/257/344/273/200/344/271/210.md +0 -424
- neverlib/.specstory/history/2025-08-22_02-10Z-/345/256/214/345/226/204/345/207/275/346/225/260/347/232/204/345/212/237/350/203/275/345/222/214/345/217/230/351/207/217/345/220/215/345/273/272/350/256/256.md +0 -247
- neverlib/.specstory/history/2025-08-26_11-54Z-oserror-missing-shared-object-file.md +0 -87
- neverlib/.specstory/history/2025-08-27_08-07Z-/345/256/214/345/226/204/346/265/213/350/257/225/346/226/207/346/241/243/347/232/204/350/256/250/350/256/272.md +0 -296
- neverlib/.specstory/history/2025-08-27_08-29Z-delete-python-file-command.md +0 -211
- neverlib/.specstory/history/2025-08-27_09-05Z-/345/234/250jupyter/344/270/255/346/222/255/346/224/276/351/237/263/351/242/221/347/232/204/344/273/243/347/240/201/344/277/256/346/224/271.md +0 -357
- neverlib-0.2.8.dist-info/RECORD +0 -510
- {neverlib-0.2.8.dist-info → neverlib-0.2.9.dist-info}/WHEEL +0 -0
- {neverlib-0.2.8.dist-info → neverlib-0.2.9.dist-info}/licenses/LICENSE +0 -0
- {neverlib-0.2.8.dist-info → neverlib-0.2.9.dist-info}/top_level.txt +0 -0
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
sys.path.append("..")
|
|
3
|
-
import random
|
|
4
|
-
import numpy as np
|
|
5
|
-
import soundfile as sf
|
|
6
|
-
import scipy.signal as signal
|
|
7
|
-
from scipy.signal import lfilter, freqz
|
|
8
|
-
import matplotlib.pyplot as plt
|
|
9
|
-
from deap import base, creator, tools, algorithms
|
|
10
|
-
from neverlib.filter import EQFilter
|
|
11
|
-
|
|
12
|
-
# --- Configuration Parameters ---
|
|
13
|
-
SOURCE_AUDIO_PATH = "../../data/white.wav"
|
|
14
|
-
TARGET_AUDIO_PATH = "../../data/white_EQ.wav"
|
|
15
|
-
OUTPUT_MATCHED_AUDIO_PATH = "../../data/white_matched.wav"
|
|
16
|
-
|
|
17
|
-
SR = 16000
|
|
18
|
-
NFFT = 1024
|
|
19
|
-
FREQ_NUM = NFFT // 2 + 1
|
|
20
|
-
|
|
21
|
-
# --- GA Configuration - 需要重点调整这些参数 ---
|
|
22
|
-
MAX_FILTERS = 10 # 尝试增加或减少, 取决于EQ预期复杂度
|
|
23
|
-
POPULATION_SIZE = 200 # 建议增加 (例如 100-200)
|
|
24
|
-
MAX_GENERATIONS = 150 # 建议增加 (例如 100-300, 甚至更多)
|
|
25
|
-
CXPB = 0.7 # 交叉概率
|
|
26
|
-
MUTPB_IND = 0.4 # 个体变异概率, 可以适当增加以增强探索
|
|
27
|
-
MUTPB_GENE = 0.15 # 基因变异概率, 可以适当增加
|
|
28
|
-
|
|
29
|
-
# 复杂度惩罚因子 - 关键调整参数!
|
|
30
|
-
# 初始可以尝试较小的值, 如果滤波器过多, 再逐渐增大
|
|
31
|
-
COMPLEXITY_PENALTY_FACTOR = 0.01 # 尝试不同的值: 0.001, 0.005, 0.01, 0.05, 0.1 等
|
|
32
|
-
|
|
33
|
-
# Filter Type Definitions (整数编码)
|
|
34
|
-
FILTER_TYPE_PEAK = 0
|
|
35
|
-
FILTER_TYPE_LOW_SHELF = 1
|
|
36
|
-
FILTER_TYPE_HIGH_SHELF = 2
|
|
37
|
-
AVAILABLE_FILTER_TYPES = [FILTER_TYPE_PEAK, FILTER_TYPE_LOW_SHELF, FILTER_TYPE_HIGH_SHELF]
|
|
38
|
-
|
|
39
|
-
FILTER_TYPE_MAP_INT_TO_STR = {
|
|
40
|
-
FILTER_TYPE_PEAK: 'peak',
|
|
41
|
-
FILTER_TYPE_LOW_SHELF: 'low_shelf',
|
|
42
|
-
FILTER_TYPE_HIGH_SHELF: 'high_shelf',
|
|
43
|
-
}
|
|
44
|
-
# 创建EQFilter实例
|
|
45
|
-
eq_filter = EQFilter(fs=SR)
|
|
46
|
-
|
|
47
|
-
FILTER_TYPE_MAP_INT_TO_FUNC = {
|
|
48
|
-
FILTER_TYPE_PEAK: eq_filter.PeakingFilter,
|
|
49
|
-
FILTER_TYPE_LOW_SHELF: eq_filter.LowshelfFilter,
|
|
50
|
-
FILTER_TYPE_HIGH_SHELF: eq_filter.HighshelfFilter,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
# Parameter Bounds
|
|
54
|
-
FC_MIN, FC_MAX = 20, SR / 2 - 50
|
|
55
|
-
Q_MIN_PEAK, Q_MAX_PEAK = 0.3, 10.0
|
|
56
|
-
Q_MIN_SHELF, Q_MAX_SHELF = 0.3, 2.0
|
|
57
|
-
DBGAIN_MIN, DBGAIN_MAX = -25.0, 25.0 # 略微扩大增益范围
|
|
58
|
-
|
|
59
|
-
Q_BOUNDS_PER_TYPE = {
|
|
60
|
-
FILTER_TYPE_PEAK: (Q_MIN_PEAK, Q_MAX_PEAK),
|
|
61
|
-
FILTER_TYPE_LOW_SHELF: (Q_MIN_SHELF, Q_MAX_SHELF),
|
|
62
|
-
FILTER_TYPE_HIGH_SHELF: (Q_MIN_SHELF, Q_MAX_SHELF),
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
GENES_PER_FILTER_BLOCK = 5
|
|
66
|
-
|
|
67
|
-
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
|
|
68
|
-
creator.create("Individual", list, fitness=creator.FitnessMin)
|
|
69
|
-
|
|
70
|
-
toolbox = base.Toolbox()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def generate_active_gene(): return random.randint(0, 1)
|
|
74
|
-
def generate_type_gene(): return random.choice(AVAILABLE_FILTER_TYPES)
|
|
75
|
-
def generate_fc_gene(): return random.uniform(FC_MIN, FC_MAX)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def generate_q_gene(filter_type_int):
|
|
79
|
-
q_min, q_max = Q_BOUNDS_PER_TYPE[filter_type_int]
|
|
80
|
-
return random.uniform(q_min, q_max)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def generate_dbgain_gene(): return random.uniform(DBGAIN_MIN, DBGAIN_MAX)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
attribute_generators = []
|
|
87
|
-
for i in range(MAX_FILTERS):
|
|
88
|
-
toolbox.register(f"active_{i}", generate_active_gene)
|
|
89
|
-
attribute_generators.append(toolbox.__getattribute__(f"active_{i}"))
|
|
90
|
-
toolbox.register(f"type_{i}", generate_type_gene)
|
|
91
|
-
attribute_generators.append(toolbox.__getattribute__(f"type_{i}"))
|
|
92
|
-
toolbox.register(f"fc_{i}", generate_fc_gene)
|
|
93
|
-
attribute_generators.append(toolbox.__getattribute__(f"fc_{i}"))
|
|
94
|
-
attribute_generators.append(None)
|
|
95
|
-
toolbox.register(f"dbgain_{i}", generate_dbgain_gene)
|
|
96
|
-
attribute_generators.append(toolbox.__getattribute__(f"dbgain_{i}"))
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def individual_creator():
|
|
100
|
-
chromosome = []
|
|
101
|
-
for i in range(MAX_FILTERS):
|
|
102
|
-
active = generate_active_gene()
|
|
103
|
-
type_val = generate_type_gene()
|
|
104
|
-
fc = generate_fc_gene()
|
|
105
|
-
q = generate_q_gene(type_val)
|
|
106
|
-
dbgain = generate_dbgain_gene()
|
|
107
|
-
chromosome.extend([active, type_val, fc, q, dbgain])
|
|
108
|
-
return creator.Individual(chromosome)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
toolbox.register("individual", individual_creator)
|
|
112
|
-
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
def get_magnitude_spectrum_db(audio, sr, n_fft):
|
|
116
|
-
# 使用 spectrogram 进行频谱估计, 并对时间帧平均
|
|
117
|
-
f_spec, t_spec, Sxx_spec = signal.spectrogram(audio, fs=sr, nperseg=n_fft, noverlap=n_fft // 4, scaling='spectrum', mode='magnitude')
|
|
118
|
-
avg_magnitude_spectrum_spec = np.mean(Sxx_spec, axis=1)
|
|
119
|
-
db_spectrum = 20 * np.log10(avg_magnitude_spectrum_spec + 1e-12)
|
|
120
|
-
return f_spec, db_spectrum
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def get_single_filter_freq_response_db_from_coeffs(filter_params, num_freq_points, fs_proc):
|
|
124
|
-
# 为每个滤波器创建新的EQFilter实例, 使用正确的采样率
|
|
125
|
-
eq_filter_instance = EQFilter(fs=fs_proc)
|
|
126
|
-
filter_type = filter_params['type_int']
|
|
127
|
-
if filter_type == FILTER_TYPE_PEAK:
|
|
128
|
-
filter_func = eq_filter_instance.PeakingFilter
|
|
129
|
-
elif filter_type == FILTER_TYPE_LOW_SHELF:
|
|
130
|
-
filter_func = eq_filter_instance.LowshelfFilter
|
|
131
|
-
else: # HIGH_SHELF
|
|
132
|
-
filter_func = eq_filter_instance.HighshelfFilter
|
|
133
|
-
|
|
134
|
-
b, a = filter_func(fc=filter_params['fc'], Q=filter_params['q'], dBgain=filter_params['dBgain'])
|
|
135
|
-
w_native, h_native = freqz(b, a, worN=num_freq_points, fs=fs_proc)
|
|
136
|
-
response_db_native = 20 * np.log10(np.abs(h_native) + 1e-12)
|
|
137
|
-
return w_native, response_db_native
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def get_combined_eq_response_db(active_filters_list, num_points_calc, fs_proc, freq_axis_target):
|
|
141
|
-
num_target_freq_bins = len(freq_axis_target)
|
|
142
|
-
combined_response_db = np.zeros(num_target_freq_bins)
|
|
143
|
-
if not active_filters_list:
|
|
144
|
-
return combined_response_db
|
|
145
|
-
|
|
146
|
-
for p_dict in active_filters_list:
|
|
147
|
-
w_native, individual_response_db_native = get_single_filter_freq_response_db_from_coeffs(
|
|
148
|
-
p_dict, num_points_calc, fs_proc
|
|
149
|
-
)
|
|
150
|
-
individual_response_db_interp = np.interp(
|
|
151
|
-
freq_axis_target, w_native, individual_response_db_native
|
|
152
|
-
)
|
|
153
|
-
combined_response_db += individual_response_db_interp
|
|
154
|
-
return combined_response_db
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
target_eq_shape_db_global = None
|
|
158
|
-
objective_freq_axis_global = None
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
def evaluate_individual(individual_chromosome):
|
|
162
|
-
global target_eq_shape_db_global, objective_freq_axis_global
|
|
163
|
-
if target_eq_shape_db_global is None or objective_freq_axis_global is None:
|
|
164
|
-
raise ValueError("全局目标频谱未设置!") # 中文注释
|
|
165
|
-
|
|
166
|
-
active_filters_params_list = []
|
|
167
|
-
num_active_filters = 0
|
|
168
|
-
|
|
169
|
-
for i in range(MAX_FILTERS):
|
|
170
|
-
base_idx = i * GENES_PER_FILTER_BLOCK
|
|
171
|
-
is_active = individual_chromosome[base_idx]
|
|
172
|
-
|
|
173
|
-
if is_active == 1:
|
|
174
|
-
num_active_filters += 1
|
|
175
|
-
filter_type_int = individual_chromosome[base_idx + 1]
|
|
176
|
-
fc_val = individual_chromosome[base_idx + 2]
|
|
177
|
-
q_val = individual_chromosome[base_idx + 3]
|
|
178
|
-
dbgain_val = individual_chromosome[base_idx + 4]
|
|
179
|
-
|
|
180
|
-
fc_val = np.clip(fc_val, FC_MIN, FC_MAX)
|
|
181
|
-
q_min_type, q_max_type = Q_BOUNDS_PER_TYPE[filter_type_int]
|
|
182
|
-
q_val = np.clip(q_val, q_min_type, q_max_type)
|
|
183
|
-
dbgain_val = np.clip(dbgain_val, DBGAIN_MIN, DBGAIN_MAX)
|
|
184
|
-
|
|
185
|
-
active_filters_params_list.append({
|
|
186
|
-
'type_int': filter_type_int,
|
|
187
|
-
'fc': fc_val,
|
|
188
|
-
'q': q_val,
|
|
189
|
-
'dBgain': dbgain_val,
|
|
190
|
-
'fs': SR
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
if not active_filters_params_list:
|
|
194
|
-
achieved_eq_response_db = np.zeros_like(target_eq_shape_db_global)
|
|
195
|
-
else:
|
|
196
|
-
achieved_eq_response_db = get_combined_eq_response_db(
|
|
197
|
-
active_filters_params_list,
|
|
198
|
-
FREQ_NUM,
|
|
199
|
-
SR,
|
|
200
|
-
objective_freq_axis_global
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
error = np.sum((achieved_eq_response_db - target_eq_shape_db_global)**2)
|
|
204
|
-
|
|
205
|
-
# 调整复杂度惩罚项的计算方式, 使其与误差的量级更相关
|
|
206
|
-
# 例如, 如果误差本身就很大, 那么滤波器的数量惩罚可以相对小一些
|
|
207
|
-
# 或者, 如果目标EQ形状本身就很复杂(变化剧烈), 那么多用几个滤波器也是合理的
|
|
208
|
-
# penalty_scale = 1 + np.mean(np.abs(target_eq_shape_db_global)) # 基于目标EQ形状的平均绝对值
|
|
209
|
-
penalty_scale = np.sum(target_eq_shape_db_global**2) / len(target_eq_shape_db_global) if len(target_eq_shape_db_global) > 0 else 1.0
|
|
210
|
-
if penalty_scale < 1e-3:
|
|
211
|
-
penalty_scale = 1.0 # 避免除以过小的值或0
|
|
212
|
-
|
|
213
|
-
complexity_cost = COMPLEXITY_PENALTY_FACTOR * num_active_filters * (1 + penalty_scale * 0.1)
|
|
214
|
-
|
|
215
|
-
total_cost = error + complexity_cost
|
|
216
|
-
return (total_cost,)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
toolbox.register("evaluate", evaluate_individual)
|
|
220
|
-
toolbox.register("mate", tools.cxTwoPoint)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
def custom_mutate(individual, indpb_gene):
|
|
224
|
-
for i in range(len(individual)):
|
|
225
|
-
if random.random() < indpb_gene:
|
|
226
|
-
block_index = i // GENES_PER_FILTER_BLOCK
|
|
227
|
-
gene_type_in_block = i % GENES_PER_FILTER_BLOCK
|
|
228
|
-
|
|
229
|
-
current_filter_type_gene_idx = block_index * GENES_PER_FILTER_BLOCK + 1
|
|
230
|
-
current_filter_type = individual[current_filter_type_gene_idx]
|
|
231
|
-
|
|
232
|
-
if gene_type_in_block == 0: # Active gene
|
|
233
|
-
individual[i] = 1 - individual[i]
|
|
234
|
-
elif gene_type_in_block == 1: # Type gene
|
|
235
|
-
new_type = random.choice([t for t in AVAILABLE_FILTER_TYPES if t != individual[i]])
|
|
236
|
-
individual[i] = new_type
|
|
237
|
-
q_gene_idx = block_index * GENES_PER_FILTER_BLOCK + 3
|
|
238
|
-
individual[q_gene_idx] = generate_q_gene(new_type) # 根据新类型更新Q
|
|
239
|
-
elif gene_type_in_block == 2: # Fc gene
|
|
240
|
-
individual[i] = generate_fc_gene()
|
|
241
|
-
elif gene_type_in_block == 3: # Q gene
|
|
242
|
-
individual[i] = generate_q_gene(current_filter_type) # Q依赖于当前块的Type
|
|
243
|
-
elif gene_type_in_block == 4: # dBGain gene
|
|
244
|
-
individual[i] = generate_dbgain_gene()
|
|
245
|
-
return individual,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
toolbox.register("mutate", custom_mutate, indpb_gene=MUTPB_GENE)
|
|
249
|
-
toolbox.register("select", tools.selTournament, tournsize=3) # 锦标赛选择, tournsize可调整
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
def main_ga():
|
|
253
|
-
global target_eq_shape_db_global, objective_freq_axis_global
|
|
254
|
-
|
|
255
|
-
# source_audio, sr = sf.read(SOURCE_AUDIO_PATH)
|
|
256
|
-
# target_audio, sr = sf.read(TARGET_AUDIO_PATH)
|
|
257
|
-
|
|
258
|
-
wav_3956, sr = sf.read("../../data/3956_speech.wav")
|
|
259
|
-
source_audio = wav_3956[:, 1]
|
|
260
|
-
target_audio = wav_3956[:, 0]
|
|
261
|
-
|
|
262
|
-
assert sr == SR, "采样率不匹配"
|
|
263
|
-
assert source_audio.ndim == 1, "源音频必须是单声道"
|
|
264
|
-
|
|
265
|
-
source_freq_axis, source_db_spectrum = get_magnitude_spectrum_db(
|
|
266
|
-
source_audio, SR, NFFT
|
|
267
|
-
)
|
|
268
|
-
target_freq_axis, target_db_spectrum = get_magnitude_spectrum_db(
|
|
269
|
-
target_audio, SR, NFFT
|
|
270
|
-
)
|
|
271
|
-
assert np.array_equal(source_freq_axis, target_freq_axis), "源频谱和目标频谱的频率轴不一致"
|
|
272
|
-
|
|
273
|
-
target_eq_shape_db_global = target_db_spectrum - source_db_spectrum
|
|
274
|
-
objective_freq_axis_global = source_freq_axis
|
|
275
|
-
|
|
276
|
-
print(f"运行遗传算法 (种群: {POPULATION_SIZE}, 迭代: {MAX_GENERATIONS}, 最大滤波器数: {MAX_FILTERS})...") # 中文注释
|
|
277
|
-
population = toolbox.population(n=POPULATION_SIZE)
|
|
278
|
-
hall_of_fame = tools.HallOfFame(1) # 只记录最好的一个
|
|
279
|
-
|
|
280
|
-
# 设置统计信息
|
|
281
|
-
stats = tools.Statistics(lambda ind: ind.fitness.values)
|
|
282
|
-
stats.register("avg", np.mean)
|
|
283
|
-
stats.register("std", np.std)
|
|
284
|
-
stats.register("min", np.min)
|
|
285
|
-
stats.register("max", np.max)
|
|
286
|
-
|
|
287
|
-
# 运行GA
|
|
288
|
-
final_pop, logbook = algorithms.eaSimple(
|
|
289
|
-
population,
|
|
290
|
-
toolbox,
|
|
291
|
-
cxpb=CXPB,
|
|
292
|
-
mutpb=MUTPB_IND, # 个体变异概率
|
|
293
|
-
ngen=MAX_GENERATIONS,
|
|
294
|
-
stats=stats,
|
|
295
|
-
halloffame=hall_of_fame,
|
|
296
|
-
verbose=True # 打印每代统计信息
|
|
297
|
-
)
|
|
298
|
-
|
|
299
|
-
best_individual_chromosome = hall_of_fame[0]
|
|
300
|
-
print(f"\n最优个体适应度 (误差+惩罚): {best_individual_chromosome.fitness.values[0]:.4f}") # 中文注释
|
|
301
|
-
|
|
302
|
-
# 解码最优个体
|
|
303
|
-
optimized_eq_params_list = []
|
|
304
|
-
num_active_found = 0
|
|
305
|
-
print("\n--- Decoded Optimal EQ Filter Parameters ---") # 英文输出标题
|
|
306
|
-
for i in range(MAX_FILTERS):
|
|
307
|
-
base_idx = i * GENES_PER_FILTER_BLOCK
|
|
308
|
-
is_active = best_individual_chromosome[base_idx]
|
|
309
|
-
if is_active == 1:
|
|
310
|
-
num_active_found += 1
|
|
311
|
-
filter_type_int = best_individual_chromosome[base_idx + 1]
|
|
312
|
-
fc_val = best_individual_chromosome[base_idx + 2]
|
|
313
|
-
q_val = best_individual_chromosome[base_idx + 3]
|
|
314
|
-
dbgain_val = best_individual_chromosome[base_idx + 4]
|
|
315
|
-
|
|
316
|
-
param_dict = {
|
|
317
|
-
'type': FILTER_TYPE_MAP_INT_TO_STR[filter_type_int],
|
|
318
|
-
'fc': round(fc_val, 2),
|
|
319
|
-
'q': round(q_val, 3),
|
|
320
|
-
'dBgain': round(dbgain_val, 2),
|
|
321
|
-
'fs': SR
|
|
322
|
-
}
|
|
323
|
-
optimized_eq_params_list.append(param_dict)
|
|
324
|
-
print(param_dict) # 打印每个找到的滤波器参数
|
|
325
|
-
|
|
326
|
-
if not optimized_eq_params_list:
|
|
327
|
-
print("Warning: Genetic algorithm did not find any active filters.")
|
|
328
|
-
|
|
329
|
-
# 应用EQ并保存 (如果找到了滤波器)
|
|
330
|
-
if optimized_eq_params_list and OUTPUT_MATCHED_AUDIO_PATH:
|
|
331
|
-
print(f"\nApplying optimized EQ to source audio and saving to {OUTPUT_MATCHED_AUDIO_PATH}...")
|
|
332
|
-
|
|
333
|
-
def apply_eq_to_signal_structural(audio, eq_params_list_decoded, fs):
|
|
334
|
-
processed_audio = np.copy(audio)
|
|
335
|
-
eq_filter_instance = EQFilter(fs=fs)
|
|
336
|
-
|
|
337
|
-
for p_dict_decoded in eq_params_list_decoded:
|
|
338
|
-
if p_dict_decoded['type'] == 'peak':
|
|
339
|
-
filter_func = eq_filter_instance.PeakingFilter
|
|
340
|
-
elif p_dict_decoded['type'] == 'low_shelf':
|
|
341
|
-
filter_func = eq_filter_instance.LowshelfFilter
|
|
342
|
-
else: # high_shelf
|
|
343
|
-
filter_func = eq_filter_instance.HighshelfFilter
|
|
344
|
-
|
|
345
|
-
b, a = filter_func(fc=p_dict_decoded['fc'], Q=p_dict_decoded['q'], dBgain=p_dict_decoded['dBgain'])
|
|
346
|
-
processed_audio = lfilter(b, a, processed_audio)
|
|
347
|
-
return processed_audio
|
|
348
|
-
|
|
349
|
-
source_audio_matched = apply_eq_to_signal_structural(source_audio, optimized_eq_params_list, SR)
|
|
350
|
-
sf.write(OUTPUT_MATCHED_AUDIO_PATH, source_audio_matched, SR)
|
|
351
|
-
|
|
352
|
-
# 生成对比图
|
|
353
|
-
print("Generating comparison plot...") # 英文输出
|
|
354
|
-
decoded_active_filters_for_eval = []
|
|
355
|
-
for p_dict in optimized_eq_params_list:
|
|
356
|
-
type_str_to_int_map = {v: k for k, v in FILTER_TYPE_MAP_INT_TO_STR.items()}
|
|
357
|
-
decoded_active_filters_for_eval.append({
|
|
358
|
-
'type_int': type_str_to_int_map[p_dict['type']],
|
|
359
|
-
'fc': p_dict['fc'],
|
|
360
|
-
'q': p_dict['q'],
|
|
361
|
-
'dBgain': p_dict['dBgain']
|
|
362
|
-
})
|
|
363
|
-
|
|
364
|
-
achieved_eq_response_for_sum_db = get_combined_eq_response_db(
|
|
365
|
-
decoded_active_filters_for_eval, FREQ_NUM, SR, objective_freq_axis_global
|
|
366
|
-
)
|
|
367
|
-
source_plus_achieved_eq_db = source_db_spectrum + achieved_eq_response_for_sum_db
|
|
368
|
-
|
|
369
|
-
plt.figure(figsize=(12, 7))
|
|
370
|
-
plt.semilogx(objective_freq_axis_global, source_db_spectrum, label='Source Audio Spectrum', alpha=0.8, color='deepskyblue')
|
|
371
|
-
plt.semilogx(objective_freq_axis_global, target_db_spectrum, label='Target Audio Spectrum', alpha=0.8, color='coral')
|
|
372
|
-
plt.semilogx(objective_freq_axis_global, source_plus_achieved_eq_db, label='Source Spectrum + Matched EQ', alpha=0.8, color='limegreen')
|
|
373
|
-
|
|
374
|
-
plt.title(f'EQ Matching Result ({num_active_found} active filters) - {SR}Hz')
|
|
375
|
-
plt.xlabel('Frequency (Hz)')
|
|
376
|
-
plt.ylabel('Magnitude (dB)')
|
|
377
|
-
plt.legend(loc='best')
|
|
378
|
-
plt.xscale('log')
|
|
379
|
-
plt.grid(True, ls="--", alpha=0.4)
|
|
380
|
-
plt.tight_layout()
|
|
381
|
-
plt.savefig("eq_matching_plot_3curves.png")
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if __name__ == '__main__':
|
|
385
|
-
main_ga()
|