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
|
@@ -350,16 +350,16 @@
|
|
|
350
350
|
"print(\"\\n音量增强方法分析总结:\")\n",
|
|
351
351
|
"print(\"=\" * 80)\n",
|
|
352
352
|
"print(\"1. Linear增强 (volume_aug_linmax):\")\n",
|
|
353
|
-
"print(\" -
|
|
354
|
-
"print(\" -
|
|
353
|
+
"print(\" - 基于峰值的线性增益, 目标为最大峰值为指定的线性值\")\n",
|
|
354
|
+
"print(\" - 特点:保持动态范围不变, 整体增强或减弱\")\n",
|
|
355
355
|
"print(\" - 适用场景:需要精确控制峰值而不改变音频动态特性的场合\")\n",
|
|
356
356
|
"print(\"\\n2. dBrms增强 (volume_aug_dbrms):\")\n",
|
|
357
|
-
"print(\" - 基于RMS
|
|
358
|
-
"print(\" -
|
|
357
|
+
"print(\" - 基于RMS电平的增益, 目标为指定的dB电平\")\n",
|
|
358
|
+
"print(\" - 特点:以能量均值为基准, 更接近人耳感知\")\n",
|
|
359
359
|
"print(\" - 适用场景:需要统一音频能量电平的场合\")\n",
|
|
360
360
|
"print(\"\\n3. LUFS增强 (volume_aug_lufs):\")\n",
|
|
361
|
-
"print(\" -
|
|
362
|
-
"print(\" -
|
|
361
|
+
"print(\" - 基于国际响度标准的增益, 符合广播标准\")\n",
|
|
362
|
+
"print(\" - 特点:考虑人耳频率加权, 最接近人耳响度感知\")\n",
|
|
363
363
|
"print(\" - 适用场景:广播、流媒体、专业音频处理等需要符合响度标准的场合\")\n",
|
|
364
364
|
"print(\"=\" * 80)"
|
|
365
365
|
]
|
|
@@ -386,9 +386,9 @@
|
|
|
386
386
|
"3. **LUFS增强 (volume_aug_lufs)**\n",
|
|
387
387
|
" - 基于感知响度单位(LUFS)的增益\n",
|
|
388
388
|
" - 符合广播标准的响度归一化\n",
|
|
389
|
-
" -
|
|
389
|
+
" - 考虑人耳感知加权, 最接近人耳响度感知\n",
|
|
390
390
|
"\n",
|
|
391
|
-
"
|
|
391
|
+
"各方法适用于不同场景, 可根据需求选择合适的音量增强方式. "
|
|
392
392
|
]
|
|
393
393
|
}
|
|
394
394
|
],
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"source": [
|
|
11
11
|
"# 音频滤波器示例\n",
|
|
12
12
|
"\n",
|
|
13
|
-
"这个notebook展示了如何使用 neverlib.filter
|
|
13
|
+
"这个notebook展示了如何使用 neverlib.filter 中的各种滤波器. 我们将展示:\n",
|
|
14
14
|
"1. 各种滤波器的频率响应\n",
|
|
15
15
|
"2. 实际音频处理示例\n",
|
|
16
16
|
"3. 与scipy原生函数的对比\n",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"source": [
|
|
81
81
|
"# 滤波器示例\n",
|
|
82
82
|
"\n",
|
|
83
|
-
"
|
|
83
|
+
"下面我们将展示各种滤波器的频率响应. 我们使用以下参数:\n",
|
|
84
84
|
"- 采样率 fs = 16000 Hz\n",
|
|
85
85
|
"- 截止频率 fc = 1000 Hz\n",
|
|
86
86
|
"- 品质因数 Q = 1/√2 ≈ 0.707 (Butterworth响应)\n",
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
"source": [
|
|
249
249
|
"# 实际音频处理示例\n",
|
|
250
250
|
"\n",
|
|
251
|
-
"
|
|
251
|
+
"下面我们将展示如何使用这些滤波器处理实际的音频信号. 我们将:\n",
|
|
252
252
|
"1. 加载一个音频文件\n",
|
|
253
253
|
"2. 应用不同的滤波器\n",
|
|
254
254
|
"3. 对比处理前后的频谱\n"
|
|
@@ -318,7 +318,7 @@
|
|
|
318
318
|
"source": [
|
|
319
319
|
"# EQ滤波\n",
|
|
320
320
|
"\n",
|
|
321
|
-
"通过多个Biquand滤波器, 组成一个EQ滤波器,
|
|
321
|
+
"通过多个Biquand滤波器, 组成一个EQ滤波器, 实现音频的均衡处理. "
|
|
322
322
|
]
|
|
323
323
|
},
|
|
324
324
|
{
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"mode 0~3\n",
|
|
13
13
|
"\n",
|
|
14
14
|
"0: 最低的语音检测敏感度, \n",
|
|
15
|
-
"- 认为背景噪声不是语音, 适合环境较安静,
|
|
16
|
-
"- 适合环境较安静,
|
|
15
|
+
"- 认为背景噪声不是语音, 适合环境较安静, 背景噪声少的情况. \n",
|
|
16
|
+
"- 适合环境较安静, 背景噪声少的情况. \n",
|
|
17
17
|
"\n",
|
|
18
18
|
"3: 最高的语音检测敏感度, \n",
|
|
19
|
-
"- VAD 会非常积极地尝试将任何噪声过滤掉,
|
|
20
|
-
"- 适合环境较吵,
|
|
19
|
+
"- VAD 会非常积极地尝试将任何噪声过滤掉, 只有明确的语音才会被认为是语音. \n",
|
|
20
|
+
"- 适合环境较吵, 背景噪声多的情况. "
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"source": [
|
|
8
8
|
"# whisper base模型\n",
|
|
9
9
|
"\n",
|
|
10
|
-
"whisper 检测的 词与词之间的VAD
|
|
10
|
+
"whisper 检测的 词与词之间的VAD 都是连着的. 但其实音频不是\n",
|
|
11
11
|
"\n",
|
|
12
12
|
"而且Whisper的VAD并没有直接提供调参接口, 所以无法调整VAD的参数"
|
|
13
13
|
]
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"source": [
|
|
171
171
|
"# whisper large-v3 模型\n",
|
|
172
172
|
"\n",
|
|
173
|
-
"词与词之间的VAD
|
|
173
|
+
"词与词之间的VAD 都是连着的. 但其实音频不是\n",
|
|
174
174
|
"```\n",
|
|
175
175
|
"# Word: Sometimes, Start: 0.00s, End: 0.70s\n",
|
|
176
176
|
"# Word: he, Start: 0.70s, End: 0.86s\n",
|
neverlib/LLM/__init__.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This file is auto-generated. Do NOT edit manually.
|
|
2
|
+
# Generated by neverlib.QA.gen_init
|
|
3
|
+
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
# 仅在类型检查时导入, 提供IDE补全支持
|
|
8
|
+
from .bailian import AliyunSession, Aliyun_App
|
|
9
|
+
from .image import chat_with_ai_image, image_to_base64_uri
|
|
10
|
+
from .text import chat
|
|
11
|
+
|
|
12
|
+
# 运行时使用懒加载
|
|
13
|
+
from lazy_loader import attach
|
|
14
|
+
|
|
15
|
+
__getattr__, __dir__, __all__ = attach(
|
|
16
|
+
__name__,
|
|
17
|
+
submodules=[
|
|
18
|
+
"bailian",
|
|
19
|
+
"image",
|
|
20
|
+
"text",
|
|
21
|
+
],
|
|
22
|
+
submod_attrs={
|
|
23
|
+
"bailian": ['AliyunSession', 'Aliyun_App'],
|
|
24
|
+
"image": ['chat_with_ai_image', 'image_to_base64_uri'],
|
|
25
|
+
"text": ['chat'],
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# 显式声明 __all__ 以便 IDE 识别
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
__all__ = [
|
|
32
|
+
'AliyunSession',
|
|
33
|
+
'Aliyun_App',
|
|
34
|
+
'chat_with_ai_image',
|
|
35
|
+
'image_to_base64_uri',
|
|
36
|
+
'chat',
|
|
37
|
+
]
|
neverlib/LLM/bailian.py
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2026-01-07 00:47:30
|
|
4
|
+
Description: 阿里云百炼应用调用封装
|
|
5
|
+
'''
|
|
6
|
+
import os
|
|
7
|
+
from typing import Optional, Dict, Any, List
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def Aliyun_App(inputs: str, prompt: Optional[str] = None,
|
|
11
|
+
api_key: Optional[str] = None,
|
|
12
|
+
app_id: Optional[str] = None,
|
|
13
|
+
stream: bool = False,
|
|
14
|
+
messages: Optional[List[Dict[str, str]]] = None,
|
|
15
|
+
workspace: Optional[str] = None,
|
|
16
|
+
temperature: Optional[float] = None,
|
|
17
|
+
top_p: Optional[float] = None,
|
|
18
|
+
top_k: Optional[int] = None,
|
|
19
|
+
return_full_response: bool = False,
|
|
20
|
+
**kwargs
|
|
21
|
+
) -> str | Dict[str, Any]:
|
|
22
|
+
"""
|
|
23
|
+
调用阿里云百炼应用
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
inputs: 输入文本
|
|
27
|
+
prompt: 提示词(可选, 会与inputs拼接)
|
|
28
|
+
api_key: API密钥
|
|
29
|
+
app_id: 应用ID(必填)
|
|
30
|
+
stream: 是否启用流式输出
|
|
31
|
+
messages: 对话消息列表, 格式: [{'role': 'user', 'content': '问题'}, {'role': 'assistant', 'content': '回答'}]
|
|
32
|
+
workspace: 工作空间
|
|
33
|
+
temperature: 温度参数 (0-2), 控制随机性和多样性
|
|
34
|
+
- 值越高:输出越随机、越有创造性
|
|
35
|
+
- 值越低:输出越确定、越保守
|
|
36
|
+
- 建议: 财经分析用0.1-0.3, 创意内容用0.7-1.0
|
|
37
|
+
top_p: 核采样参数(Nucleus Sampling), 范围 (0-1)
|
|
38
|
+
- 作用: 从累积概率达到p的候选词中采样
|
|
39
|
+
- 0.1: 只考虑累积概率前10%的词(更确定)
|
|
40
|
+
- 0.9: 考虑累积概率前90%的词(更多样)
|
|
41
|
+
- 建议: 专业分析用0.1-0.3, 常规对话用0.7, 创意内容用0.9
|
|
42
|
+
top_k: Top-K采样候选集大小
|
|
43
|
+
- 作用: 每次生成只从概率最高的k个词中选择
|
|
44
|
+
- 值越小:确定性越高(如10-30)
|
|
45
|
+
- 值越大:随机性越高(如50-100)
|
|
46
|
+
- 默认0: 禁用top_k策略, 只使用top_p
|
|
47
|
+
return_full_response: 是否返回完整响应(包含thoughts、session_id等)
|
|
48
|
+
**kwargs: 其他API支持的参数
|
|
49
|
+
- enable_thinking: 启用深度思考模式
|
|
50
|
+
- has_thoughts: 包含思考内容
|
|
51
|
+
- seed: 随机种子(用于复现结果)
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
str: 默认返回响应文本字符串
|
|
55
|
+
dict: 当 return_full_response=True 时返回完整响应字典:
|
|
56
|
+
{
|
|
57
|
+
"status": "success" | "error",
|
|
58
|
+
"text": "响应文本",
|
|
59
|
+
"request_id": "请求ID",
|
|
60
|
+
"session_id": "会话ID(可选)",
|
|
61
|
+
"finish_reason": "结束原因(可选)",
|
|
62
|
+
"thoughts": [...] # 思考过程(可选),
|
|
63
|
+
"doc_references": [...] # 文档引用(可选),
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Raises:
|
|
67
|
+
ValueError: 参数验证失败
|
|
68
|
+
|
|
69
|
+
来源: https://help.aliyun.com/zh/model-studio/call-single-agent-application/
|
|
70
|
+
"""
|
|
71
|
+
try:
|
|
72
|
+
from http import HTTPStatus
|
|
73
|
+
from dashscope import Application
|
|
74
|
+
except ImportError as e:
|
|
75
|
+
if 'dashscope' in str(e):
|
|
76
|
+
raise ImportError("请安装dashscope库: pip install dashscope")
|
|
77
|
+
else:
|
|
78
|
+
raise ImportError(f"导入失败: {e}. 如果是因为HTTPStatus, 请确保使用Python 3.5或更高版本")
|
|
79
|
+
|
|
80
|
+
if not app_id:
|
|
81
|
+
raise ValueError("app_id参数不能为空")
|
|
82
|
+
|
|
83
|
+
if not inputs and not prompt:
|
|
84
|
+
raise ValueError("inputs和prompt至少需要提供一个")
|
|
85
|
+
|
|
86
|
+
# 构建输入
|
|
87
|
+
if prompt and inputs:
|
|
88
|
+
llm_input = f"{prompt}\n{inputs}"
|
|
89
|
+
elif prompt:
|
|
90
|
+
llm_input = prompt
|
|
91
|
+
else:
|
|
92
|
+
llm_input = inputs
|
|
93
|
+
|
|
94
|
+
# 构建API调用参数
|
|
95
|
+
call_params = {
|
|
96
|
+
'app_id': app_id,
|
|
97
|
+
'prompt': llm_input,
|
|
98
|
+
'stream': stream
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# 添加可选参数
|
|
102
|
+
if api_key:
|
|
103
|
+
call_params['api_key'] = api_key
|
|
104
|
+
if messages:
|
|
105
|
+
call_params['messages'] = messages
|
|
106
|
+
if workspace:
|
|
107
|
+
call_params['workspace'] = workspace
|
|
108
|
+
if temperature is not None:
|
|
109
|
+
call_params['temperature'] = temperature
|
|
110
|
+
if top_p is not None:
|
|
111
|
+
call_params['top_p'] = top_p
|
|
112
|
+
if top_k is not None:
|
|
113
|
+
call_params['top_k'] = top_k
|
|
114
|
+
|
|
115
|
+
# 添加额外参数
|
|
116
|
+
call_params.update(kwargs)
|
|
117
|
+
|
|
118
|
+
# 调用API
|
|
119
|
+
response = Application.call(**call_params)
|
|
120
|
+
|
|
121
|
+
# 检查响应状态
|
|
122
|
+
if response.status_code != HTTPStatus.OK:
|
|
123
|
+
if return_full_response:
|
|
124
|
+
return {
|
|
125
|
+
"status": "error",
|
|
126
|
+
"text": "",
|
|
127
|
+
"message": f"API调用失败: [{response.code}] {response.message}",
|
|
128
|
+
"code": response.code
|
|
129
|
+
}
|
|
130
|
+
return "API调用失败"
|
|
131
|
+
|
|
132
|
+
# 提取文本
|
|
133
|
+
output_text = response.output.text if hasattr(response.output, 'text') else str(response.output)
|
|
134
|
+
|
|
135
|
+
# 如果需要完整响应
|
|
136
|
+
if return_full_response:
|
|
137
|
+
result = {
|
|
138
|
+
"status": "success",
|
|
139
|
+
"text": output_text,
|
|
140
|
+
"request_id": response.request_id
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# 添加 session_id
|
|
144
|
+
if hasattr(response.output, 'session_id') and response.output.session_id:
|
|
145
|
+
result['session_id'] = response.output.session_id
|
|
146
|
+
|
|
147
|
+
# 添加 finish_reason
|
|
148
|
+
if hasattr(response.output, 'finish_reason') and response.output.finish_reason:
|
|
149
|
+
result['finish_reason'] = response.output.finish_reason
|
|
150
|
+
|
|
151
|
+
# 添加思考过程(深度思考)
|
|
152
|
+
if hasattr(response.output, 'thoughts') and response.output.thoughts:
|
|
153
|
+
result['thoughts'] = [
|
|
154
|
+
{
|
|
155
|
+
'thought': t.thought,
|
|
156
|
+
'action_type': t.action_type,
|
|
157
|
+
'action_name': t.action_name,
|
|
158
|
+
'observation': t.observation
|
|
159
|
+
}
|
|
160
|
+
for t in response.output.thoughts
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
# 添加文档引用(RAG场景)
|
|
164
|
+
if hasattr(response.output, 'doc_references') and response.output.doc_references:
|
|
165
|
+
result['doc_references'] = [
|
|
166
|
+
{
|
|
167
|
+
'title': ref.title,
|
|
168
|
+
'text': ref.text,
|
|
169
|
+
'doc_name': ref.doc_name
|
|
170
|
+
}
|
|
171
|
+
for ref in response.output.doc_references
|
|
172
|
+
]
|
|
173
|
+
|
|
174
|
+
return result
|
|
175
|
+
|
|
176
|
+
return output_text
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class AliyunSession:
|
|
180
|
+
"""
|
|
181
|
+
阿里云百炼应用会话管理类
|
|
182
|
+
自动维护对话历史, 支持多轮对话
|
|
183
|
+
|
|
184
|
+
使用示例:
|
|
185
|
+
session = AliyunSession(app_id="xxx", api_key="xxx", temperature=0.3)
|
|
186
|
+
|
|
187
|
+
# 第一轮对话
|
|
188
|
+
result1 = session.chat("介绍一下股票市场")
|
|
189
|
+
|
|
190
|
+
# 第二轮对话(自动带上历史)
|
|
191
|
+
result2 = session.chat("那A股和港股有什么区别?")
|
|
192
|
+
|
|
193
|
+
# 查看历史
|
|
194
|
+
print(session.get_history_text())
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
def __init__(self, app_id: str, api_key: Optional[str] = None,
|
|
198
|
+
max_history: int = 10, **default_params):
|
|
199
|
+
"""
|
|
200
|
+
初始化会话
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
app_id: 应用ID
|
|
204
|
+
api_key: API密钥
|
|
205
|
+
max_history: 最多保留的历史轮数(默认10轮, 超过会自动删除最早的)
|
|
206
|
+
**default_params: 默认参数(如temperature, top_p等)
|
|
207
|
+
"""
|
|
208
|
+
self.app_id = app_id
|
|
209
|
+
self.api_key = api_key
|
|
210
|
+
self.max_history = max_history
|
|
211
|
+
self.default_params = default_params
|
|
212
|
+
self.messages: List[Dict[str, str]] = []
|
|
213
|
+
self.session_id: Optional[str] = None
|
|
214
|
+
|
|
215
|
+
def chat(self, inputs: str, prompt: Optional[str] = None, **kwargs) -> str | Dict[str, Any]:
|
|
216
|
+
"""
|
|
217
|
+
发送消息并自动维护历史
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
inputs: 用户输入
|
|
221
|
+
prompt: 系统提示词(可选)
|
|
222
|
+
**kwargs: 覆盖默认参数(如 return_full_response=True)
|
|
223
|
+
|
|
224
|
+
Returns:
|
|
225
|
+
str: 默认返回响应文本
|
|
226
|
+
dict: 当 kwargs 中包含 return_full_response=True 时返回完整响应
|
|
227
|
+
"""
|
|
228
|
+
# 合并默认参数和传入参数
|
|
229
|
+
call_params = {**self.default_params, **kwargs}
|
|
230
|
+
|
|
231
|
+
# 调用API
|
|
232
|
+
result = Aliyun_App(
|
|
233
|
+
inputs=inputs,
|
|
234
|
+
prompt=prompt,
|
|
235
|
+
app_id=self.app_id,
|
|
236
|
+
api_key=self.api_key,
|
|
237
|
+
messages=self.messages.copy() if self.messages else None,
|
|
238
|
+
**call_params
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
# 如果调用成功, 添加到历史
|
|
242
|
+
# 添加用户消息
|
|
243
|
+
user_content = f"{prompt}\n{inputs}" if prompt else inputs
|
|
244
|
+
self.messages.append({"role": "user", "content": user_content})
|
|
245
|
+
|
|
246
|
+
# 添加助手回复
|
|
247
|
+
self.messages.append({"role": "assistant", "content": result})
|
|
248
|
+
|
|
249
|
+
# 限制历史长度(保留最近的 max_history 轮对话)
|
|
250
|
+
if len(self.messages) > self.max_history * 2:
|
|
251
|
+
removed = len(self.messages) - self.max_history * 2
|
|
252
|
+
self.messages = self.messages[removed:]
|
|
253
|
+
|
|
254
|
+
return result
|
|
255
|
+
|
|
256
|
+
def clear_history(self):
|
|
257
|
+
"""清空对话历史"""
|
|
258
|
+
self.messages.clear()
|
|
259
|
+
self.session_id = None
|
|
260
|
+
|
|
261
|
+
def get_history(self) -> List[Dict[str, str]]:
|
|
262
|
+
"""获取当前对话历史"""
|
|
263
|
+
return self.messages.copy()
|
|
264
|
+
|
|
265
|
+
def get_history_text(self) -> str:
|
|
266
|
+
"""获取格式化的对话历史文本"""
|
|
267
|
+
history_lines = []
|
|
268
|
+
for msg in self.messages:
|
|
269
|
+
role = "用户" if msg["role"] == "user" else "助手"
|
|
270
|
+
history_lines.append(f"{role}: {msg['content'][:100]}...")
|
|
271
|
+
return "\n\n".join(history_lines)
|
|
272
|
+
|
|
273
|
+
def set_history(self, messages: List[Dict[str, str]]):
|
|
274
|
+
"""设置对话历史(用于恢复会话)"""
|
|
275
|
+
self.messages = messages.copy()
|
|
276
|
+
|
|
277
|
+
def __repr__(self):
|
|
278
|
+
return f"AliyunSession(app_id={self.app_id}, history={len(self.messages) // 2}轮)"
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
if __name__ == "__main__":
|
|
282
|
+
import dotenv
|
|
283
|
+
dotenv.load_dotenv()
|
|
284
|
+
|
|
285
|
+
# 使用示例1: 基本调用
|
|
286
|
+
print("=" * 50)
|
|
287
|
+
print("示例1: 基本调用")
|
|
288
|
+
print("=" * 50)
|
|
289
|
+
result = Aliyun_App(
|
|
290
|
+
inputs="你好, 请介绍一下最近的A股市场情况",
|
|
291
|
+
app_id=os.getenv("ALIYUN_APP_ID"),
|
|
292
|
+
api_key=os.getenv("DASHSCOPE_API_KEY")
|
|
293
|
+
)
|
|
294
|
+
print(f"响应: {result[:200]}...")
|
|
295
|
+
|
|
296
|
+
# 使用示例2: 使用会话管理类(自动维护历史)
|
|
297
|
+
print("\n" + "=" * 50)
|
|
298
|
+
print("示例2: 使用AliyunSession - 多轮对话")
|
|
299
|
+
print("=" * 50)
|
|
300
|
+
|
|
301
|
+
session = AliyunSession(
|
|
302
|
+
app_id=os.getenv("ALIYUN_APP_ID"),
|
|
303
|
+
api_key=os.getenv("DASHSCOPE_API_KEY"),
|
|
304
|
+
temperature=0.5,
|
|
305
|
+
max_history=5
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
# 第一轮
|
|
309
|
+
print("\n[第1轮]")
|
|
310
|
+
r1 = session.chat("介绍一下A股市场")
|
|
311
|
+
print(f"用户: 介绍一下A股市场")
|
|
312
|
+
print(f"助手: {r1[:150]}...")
|
|
313
|
+
|
|
314
|
+
# 第二轮(自动带上历史)
|
|
315
|
+
print("\n[第2轮]")
|
|
316
|
+
r2 = session.chat("那主要有哪些板块?")
|
|
317
|
+
print(f"用户: 那主要有哪些板块?")
|
|
318
|
+
print(f"助手: {r2[:150]}...")
|
|
319
|
+
|
|
320
|
+
# 查看会话信息
|
|
321
|
+
print(f"\n{session}")
|
|
322
|
+
|
|
323
|
+
# 使用示例3: 启用深度思考模式(返回完整响应)
|
|
324
|
+
print("\n" + "=" * 50)
|
|
325
|
+
print("示例3: 深度思考模式")
|
|
326
|
+
print("=" * 50)
|
|
327
|
+
result_thinking = Aliyun_App(
|
|
328
|
+
inputs="分析今日A股大盘走势",
|
|
329
|
+
app_id=os.getenv("ALIYUN_APP_ID"),
|
|
330
|
+
api_key=os.getenv("DASHSCOPE_API_KEY"),
|
|
331
|
+
return_full_response=True,
|
|
332
|
+
enable_thinking=True
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
if isinstance(result_thinking, dict):
|
|
336
|
+
print(f"状态: {result_thinking.get('status')}")
|
|
337
|
+
print(f"响应: {result_thinking.get('text', '')[:200]}...")
|
|
338
|
+
|
|
339
|
+
if result_thinking.get('thoughts'):
|
|
340
|
+
print(f"\n发现 {len(result_thinking['thoughts'])} 条思考过程")
|
|
341
|
+
if result_thinking.get('finish_reason'):
|
|
342
|
+
print(f"结束原因: {result_thinking['finish_reason']}")
|
neverlib/LLM/image.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2026-01-07 00:44:24
|
|
4
|
+
Description:
|
|
5
|
+
'''
|
|
6
|
+
import os
|
|
7
|
+
import base64
|
|
8
|
+
import mimetypes
|
|
9
|
+
from openai import OpenAI
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def image_to_base64_uri(file_path):
|
|
13
|
+
"""
|
|
14
|
+
将本地图片文件转换为Base64编码的Data URI.
|
|
15
|
+
"""
|
|
16
|
+
# 自动猜测MIME类型
|
|
17
|
+
mime_type, _ = mimetypes.guess_type(file_path)
|
|
18
|
+
if mime_type is None:
|
|
19
|
+
# 如果无法猜测, 可以根据文件扩展名设置一个默认值
|
|
20
|
+
if file_path.lower().endswith(('.jpg', '.jpeg')):
|
|
21
|
+
mime_type = 'image/jpeg'
|
|
22
|
+
elif file_path.lower().endswith('.png'):
|
|
23
|
+
mime_type = 'image/png'
|
|
24
|
+
elif file_path.lower().endswith('.gif'):
|
|
25
|
+
mime_type = 'image/gif'
|
|
26
|
+
elif file_path.lower().endswith('.webp'):
|
|
27
|
+
mime_type = 'image/webp'
|
|
28
|
+
else:
|
|
29
|
+
print(
|
|
30
|
+
f"Warning: Could not determine MIME type for {file_path}. Skipping.")
|
|
31
|
+
return None # 或者抛出错误
|
|
32
|
+
|
|
33
|
+
with open(file_path, "rb") as image_file:
|
|
34
|
+
binary_data = image_file.read()
|
|
35
|
+
base64_encoded_data = base64.b64encode(binary_data)
|
|
36
|
+
base64_string = base64_encoded_data.decode('utf-8')
|
|
37
|
+
return f"data:{mime_type};base64,{base64_string}"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def chat_with_ai_image(inputs, image_path_list, prompt=None,
|
|
41
|
+
model="doubao-1-5-vision-pro-32k-250115"):
|
|
42
|
+
"""
|
|
43
|
+
使用豆包大模型分析图片和文本内容.
|
|
44
|
+
支持多个图片, 图片可以是本地路径或网络URL.
|
|
45
|
+
"""
|
|
46
|
+
image_contents, messages = [], []
|
|
47
|
+
for image_path in image_path_list:
|
|
48
|
+
if "http" in image_path: # 是网络图片
|
|
49
|
+
image_contents.append({
|
|
50
|
+
"type": "image_url",
|
|
51
|
+
"image_url": {"url": image_path}
|
|
52
|
+
})
|
|
53
|
+
else: # 是本地图片路径
|
|
54
|
+
base64_uri = image_to_base64_uri(image_path)
|
|
55
|
+
image_contents.append({
|
|
56
|
+
"type": "image_url",
|
|
57
|
+
"image_url": {"url": base64_uri}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
image_contents.append({"type": "text", "text": inputs})
|
|
61
|
+
if prompt:
|
|
62
|
+
messages.append({"role": "system", "content": prompt})
|
|
63
|
+
messages.append({"role": "user", "content": image_contents})
|
|
64
|
+
|
|
65
|
+
client = OpenAI(
|
|
66
|
+
base_url="https://ark.cn-beijing.volces.com/api/v3",
|
|
67
|
+
api_key=os.environ.get("DOUBAO_API_KEY"),
|
|
68
|
+
)
|
|
69
|
+
response = client.chat.completions.create(
|
|
70
|
+
model=model,
|
|
71
|
+
messages=messages,
|
|
72
|
+
)
|
|
73
|
+
return response.choices[0].message.content
|
neverlib/LLM/text.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2026-01-07 00:35:35
|
|
4
|
+
Description:
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def chat(inputs, prompt=None, model=None, timeout=180, base_url=None, api_key=None):
|
|
9
|
+
"""
|
|
10
|
+
使用OpenAI API进行对话(非流式)
|
|
11
|
+
"""
|
|
12
|
+
try:
|
|
13
|
+
from openai import OpenAI
|
|
14
|
+
except ImportError:
|
|
15
|
+
raise ImportError("请安装openai库: pip install openai")
|
|
16
|
+
assert model, "model不能为空"
|
|
17
|
+
assert base_url and api_key, "base_url和api_key不能为空"
|
|
18
|
+
client = OpenAI(base_url=base_url, api_key=api_key, timeout=timeout)
|
|
19
|
+
|
|
20
|
+
messages = []
|
|
21
|
+
if prompt:
|
|
22
|
+
messages.append({"role": "system", "content": prompt})
|
|
23
|
+
messages.append({"role": "user", "content": inputs})
|
|
24
|
+
|
|
25
|
+
completion = client.chat.completions.create(
|
|
26
|
+
model=model, messages=messages, timeout=timeout)
|
|
27
|
+
|
|
28
|
+
output = completion.choices[0].message.content
|
|
29
|
+
# 如果有引用, 则添加到输出中
|
|
30
|
+
if hasattr(completion, "references"):
|
|
31
|
+
output += "\n" + str(completion.references)
|
|
32
|
+
return output
|