neverlib 0.2.8__py3-none-any.whl → 0.3.0__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/Docs/audio_aug/test_volume.ipynb +8 -8
- neverlib/Docs/filter/biquad.ipynb +1 -1
- neverlib/Docs/filter/filter_family.ipynb +4 -4
- neverlib/Docs/vad/VAD_WebRTC.ipynb +4 -4
- neverlib/Docs/vad/VAD_whisper.ipynb +2 -2
- neverlib/LLM/__init__.py +37 -0
- neverlib/LLM/bailian.py +342 -0
- neverlib/LLM/image.py +73 -0
- neverlib/LLM/text.py +32 -0
- neverlib/QA/ImpactNoiseRejection.py +119 -0
- neverlib/QA/gen_init.py +13 -16
- neverlib/__init__.py +5 -5
- neverlib/audio_aug/HarmonicDistortion.py +11 -11
- neverlib/audio_aug/README.md +3 -0
- neverlib/audio_aug/__init__.py +2 -2
- neverlib/audio_aug/audio_aug.py +18 -18
- neverlib/audio_aug/coder_aug.py +25 -25
- neverlib/audio_aug/coder_aug2.py +10 -10
- neverlib/audio_aug/loss_packet_aug.py +16 -16
- neverlib/audio_aug/quant_aug.py +7 -7
- neverlib/data_analyze/README.md +1 -1
- neverlib/data_analyze/__init__.py +2 -2
- neverlib/data_analyze/dataset_analyzer.py +2 -2
- neverlib/data_analyze/quality_metrics.py +12 -12
- neverlib/data_analyze/statistics.py +1 -1
- neverlib/data_analyze/visualization.py +1 -1
- neverlib/filter/README.md +3 -3
- neverlib/filter/__init__.py +2 -2
- neverlib/filter/auto_eq/README.md +2 -2
- neverlib/filter/auto_eq/__init__.py +2 -2
- neverlib/filter/auto_eq/de_eq.py +1 -1
- neverlib/filter/auto_eq/ga_eq_advanced.py +2 -2
- neverlib/filter/auto_eq/ga_eq_basic.py +1 -1
- neverlib/filter/biquad.py +1 -1
- neverlib/filter/core.py +8 -5
- neverlib/metrics/README.md +35 -0
- neverlib/metrics/__init__.py +2 -2
- neverlib/metrics/dnsmos.py +2 -2
- neverlib/metrics/lpc_lsp.py +8 -8
- neverlib/metrics/pesq_c/PESQ +0 -0
- neverlib/metrics/snr.py +5 -5
- neverlib/metrics/spec.py +23 -23
- neverlib/metrics/test_pesq.py +3 -3
- neverlib/signal_gen/babble_noise_generate.py +113 -0
- neverlib/tests/__init__.py +2 -2
- neverlib/tests/test_imports.py +1 -1
- neverlib/utils/README.md +29 -0
- neverlib/utils/__init__.py +24 -16
- neverlib/utils/audio_split.py +21 -21
- neverlib/utils/checkGPU.py +52 -79
- neverlib/utils/floder.py +115 -0
- neverlib/utils/lazy_expose.py +1 -1
- neverlib/utils/lazy_module.py +6 -6
- neverlib/utils/message.py +2 -3
- neverlib/utils/pcm.py +42 -0
- neverlib/utils/utils.py +108 -91
- neverlib/vad/README.md +5 -5
- neverlib/vad/__init__.py +2 -2
- neverlib/vad/utils.py +1 -1
- {neverlib-0.2.8.dist-info → neverlib-0.3.0.dist-info}/METADATA +17 -3
- neverlib-0.3.0.dist-info/RECORD +120 -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.3.0.dist-info}/WHEEL +0 -0
- {neverlib-0.2.8.dist-info → neverlib-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {neverlib-0.2.8.dist-info → neverlib-0.3.0.dist-info}/top_level.txt +0 -0
neverlib/tests/__init__.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
|
-
#
|
|
7
|
+
# 仅在类型检查时导入, 提供IDE补全支持
|
|
8
8
|
from .test_preprocess import test_NS_shape, test_pre_emphasis
|
|
9
9
|
from .test_vad import test_vad2nad
|
|
10
10
|
|
|
@@ -30,4 +30,4 @@ if TYPE_CHECKING:
|
|
|
30
30
|
'test_NS_shape',
|
|
31
31
|
'test_pre_emphasis',
|
|
32
32
|
'test_vad2nad',
|
|
33
|
-
]
|
|
33
|
+
]
|
neverlib/tests/test_imports.py
CHANGED
|
@@ -11,7 +11,7 @@ import time
|
|
|
11
11
|
from neverlib.utils import get_path_list
|
|
12
12
|
from neverlib.data_analyze.dataset_analyzer import AudioFileInfo
|
|
13
13
|
|
|
14
|
-
# 确保当前目录在Python
|
|
14
|
+
# 确保当前目录在Python路径中, 以便导入neverlib
|
|
15
15
|
# sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
16
16
|
sys.path.append("../..")
|
|
17
17
|
print("开始测试neverlib导入功能...")
|
neverlib/utils/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
prsync
|
|
2
|
+
来源:https://github.com/nathanhaigh/parallel-rsync
|
|
3
|
+
用法
|
|
4
|
+
如果您的命令如下所示:rsync
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
rsync \
|
|
8
|
+
--times --recursive --progress \
|
|
9
|
+
--exclude "raw_reads" --exclude ".snakemake" \
|
|
10
|
+
user@example.com:/my_remote_dir/ /my_local_dir/
|
|
11
|
+
```
|
|
12
|
+
只需替换此脚本的可执行文件:rsync
|
|
13
|
+
```bash
|
|
14
|
+
./prsync \
|
|
15
|
+
--times --recursive --progress \
|
|
16
|
+
--exclude "raw_reads" --exclude ".snakemake" \
|
|
17
|
+
user@example.com:/my_remote_dir/ /my_local_dir/
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
并行作业数
|
|
21
|
+
默认情况下, 脚本将为计算机上的每个处理器使用 1 个并行作业. 这是由确定的, 如果失败, 我们将回退到并行作业来传输文件.
|
|
22
|
+
可以通过使用作为脚本的第一个命令行参数来覆盖此行为:```nproc 10 --parallel```
|
|
23
|
+
```bash
|
|
24
|
+
./prsync \
|
|
25
|
+
--parallel=20 \
|
|
26
|
+
--times --recursive --progress \
|
|
27
|
+
--exclude "raw_reads" --exclude ".snakemake" \
|
|
28
|
+
user@example.com:/my_remote_dir/ /my_local_dir/
|
|
29
|
+
```
|
neverlib/utils/__init__.py
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
|
-
#
|
|
7
|
+
# 仅在类型检查时导入, 提供IDE补全支持
|
|
8
8
|
from .audio_split import audio_split_VADfunasr, audio_split_VADsilero, audio_split_ffmpeg, audio_split_np, audio_split_pydub, audio_split_random, audio_split_sox
|
|
9
|
-
from .checkGPU import get_gpu_utilization,
|
|
9
|
+
from .checkGPU import get_gpu_utilization, get_gpu_utilization2, monitor_gpu_utilization
|
|
10
|
+
from .floder import change_path, del_empty_folders, get_leaf_folders, rename_files_and_folders
|
|
10
11
|
from .lazy_expose import attach_and_expose_all
|
|
11
12
|
from .lazy_module import LazyModule
|
|
12
13
|
from .message import send_QQEmail, send_QQEmail_with_images
|
|
13
|
-
from .
|
|
14
|
-
|
|
14
|
+
from .pcm import pcm2wav, read_pcm, wav2pcm
|
|
15
|
+
from .utils import DatasetSubfloderSplit, TrainValSplit, TrainValTestSplit, del_duplicate_path, get_audio_segments, get_file_time, get_path_list, log_time, merge_tensorboard, remove_parent_dir_prefix, save_weight_histogram
|
|
15
16
|
|
|
16
17
|
# 运行时使用懒加载
|
|
17
18
|
from lazy_loader import attach
|
|
@@ -21,19 +22,22 @@ __getattr__, __dir__, __all__ = attach(
|
|
|
21
22
|
submodules=[
|
|
22
23
|
"audio_split",
|
|
23
24
|
"checkGPU",
|
|
25
|
+
"floder",
|
|
24
26
|
"lazy_expose",
|
|
25
27
|
"lazy_module",
|
|
26
28
|
"message",
|
|
29
|
+
"pcm",
|
|
27
30
|
"utils",
|
|
28
31
|
],
|
|
29
32
|
submod_attrs={
|
|
30
33
|
"audio_split": ['audio_split_VADfunasr', 'audio_split_VADsilero', 'audio_split_ffmpeg', 'audio_split_np', 'audio_split_pydub', 'audio_split_random', 'audio_split_sox'],
|
|
31
|
-
"checkGPU": ['get_gpu_utilization', '
|
|
34
|
+
"checkGPU": ['get_gpu_utilization', 'get_gpu_utilization2', 'monitor_gpu_utilization'],
|
|
35
|
+
"floder": ['change_path', 'del_empty_folders', 'get_leaf_folders', 'rename_files_and_folders'],
|
|
32
36
|
"lazy_expose": ['attach_and_expose_all'],
|
|
33
37
|
"lazy_module": ['LazyModule'],
|
|
34
38
|
"message": ['send_QQEmail', 'send_QQEmail_with_images'],
|
|
35
|
-
"
|
|
36
|
-
|
|
39
|
+
"pcm": ['pcm2wav', 'read_pcm', 'wav2pcm'],
|
|
40
|
+
"utils": ['DatasetSubfloderSplit', 'TrainValSplit', 'TrainValTestSplit', 'del_duplicate_path', 'get_audio_segments', 'get_file_time', 'get_path_list', 'log_time', 'merge_tensorboard', 'remove_parent_dir_prefix', 'save_weight_histogram'],
|
|
37
41
|
}
|
|
38
42
|
)
|
|
39
43
|
|
|
@@ -48,24 +52,28 @@ if TYPE_CHECKING:
|
|
|
48
52
|
'audio_split_random',
|
|
49
53
|
'audio_split_sox',
|
|
50
54
|
'get_gpu_utilization',
|
|
51
|
-
'
|
|
55
|
+
'get_gpu_utilization2',
|
|
52
56
|
'monitor_gpu_utilization',
|
|
57
|
+
'change_path',
|
|
58
|
+
'del_empty_folders',
|
|
59
|
+
'get_leaf_folders',
|
|
60
|
+
'rename_files_and_folders',
|
|
53
61
|
'attach_and_expose_all',
|
|
54
62
|
'LazyModule',
|
|
55
63
|
'send_QQEmail',
|
|
56
64
|
'send_QQEmail_with_images',
|
|
65
|
+
'pcm2wav',
|
|
66
|
+
'read_pcm',
|
|
67
|
+
'wav2pcm',
|
|
57
68
|
'DatasetSubfloderSplit',
|
|
58
69
|
'TrainValSplit',
|
|
59
70
|
'TrainValTestSplit',
|
|
60
|
-
'
|
|
71
|
+
'del_duplicate_path',
|
|
61
72
|
'get_audio_segments',
|
|
62
73
|
'get_file_time',
|
|
63
|
-
'get_leaf_folders',
|
|
64
74
|
'get_path_list',
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
75
|
+
'log_time',
|
|
76
|
+
'merge_tensorboard',
|
|
77
|
+
'remove_parent_dir_prefix',
|
|
68
78
|
'save_weight_histogram',
|
|
69
|
-
|
|
70
|
-
'EPS',
|
|
71
|
-
]
|
|
79
|
+
]
|
neverlib/utils/audio_split.py
CHANGED
|
@@ -12,20 +12,20 @@ import numpy as np
|
|
|
12
12
|
from .utils import get_path_list
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def audio_split_ffmpeg(
|
|
15
|
+
def audio_split_ffmpeg(source_dir, target_dir, sr, channel_num, duration, endwith="*.pcm"):
|
|
16
16
|
""" 切割音频切不准, 会留点尾巴0.016s
|
|
17
17
|
使用ffmpeg分割音频, 分割为短音频(单位:秒), 似乎无法非常准确的分割到指定长度
|
|
18
|
-
:param
|
|
19
|
-
:param
|
|
18
|
+
:param source_dir: 源音频路径
|
|
19
|
+
:param target_dir: 目标音频路径
|
|
20
20
|
:param sr: 源音频采样率
|
|
21
21
|
:param channel_num: 源音频声道数
|
|
22
22
|
:param duration: 分割为时长(短音频)(单位:秒)
|
|
23
23
|
:param endwith: 音频格式(支持pcm和wav)
|
|
24
24
|
"""
|
|
25
|
-
wav_path_list = get_path_list(
|
|
25
|
+
wav_path_list = get_path_list(source_dir, end=endwith)
|
|
26
26
|
print("待分割的音频数: ", len(wav_path_list))
|
|
27
27
|
for wav_path in wav_path_list:
|
|
28
|
-
wav_folder = wav_path[:-4].replace(
|
|
28
|
+
wav_folder = wav_path[:-4].replace(source_dir, target_dir)
|
|
29
29
|
os.makedirs(wav_folder, exist_ok=True)
|
|
30
30
|
|
|
31
31
|
if endwith == "*.pcm":
|
|
@@ -45,19 +45,19 @@ def audio_split_ffmpeg(source_path, target_path, sr, channel_num, duration, endw
|
|
|
45
45
|
print("分割完毕: done!")
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
def audio_split_sox(
|
|
48
|
+
def audio_split_sox(source_dir, target_dir, duration, endwith="*.wav"):
|
|
49
49
|
"""
|
|
50
50
|
使用sox分割音频, 分割为短音频(单位:秒), 可以非常准确的分割到指定长度
|
|
51
|
-
:param
|
|
52
|
-
:param
|
|
51
|
+
:param source_dir: 源音频路径
|
|
52
|
+
:param target_dir: 目标音频路径
|
|
53
53
|
:param duration: 分割为时长(短音频)(单位:秒)
|
|
54
54
|
:param endwith: 音频格式(只支持wav)
|
|
55
55
|
"""
|
|
56
56
|
assert endwith == "*.wav", "只支持wav格式的音频"
|
|
57
|
-
wav_path_list = get_path_list(
|
|
57
|
+
wav_path_list = get_path_list(source_dir, end=endwith)
|
|
58
58
|
|
|
59
59
|
for wav_path in wav_path_list:
|
|
60
|
-
wav_folder = wav_path[:-4].replace(
|
|
60
|
+
wav_folder = wav_path[:-4].replace(source_dir, target_dir)
|
|
61
61
|
os.makedirs(wav_folder, exist_ok=True)
|
|
62
62
|
|
|
63
63
|
output_pattern = f"{wav_folder}/%.wav"
|
|
@@ -71,25 +71,25 @@ def audio_split_sox(source_path, target_path, duration, endwith="*.wav"):
|
|
|
71
71
|
print("分割完毕: done!")
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
def audio_split_np(
|
|
74
|
+
def audio_split_np(source_dir, target_dir, sr, channel_num, duration, endwith="*.pcm"):
|
|
75
75
|
"""
|
|
76
76
|
使用numpy读取pcm文件并切割保存为wav文件, 保持通道数一致, 保存不足30秒的最后一段音频
|
|
77
|
-
:param
|
|
78
|
-
:param
|
|
77
|
+
:param source_dir: 源音频路径
|
|
78
|
+
:param target_dir: 目标音频路径
|
|
79
79
|
:param sr: 采样率
|
|
80
80
|
:param channel_num: 声道数
|
|
81
81
|
:param duration: 分割的时长 (秒)
|
|
82
82
|
:param endwith: 音频格式 (支持 pcm)
|
|
83
83
|
"""
|
|
84
84
|
assert endwith == "*.pcm", "只支持pcm格式的音频"
|
|
85
|
-
wav_path_list = get_path_list(
|
|
85
|
+
wav_path_list = get_path_list(source_dir, end=endwith) # 获取音频文件列表
|
|
86
86
|
print("待分割的音频数: ", len(wav_path_list))
|
|
87
87
|
|
|
88
88
|
segment_length_samples = duration * sr # 每个切片音频的采样点数
|
|
89
89
|
|
|
90
90
|
for wav_path in wav_path_list:
|
|
91
91
|
print("正在分割: ", wav_path)
|
|
92
|
-
wav_folder = wav_path[:-4].replace(
|
|
92
|
+
wav_folder = wav_path[:-4].replace(source_dir, target_dir)
|
|
93
93
|
os.makedirs(wav_folder, exist_ok=True)
|
|
94
94
|
|
|
95
95
|
# 注意读取时使用正确的dtype(例如int16表示16位PCM)
|
|
@@ -119,11 +119,11 @@ def audio_split_np(source_path, target_path, sr, channel_num, duration, endwith=
|
|
|
119
119
|
print("分割完毕: done!")
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
def audio_split_pydub(
|
|
122
|
+
def audio_split_pydub(source_dir, target_dir, sr, channel_num, duration, endwith="*.pcm", sample_width=2):
|
|
123
123
|
"""
|
|
124
124
|
使用pydub分割音频, 进行精确的分割
|
|
125
|
-
:param
|
|
126
|
-
:param
|
|
125
|
+
:param source_dir: 源音频路径
|
|
126
|
+
:param target_dir: 目标音频路径
|
|
127
127
|
:param sr: 源音频采样率
|
|
128
128
|
:param channel_num: 源音频声道数
|
|
129
129
|
:param duration: 分割为时长(短音频)(单位:秒), 必须是1s的整数倍
|
|
@@ -136,12 +136,12 @@ def audio_split_pydub(source_path, target_path, sr, channel_num, duration, endwi
|
|
|
136
136
|
raise ImportError("需要安装 pydub 才能使用 audio_split_pydub: pip install pydub") from e
|
|
137
137
|
|
|
138
138
|
assert duration % 1 == 0, "duration必须是1s的整数倍"
|
|
139
|
-
wav_path_list = get_path_list(
|
|
139
|
+
wav_path_list = get_path_list(source_dir, end=endwith) # 获取音频文件列表
|
|
140
140
|
print("待分割的音频数: ", len(wav_path_list))
|
|
141
141
|
|
|
142
142
|
for wav_path in wav_path_list:
|
|
143
143
|
print("正在分割: ", wav_path)
|
|
144
|
-
wav_folder = wav_path[:-4].replace(
|
|
144
|
+
wav_folder = wav_path[:-4].replace(source_dir, target_dir) # 设置目标文件夹
|
|
145
145
|
os.makedirs(wav_folder, exist_ok=True)
|
|
146
146
|
|
|
147
147
|
# 使用pydub加载音频
|
|
@@ -170,7 +170,7 @@ def audio_split_pydub(source_path, target_path, sr, channel_num, duration, endwi
|
|
|
170
170
|
|
|
171
171
|
def audio_split_random(source_dir, target_dir, min_duration=3, max_duration=10, sr=16000):
|
|
172
172
|
"""
|
|
173
|
-
将音频切割成 3 到 10
|
|
173
|
+
将音频切割成 3 到 10 秒的多个片段并保存.
|
|
174
174
|
参数:
|
|
175
175
|
- input_audio_path: 输入音频文件路径
|
|
176
176
|
- output_dir: 输出音频文件夹路径
|
neverlib/utils/checkGPU.py
CHANGED
|
@@ -1,43 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-09-24 14:28:42
|
|
4
|
+
Description:
|
|
5
5
|
检查GPU时候空闲
|
|
6
6
|
nohup python -u ./checkGPU.py > ./checkGPU.log 2>&1 &
|
|
7
7
|
pid 5993
|
|
8
|
-
|
|
8
|
+
'''
|
|
9
9
|
import time
|
|
10
10
|
import subprocess
|
|
11
11
|
import numpy as np
|
|
12
12
|
from .message import send_QQEmail
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def is_gpu_idle():
|
|
16
|
-
try:
|
|
17
|
-
import GPUtil
|
|
18
|
-
except ImportError:
|
|
19
|
-
raise ImportError(
|
|
20
|
-
"GPUtil is required for is_gpu_idle(). "
|
|
21
|
-
"Please install it via `pip install checkGPU`."
|
|
22
|
-
)
|
|
23
|
-
try:
|
|
24
|
-
# 获取所有可见的GPU设备列表
|
|
25
|
-
gpus = GPUtil.getGPUs()
|
|
26
|
-
# print(len(gpus), gpus)
|
|
27
|
-
gpu0, gpu1, gpu2, gpu3, gpu4, gpu5, gpu6, gpu7 = gpus # 8块GPU
|
|
28
|
-
# gpu.memoryUtil表示GPU的内存利用率
|
|
29
|
-
# gpu.load表示GPU的计算利用率
|
|
30
|
-
# gpu.memoryTotal表示GPU的总内存
|
|
31
|
-
# gpu.memoryUsed表示GPU的已使用内存
|
|
32
|
-
# gpu.memoryFree表示GPU的空闲内存
|
|
33
|
-
if gpu0.load == 0.0 and gpu1 == 0.0 and gpu2 == 0.0 and gpu3 == 0.0:
|
|
34
|
-
return True
|
|
35
|
-
return False
|
|
36
|
-
except Exception as e:
|
|
37
|
-
print(f"Error checking GPU utilization: {e}")
|
|
38
|
-
return False
|
|
39
|
-
|
|
40
|
-
|
|
41
15
|
def get_gpu_utilization():
|
|
42
16
|
"""
|
|
43
17
|
Returns: 返回所有GPU利用率列表
|
|
@@ -53,9 +27,31 @@ def get_gpu_utilization():
|
|
|
53
27
|
return None
|
|
54
28
|
|
|
55
29
|
|
|
30
|
+
def get_gpu_utilization2(gpu_id=None):
|
|
31
|
+
try:
|
|
32
|
+
import GPUtil
|
|
33
|
+
except ImportError:
|
|
34
|
+
raise ImportError(
|
|
35
|
+
"GPUtil is required for is_gpu_idle(). "
|
|
36
|
+
"Please install it via `pip install gputil`."
|
|
37
|
+
)
|
|
38
|
+
gpus = GPUtil.getGPUs() # 获取所有可见的GPU设备列表
|
|
39
|
+
# gpu.memoryUtil表示GPU的内存利用率
|
|
40
|
+
# gpu.load表示GPU的计算利用率
|
|
41
|
+
# gpu.memoryTotal表示GPU的总内存
|
|
42
|
+
# gpu.memoryUsed表示GPU的已使用内存
|
|
43
|
+
# gpu.memoryFree表示GPU的空闲内存
|
|
44
|
+
# 返回所有显卡的利用率列表
|
|
45
|
+
gpu_utilization = np.array([gpu.load * 100 for gpu in gpus])
|
|
46
|
+
if gpu_id is not None:
|
|
47
|
+
return gpu_utilization[gpu_id]
|
|
48
|
+
return gpu_utilization
|
|
49
|
+
|
|
50
|
+
|
|
56
51
|
# 监控显卡利用率
|
|
57
|
-
def monitor_gpu_utilization(check_interval=
|
|
58
|
-
MonitorGPUs=
|
|
52
|
+
def monitor_gpu_utilization(check_interval=600, duration_limit=1800, threshold=20,
|
|
53
|
+
MonitorGPUs=None,
|
|
54
|
+
from_name="凌逆战",
|
|
59
55
|
from_email="xxxxx@qq.com",
|
|
60
56
|
from_password="xxxxxxx",
|
|
61
57
|
to_email="xxxxx@qq.com"):
|
|
@@ -65,58 +61,35 @@ def monitor_gpu_utilization(check_interval=5, duration_limit=300, threshold=20,
|
|
|
65
61
|
threshold = 20 # 利用率阈值
|
|
66
62
|
Returns:
|
|
67
63
|
"""
|
|
68
|
-
|
|
69
|
-
max_alarm_times_1day = 10 # 24小时内最大报警次数
|
|
70
|
-
|
|
71
|
-
timer_start = time.time()
|
|
72
|
-
last_alarm_time = 0
|
|
73
|
-
host_ip = subprocess.check_output(['hostname', '-I']).decode('utf-8').split()[0]
|
|
74
|
-
print(f"Host IP: {host_ip}")
|
|
64
|
+
host_ip = subprocess.check_output(['hostname', '-I']).decode('utf-8').split()[0] # 172.16.64.33
|
|
75
65
|
|
|
76
66
|
while True:
|
|
77
|
-
utilization_mean = []
|
|
78
|
-
for i in range(duration_limit // check_interval):
|
|
79
|
-
utilization =
|
|
80
|
-
if utilization is None:
|
|
81
|
-
continue
|
|
67
|
+
utilization_mean = [] # 平均利用率
|
|
68
|
+
for i in range(duration_limit // check_interval): # 30分钟平均一次, 每10分钟检查一次
|
|
69
|
+
utilization = get_gpu_utilization2(MonitorGPUs)
|
|
82
70
|
utilization = np.array(utilization)
|
|
83
71
|
utilization_mean.append(utilization)
|
|
84
|
-
time.sleep(check_interval) # 每隔
|
|
85
|
-
|
|
86
|
-
utilization_mean = np.mean(np.array(utilization_mean), axis=0)
|
|
72
|
+
time.sleep(check_interval) # 每隔check_interval分钟检查一次
|
|
73
|
+
utilization_mean = np.mean(utilization_mean, axis=0)
|
|
87
74
|
t_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
88
|
-
print(f"
|
|
89
|
-
|
|
90
|
-
if utilization_mean is not None:
|
|
91
|
-
alarm_flag = False
|
|
92
|
-
for gpu_id in MonitorGPUs:
|
|
93
|
-
if utilization_mean[gpu_id] < threshold:
|
|
94
|
-
alarm_flag = True
|
|
95
|
-
break
|
|
75
|
+
print(f"{t_now} GPU Utilization: {utilization}") # [95. 50. 91. 83. 84. 65. 95. 82.]
|
|
96
76
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
alarm_times += 1
|
|
108
|
-
last_alarm_time = time.time()
|
|
109
|
-
# clean max_alarm_times_1day if 24 hours passed
|
|
110
|
-
if time.time() - timer_start > 24 * 3600.0:
|
|
111
|
-
alarm_times = 0
|
|
112
|
-
timer_start = time.time()
|
|
77
|
+
# 如果有GPU利用率低于阈值, 则发送邮件
|
|
78
|
+
if np.any(utilization_mean < threshold):
|
|
79
|
+
send_QQEmail(title=f"GPU利用率警告",
|
|
80
|
+
content=f"服务器: {host_ip}\n {t_now} GPU利用率为:{utilization}. 低于阈值 {threshold}% \n",
|
|
81
|
+
from_name=from_name,
|
|
82
|
+
from_email=from_email,
|
|
83
|
+
from_password=from_password,
|
|
84
|
+
to_email=to_email)
|
|
85
|
+
print(f"Alarm sent: GPU utilization below {threshold}% for GPU(s) {utilization_mean}")
|
|
113
86
|
|
|
114
87
|
|
|
115
88
|
if __name__ == "__main__":
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
89
|
+
# print(get_gpu_utilization2(gpu_id=3))
|
|
90
|
+
monitor_gpu_utilization(check_interval=1, duration_limit=3, threshold=100,
|
|
91
|
+
MonitorGPUs=[4, 5, 6, 7],
|
|
92
|
+
from_name="xxx",
|
|
93
|
+
from_email="xxxxxx@qq.com",
|
|
94
|
+
from_password="xxxxxxx",
|
|
95
|
+
to_email="xxxxxx@qq.com", )
|
neverlib/utils/floder.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-03-26 22:13:21
|
|
4
|
+
Description: 路径层级互换(支持 Windows / Linux / macOS)
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from neverlib.utils import get_path_list
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_leaf_folders(directory):
|
|
14
|
+
# 获取最底层的文件夹路径
|
|
15
|
+
leaf_folders = []
|
|
16
|
+
for root, dirs, _ in os.walk(directory):
|
|
17
|
+
if not dirs: # 如果当前文件夹没有子文件夹
|
|
18
|
+
leaf_folders.append(root)
|
|
19
|
+
return leaf_folders
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def rename_files_and_folders(directory, replace='_-', replacement='_'):
|
|
23
|
+
# 将路径的指定字符替换为指定字符
|
|
24
|
+
for root, dirs, files in os.walk(directory):
|
|
25
|
+
for filename in files:
|
|
26
|
+
if replace in filename:
|
|
27
|
+
new_filename = filename.replace(replace, replacement)
|
|
28
|
+
old_path = os.path.join(root, filename)
|
|
29
|
+
new_path = os.path.join(root, new_filename)
|
|
30
|
+
os.rename(old_path, new_path)
|
|
31
|
+
print(f'Renamed file: {old_path} -> {new_path}')
|
|
32
|
+
|
|
33
|
+
for folder in dirs:
|
|
34
|
+
if replace in folder:
|
|
35
|
+
new_folder = folder.replace(replace, replacement)
|
|
36
|
+
old_path = os.path.join(root, folder)
|
|
37
|
+
new_path = os.path.join(root, new_folder)
|
|
38
|
+
os.rename(old_path, new_path)
|
|
39
|
+
print(f'Renamed folder: {old_path} -> {new_path}')
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def del_empty_folders(path):
|
|
43
|
+
"""递归删除空文件夹(先删除子文件夹, 再删除父文件夹)"""
|
|
44
|
+
if not os.path.isdir(path):
|
|
45
|
+
return
|
|
46
|
+
|
|
47
|
+
# 获取子文件夹
|
|
48
|
+
subfolders = [
|
|
49
|
+
os.path.join(path, d) for d in os.listdir(path)
|
|
50
|
+
if os.path.isdir(os.path.join(path, d))
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
# 递归处理子文件夹
|
|
54
|
+
for subfolder in subfolders:
|
|
55
|
+
del_empty_folders(subfolder)
|
|
56
|
+
|
|
57
|
+
# 如果文件夹为空, 则删除
|
|
58
|
+
if not os.listdir(path):
|
|
59
|
+
os.rmdir(path)
|
|
60
|
+
print(f"删除空文件夹: {path}")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def change_path(source_dir, idx_1, idx_2):
|
|
64
|
+
# 统一路径类型
|
|
65
|
+
source_dir = Path(source_dir)
|
|
66
|
+
path_list = [Path(p) for p in get_path_list(str(source_dir), end="*.*")]
|
|
67
|
+
|
|
68
|
+
print("\n📂 文件路径变更预览(前 5 个):\n")
|
|
69
|
+
preview_count = min(5, len(path_list))
|
|
70
|
+
|
|
71
|
+
for i in range(preview_count):
|
|
72
|
+
path = path_list[i]
|
|
73
|
+
parts = list(path.parts) # 各层级组成的元组
|
|
74
|
+
try:
|
|
75
|
+
# 交换指定索引层级
|
|
76
|
+
parts[idx_1], parts[idx_2] = parts[idx_2], parts[idx_1]
|
|
77
|
+
except IndexError:
|
|
78
|
+
print(f"[警告] 索引越界:文件 {path}")
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
new_path = Path(*parts)
|
|
82
|
+
print(f"原路径: {path}")
|
|
83
|
+
print(f"新路径: {new_path}\n")
|
|
84
|
+
|
|
85
|
+
# 交互确认
|
|
86
|
+
user_input = input("是否确认对所有文件进行以上变更? (y/n): ").strip().lower()
|
|
87
|
+
if user_input != "y":
|
|
88
|
+
print("❌ 操作已取消. ")
|
|
89
|
+
return
|
|
90
|
+
|
|
91
|
+
print("\n🚀 开始批量处理文件...")
|
|
92
|
+
for path in path_list:
|
|
93
|
+
parts = list(path.parts)
|
|
94
|
+
try:
|
|
95
|
+
parts[idx_1], parts[idx_2] = parts[idx_2], parts[idx_1]
|
|
96
|
+
except IndexError:
|
|
97
|
+
print(f"[跳过] 索引错误:{path}")
|
|
98
|
+
continue
|
|
99
|
+
|
|
100
|
+
new_path = Path(*parts)
|
|
101
|
+
new_path.parent.mkdir(parents=True, exist_ok=True)
|
|
102
|
+
try:
|
|
103
|
+
shutil.move(str(path), str(new_path))
|
|
104
|
+
except Exception as e:
|
|
105
|
+
print(f"[错误] 无法移动 {path} -> {new_path}: {e}")
|
|
106
|
+
|
|
107
|
+
print("\n✅ 所有文件处理完成!")
|
|
108
|
+
del_empty_folders(str(source_dir)) # 清理空文件夹
|
|
109
|
+
print("🧹 已清空空目录. ")
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
# 示例路径(自动根据系统适配)
|
|
114
|
+
source_dir = Path("/data01/never/Dataset/kws_data/Command_Word_NN_wrong_high/Crowdsourcing_wash/zh_kws/train/RealPerson")
|
|
115
|
+
change_path(source_dir, 10, 11)
|
neverlib/utils/lazy_expose.py
CHANGED
neverlib/utils/lazy_module.py
CHANGED
|
@@ -10,7 +10,7 @@ from typing import Dict, Tuple, Union, Iterable
|
|
|
10
10
|
|
|
11
11
|
class LazyModule(ModuleType):
|
|
12
12
|
"""
|
|
13
|
-
|
|
13
|
+
一个懒加载模块, 可以按需导入子模块或对象.
|
|
14
14
|
- 支持 name -> 'pkg.subpkg.module' 的懒导入(返回模块对象)
|
|
15
15
|
- 支持 name -> ('pkg.subpkg.module', 'attr') 的懒导入(返回模块内的对象)
|
|
16
16
|
- 透传 __spec__/__path__/__all__ 以兼容 import 系统和 IDE 补全
|
|
@@ -35,7 +35,7 @@ class LazyModule(ModuleType):
|
|
|
35
35
|
self.__dict__["__spec__"] = module_spec
|
|
36
36
|
if module_path is not None:
|
|
37
37
|
self.__dict__["__path__"] = list(module_path)
|
|
38
|
-
#
|
|
38
|
+
# 若存在代理模块, 则不预设 __all__, 避免阻断 import * 的 dir() 行为
|
|
39
39
|
if not proxy_modules:
|
|
40
40
|
self.__dict__["__all__"] = sorted(list(import_structure.keys()))
|
|
41
41
|
|
|
@@ -56,7 +56,7 @@ class LazyModule(ModuleType):
|
|
|
56
56
|
obj = getattr(module, attr_name)
|
|
57
57
|
setattr(self, name, obj)
|
|
58
58
|
return obj
|
|
59
|
-
#
|
|
59
|
+
# 若未在显式映射中, 尝试到代理模块中查找公开符号
|
|
60
60
|
for proxy_name in self.__dict__.get("_proxy_modules", []):
|
|
61
61
|
mod_cache_key = f"__proxy__::{proxy_name}"
|
|
62
62
|
module = self.__dict__["_modules"].get(mod_cache_key)
|
|
@@ -67,12 +67,12 @@ class LazyModule(ModuleType):
|
|
|
67
67
|
obj = getattr(module, name)
|
|
68
68
|
setattr(self, name, obj)
|
|
69
69
|
return obj
|
|
70
|
-
raise AttributeError(f"Module {self.__name__} has no attribute {name}") #
|
|
70
|
+
raise AttributeError(f"Module {self.__name__} has no attribute {name}") # 如果模块没有属性, 则抛出异常
|
|
71
71
|
|
|
72
72
|
def __dir__(self):
|
|
73
|
-
#
|
|
73
|
+
# 将懒加载键与现有属性合并, 便于 IDE 补全
|
|
74
74
|
keys = set(self.__dict__.keys()) | set(self.__dict__.get("_import_structure", {}).keys())
|
|
75
|
-
#
|
|
75
|
+
# 若配置了代理模块, 将其公开符号加入补全(会触发代理模块导入)
|
|
76
76
|
for proxy_name in self.__dict__.get("_proxy_modules", []):
|
|
77
77
|
module = importlib.import_module(proxy_name)
|
|
78
78
|
for n in dir(module):
|
neverlib/utils/message.py
CHANGED
|
@@ -26,10 +26,9 @@ def send_QQEmail(title, content, from_name, from_email, from_password, to_email)
|
|
|
26
26
|
HOST = "smtp.qq.com"
|
|
27
27
|
|
|
28
28
|
# 设置邮件正文
|
|
29
|
-
message = MIMEText(content, "
|
|
29
|
+
message = MIMEText(content, "html", "utf-8")
|
|
30
30
|
message["Subject"] = Header(title, charset="utf-8")
|
|
31
31
|
message["From"] = formataddr((from_name, from_email))
|
|
32
|
-
# message["From"] = Header(from_email)
|
|
33
32
|
message["To"] = Header(to_email)
|
|
34
33
|
|
|
35
34
|
try:
|
|
@@ -48,7 +47,7 @@ def send_QQEmail_with_images(title, content, from_name, from_email, from_passwor
|
|
|
48
47
|
"""
|
|
49
48
|
发送包含多张PNG图片附件的QQ邮件
|
|
50
49
|
:param title: 邮件标题
|
|
51
|
-
:param content:
|
|
50
|
+
:param content: 邮件正文内容(支持HTML格式)
|
|
52
51
|
:param from_email: 发件人邮箱
|
|
53
52
|
:param from_password: 发件人邮箱SMTP授权码
|
|
54
53
|
:param to_email: 收件人邮箱
|
neverlib/utils/pcm.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
import numpy as np
|
|
3
|
+
import soundfile as sf
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def pcm2wav(pcm_path, wav_path, sr=16000, channels=1, subtype='PCM_16'):
|
|
7
|
+
"""
|
|
8
|
+
将pcm文件转换为wav文件
|
|
9
|
+
:param pcm_path: pcm文件路径
|
|
10
|
+
:param wav_path: wav文件路径
|
|
11
|
+
:param sr: 采样率
|
|
12
|
+
:param channels: 声道数
|
|
13
|
+
:param subtype: 子类型
|
|
14
|
+
"""
|
|
15
|
+
pcm_data = np.fromfile(pcm_path, dtype=np.int16)
|
|
16
|
+
pcm_data = pcm_data.reshape(-1, channels) # 支持多通道
|
|
17
|
+
sf.write(wav_path, pcm_data, sr, subtype=subtype)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def wav2pcm(wav_path, pcm_path):
|
|
21
|
+
"""
|
|
22
|
+
将wav文件转换为pcm文件
|
|
23
|
+
:param wav_path: wav文件路径
|
|
24
|
+
:param pcm_path: pcm文件路径
|
|
25
|
+
"""
|
|
26
|
+
data, _ = sf.read(wav_path, dtype='int16')
|
|
27
|
+
data.tofile(pcm_path)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def read_pcm(file_path, channels=5, sample_rate=16000, sample_width=2):
|
|
31
|
+
# Read raw binary data from the PCM file
|
|
32
|
+
with open(file_path, 'rb') as f:
|
|
33
|
+
raw_data = f.read()
|
|
34
|
+
|
|
35
|
+
# Convert binary data to numpy array of the correct dtype
|
|
36
|
+
audio_data = np.frombuffer(raw_data, dtype=np.int16)
|
|
37
|
+
|
|
38
|
+
# Reshape the data into a 2D array with shape (num_frames, channels)
|
|
39
|
+
num_frames = len(audio_data) // channels
|
|
40
|
+
audio_data = audio_data.reshape((num_frames, channels))
|
|
41
|
+
|
|
42
|
+
return audio_data
|