neverlib 0.2.4__py3-none-any.whl → 0.2.6__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/.history/Docs/audio_aug/del_20250827162530.py +0 -0
- neverlib/.history/Docs/audio_aug/del_20250827162540.py +2 -0
- neverlib/.history/Docs/audio_aug/del_20250827162541.py +7 -0
- neverlib/.history/Docs/audio_aug/del_20250827162606.py +7 -0
- neverlib/.history/Docs/audio_aug/del_20250827162637.py +8 -0
- neverlib/.history/Docs/audio_aug/del_20250827162645.py +8 -0
- neverlib/.history/Docs/audio_aug/del_20250827162723.py +9 -0
- neverlib/.history/Docs/audio_aug/del_20250827162739.py +9 -0
- neverlib/.history/Docs/audio_aug/test_snr_20250827161751.py +55 -0
- neverlib/.history/Docs/audio_aug/test_snr_20250827161754.py +55 -0
- neverlib/.history/Docs/audio_aug/test_snr_20250827161833.py +54 -0
- neverlib/.history/Docs/audio_aug/test_snr_20250827162017.py +56 -0
- neverlib/.history/Docs/audio_aug/test_snr_20250827162021.py +57 -0
- neverlib/.history/Docs/audio_aug/test_snr_20250827162028.py +57 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162738.py +9 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162819.py +9 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162830.py +9 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162846.py +9 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162851.py +9 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162903.py +10 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162921.py +10 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827162926.py +10 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827163030.py +10 -0
- neverlib/.history/Docs/audio_aug_test/del_20250827163032.py +10 -0
- neverlib/.history/QA/html2markdown_20250822234112.md +0 -0
- neverlib/.history/QA/html2markdown_20250822234140.py +9 -0
- neverlib/.history/QA/html2markdown_20250822234141.md +9 -0
- neverlib/.history/QA/html2markdown_20250822234159.py +12 -0
- neverlib/.history/QA/html2markdown_20250822234200.py +17 -0
- neverlib/.history/QA/html2markdown_20250822234236.py +17 -0
- neverlib/.history/QA/html2markdown_20250822234340.py +14 -0
- neverlib/.history/QA/html2markdown_20250822234522.py +18 -0
- neverlib/.history/QA/html2markdown_20250822234601.py +20 -0
- neverlib/.history/QA/html2markdown_20250822234615.py +22 -0
- neverlib/.history/QA/html2markdown_20250822234715.py +28 -0
- neverlib/.history/QA/html2markdown_20250822234720.py +27 -0
- neverlib/.history/QA/html2markdown_20250822234903.py +27 -0
- neverlib/.history/__init___20250805234212.py +41 -0
- neverlib/.history/__init___20250904102635.py +39 -0
- neverlib/.history/__init___20250904102836.py +34 -0
- neverlib/.history/__init___20250904102838.py +39 -0
- neverlib/.history/__init___20250904102851.py +33 -0
- neverlib/.history/audio_aug/audio_aug_20250826155913.py +158 -0
- neverlib/.history/audio_aug/audio_aug_20250826164159.py +159 -0
- neverlib/.history/audio_aug/audio_aug_20250826164217.py +160 -0
- neverlib/.history/audio_aug/audio_aug_20250826164408.py +161 -0
- neverlib/.history/audio_aug/audio_aug_20250826164423.py +161 -0
- neverlib/.history/audio_aug/audio_aug_20250826164529.py +161 -0
- neverlib/.history/audio_aug/audio_aug_20250826164824.py +161 -0
- neverlib/.history/audio_aug/audio_aug_20250826164932.py +162 -0
- neverlib/.history/audio_aug/audio_aug_20250826164947.py +162 -0
- neverlib/.history/audio_aug/audio_aug_20250826165403.py +162 -0
- neverlib/.history/audio_aug/audio_aug_20250826165421.py +162 -0
- neverlib/.history/audio_aug/audio_aug_20250826165509.py +163 -0
- neverlib/.history/audio_aug/audio_aug_20250826165702.py +163 -0
- neverlib/.history/audio_aug/audio_aug_20250826165732.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826170041.py +163 -0
- neverlib/.history/audio_aug/audio_aug_20250826170105.py +164 -0
- neverlib/.history/audio_aug/audio_aug_20250826170154.py +164 -0
- neverlib/.history/audio_aug/audio_aug_20250826170220.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826170221.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826170228.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826170231.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826212001.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826220038.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826220133.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826220148.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826220154.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826220156.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826220314.py +165 -0
- neverlib/.history/audio_aug/audio_aug_20250826220343.py +184 -0
- neverlib/.history/audio_aug/audio_aug_20250826220345.py +184 -0
- neverlib/.history/audio_aug/audio_aug_20250826220349.py +184 -0
- neverlib/.history/audio_aug/audio_aug_20250826220429.py +184 -0
- neverlib/.history/audio_aug/audio_aug_20250826220447.py +184 -0
- neverlib/.history/audio_aug/audio_aug_20250826220601.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220638.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220641.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220647.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220653.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220655.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220731.py +185 -0
- neverlib/.history/audio_aug/audio_aug_20250826220739.py +185 -0
- neverlib/.history/audio_aug/audio_aug_20250826220747.py +185 -0
- neverlib/.history/audio_aug/audio_aug_20250826220801.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220822.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826220901.py +186 -0
- neverlib/.history/audio_aug/audio_aug_20250826221107.py +187 -0
- neverlib/.history/audio_aug/audio_aug_20250826221310.py +188 -0
- neverlib/.history/audio_aug/audio_aug_20250826221353.py +191 -0
- neverlib/.history/audio_aug/audio_aug_20250826221821.py +191 -0
- neverlib/.history/audio_aug/audio_aug_20250826221838.py +191 -0
- neverlib/.history/audio_aug/audio_aug_20250826221906.py +191 -0
- neverlib/.history/audio_aug/audio_aug_20250826221930.py +191 -0
- neverlib/.history/audio_aug/audio_aug_20250826221939.py +191 -0
- neverlib/.history/audio_aug/audio_aug_20250826221955.py +191 -0
- neverlib/.history/audio_aug/audio_aug_20250826222008.py +197 -0
- neverlib/.history/audio_aug/audio_aug_20250826222017.py +200 -0
- neverlib/.history/audio_aug/audio_aug_20250826222046.py +203 -0
- neverlib/.history/audio_aug/audio_aug_20250826222105.py +203 -0
- neverlib/.history/audio_aug/audio_aug_20250826222206.py +203 -0
- neverlib/.history/audio_aug/audio_aug_20250826222302.py +203 -0
- neverlib/.history/audio_aug/audio_aug_20250826222336.py +203 -0
- neverlib/.history/audio_aug/audio_aug_20250826222455.py +204 -0
- neverlib/.history/audio_aug/audio_aug_20250826222526.py +204 -0
- neverlib/.history/audio_aug/audio_aug_20250826222541.py +204 -0
- neverlib/.history/audio_aug/audio_aug_20250826222624.py +202 -0
- neverlib/.history/audio_aug/audio_aug_20250826222714.py +205 -0
- neverlib/.history/audio_aug/audio_aug_20250826222820.py +205 -0
- neverlib/.history/audio_aug/audio_aug_20250826222827.py +205 -0
- neverlib/.history/audio_aug/audio_aug_20250826222927.py +232 -0
- neverlib/.history/audio_aug/audio_aug_20250826223009.py +232 -0
- neverlib/.history/audio_aug/audio_aug_20250826223054.py +232 -0
- neverlib/.history/audio_aug/audio_aug_20250826223225.py +233 -0
- neverlib/.history/audio_aug/audio_aug_20250826223344.py +236 -0
- neverlib/.history/audio_aug/audio_aug_20250826223356.py +236 -0
- neverlib/.history/audio_aug/audio_aug_20250826223955.py +242 -0
- neverlib/.history/audio_aug/audio_aug_20250826224210.py +240 -0
- neverlib/.history/audio_aug/audio_aug_20250826224250.py +242 -0
- neverlib/.history/audio_aug/audio_aug_20250826224323.py +280 -0
- neverlib/.history/audio_aug/audio_aug_20250826224452.py +263 -0
- neverlib/.history/audio_aug/audio_aug_20250826224455.py +263 -0
- neverlib/.history/audio_aug/audio_aug_20250826224502.py +263 -0
- neverlib/.history/audio_aug/audio_aug_20250826224528.py +263 -0
- neverlib/.history/audio_aug/audio_aug_20250826224658.py +263 -0
- neverlib/.history/audio_aug/audio_aug_20250826224833.py +264 -0
- neverlib/.history/audio_aug/audio_aug_20250826225013.py +269 -0
- neverlib/.history/audio_aug/audio_aug_20250826225050.py +269 -0
- neverlib/.history/audio_aug/audio_aug_20250826225241.py +268 -0
- neverlib/.history/audio_aug/audio_aug_20250826225315.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826225404.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826225502.py +265 -0
- neverlib/.history/audio_aug/audio_aug_20250826225950.py +267 -0
- neverlib/.history/audio_aug/audio_aug_20250826225959.py +268 -0
- neverlib/.history/audio_aug/audio_aug_20250826230222.py +271 -0
- neverlib/.history/audio_aug/audio_aug_20250826230248.py +270 -0
- neverlib/.history/audio_aug/audio_aug_20250826230638.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826230755.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826230941.py +265 -0
- neverlib/.history/audio_aug/audio_aug_20250826231054.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826231117.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826231219.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826232330.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250826232352.py +266 -0
- neverlib/.history/audio_aug/audio_aug_20250827152748.py +268 -0
- neverlib/.history/audio_aug/audio_aug_20250827152806.py +268 -0
- neverlib/.history/audio_aug/audio_aug_20250827152808.py +268 -0
- neverlib/.history/audio_aug/audio_aug_20250827152917.py +283 -0
- neverlib/.history/audio_aug/audio_aug_20250827152929.py +281 -0
- neverlib/.history/audio_aug/audio_aug_20250827153100.py +286 -0
- neverlib/.history/audio_aug/audio_aug_20250827153102.py +286 -0
- neverlib/.history/audio_aug/audio_aug_20250827153301.py +295 -0
- neverlib/.history/audio_aug/audio_aug_20250827153331.py +298 -0
- neverlib/.history/audio_aug/audio_aug_20250827153525.py +303 -0
- neverlib/.history/audio_aug/audio_aug_20250827153533.py +304 -0
- neverlib/.history/audio_aug/audio_aug_20250827153541.py +321 -0
- neverlib/.history/audio_aug/audio_aug_20250827153805.py +322 -0
- neverlib/.history/audio_aug/audio_aug_20250827153832.py +323 -0
- neverlib/.history/audio_aug/audio_aug_20250827153836.py +324 -0
- neverlib/.history/audio_aug/audio_aug_20250827153846.py +324 -0
- neverlib/.history/audio_aug/audio_aug_20250827153859.py +325 -0
- neverlib/.history/audio_aug/audio_aug_20250827154453.py +337 -0
- neverlib/.history/audio_aug/audio_aug_20250827154513.py +355 -0
- neverlib/.history/audio_aug/audio_aug_20250827154538.py +356 -0
- neverlib/.history/audio_aug/audio_aug_20250827154541.py +357 -0
- neverlib/.history/audio_aug/audio_aug_20250827154612.py +357 -0
- neverlib/.history/audio_aug/audio_aug_20250827154657.py +360 -0
- neverlib/.history/audio_aug/audio_aug_20250827154708.py +360 -0
- neverlib/.history/audio_aug/audio_aug_20250827154728.py +366 -0
- neverlib/.history/audio_aug/audio_aug_20250827154755.py +367 -0
- neverlib/.history/audio_aug/audio_aug_20250827154800.py +367 -0
- neverlib/.history/audio_aug/audio_aug_20250827154917.py +368 -0
- neverlib/.history/audio_aug/audio_aug_20250827154928.py +369 -0
- neverlib/.history/audio_aug/audio_aug_20250827154932.py +370 -0
- neverlib/.history/audio_aug/audio_aug_20250827154947.py +372 -0
- neverlib/.history/audio_aug/audio_aug_20250827155015.py +375 -0
- neverlib/.history/audio_aug/audio_aug_20250827155106.py +375 -0
- neverlib/.history/audio_aug/audio_aug_20250827155114.py +393 -0
- neverlib/.history/audio_aug/audio_aug_20250827155207.py +415 -0
- neverlib/.history/audio_aug/audio_aug_20250827155300.py +415 -0
- neverlib/.history/audio_aug/audio_aug_20250827155321.py +471 -0
- neverlib/.history/audio_aug/audio_aug_20250827164703.py +471 -0
- neverlib/.history/audio_aug/audio_aug_20250827164749.py +471 -0
- neverlib/.history/audio_aug/audio_aug_20250827165252.py +472 -0
- neverlib/.history/audio_aug/audio_aug_20250827165334.py +472 -0
- neverlib/.history/audio_aug/audio_aug_20250827165404.py +473 -0
- neverlib/.history/audio_aug/audio_aug_20250827165610.py +473 -0
- neverlib/.history/audio_aug/audio_aug_20250827165805.py +473 -0
- neverlib/.history/audio_aug/audio_aug_20250827170056.py +473 -0
- neverlib/.history/audio_aug/audio_aug_20250827170106.py +472 -0
- neverlib/.history/audio_aug/audio_aug_20250827170143.py +472 -0
- neverlib/.history/audio_aug/audio_aug_20250827170216.py +472 -0
- neverlib/.history/audio_aug/audio_aug_20250827170218.py +472 -0
- neverlib/.history/audio_aug/audio_aug_20250827170314.py +472 -0
- neverlib/.history/audio_aug/audio_aug_20250827171500.py +471 -0
- neverlib/.history/audio_aug/audio_aug_20250827172347.py +471 -0
- neverlib/.history/audio_aug/audio_aug_20250827172558.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250827172559.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250827172801.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250827182522.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250827182526.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250827182626.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250827182715.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250904185444.py +470 -0
- neverlib/.history/audio_aug/audio_aug_20250904185538.py +445 -0
- neverlib/.history/data_analyze/__init___20250806204158.py +14 -0
- neverlib/.history/data_analyze/__init___20250827163248.py +14 -0
- neverlib/.history/filter/auto_eq/freq_eq_20250821143140.py +76 -0
- neverlib/.history/filter/auto_eq/freq_eq_20250821153208.py +76 -0
- neverlib/.history/filter/auto_eq/freq_eq_20250821153214.py +76 -0
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110521.py +385 -0
- neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110652.py +385 -0
- neverlib/.history/filter/common_20250806002134.py +37 -0
- neverlib/.history/filter/common_20250821120448.py +49 -0
- neverlib/.history/filter/common_20250821120453.py +49 -0
- neverlib/.history/metrics/snr_20250827224201.py +182 -0
- neverlib/.history/metrics/snr_20250827234019.py +186 -0
- neverlib/.history/metrics/snr_20250827234028.py +186 -0
- neverlib/.history/metrics/snr_20250827234030.py +186 -0
- neverlib/.history/utils/audio_split_20250805234209.py +268 -0
- neverlib/.history/utils/audio_split_20250904185309.py +268 -0
- neverlib/.history/utils/utils_20250813165516.py +330 -0
- neverlib/.history/utils/utils_20250904181341.py +328 -0
- neverlib/.history/utils/utils_20250904185546.py +352 -0
- neverlib/.history/utils/utils_20250904185548.py +353 -0
- neverlib/.history/utils/utils_20250904185603.py +353 -0
- neverlib/.history/utils/utils_20250904185636.py +353 -0
- neverlib/.history/utils/utils_20250904185658.py +358 -0
- neverlib/.history/utils/utils_20250904190053.py +359 -0
- 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 +247 -0
- neverlib/.specstory/history/2025-08-26_11-54Z-oserror-missing-shared-object-file.md +87 -0
- 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 +296 -0
- neverlib/.specstory/history/2025-08-27_08-29Z-delete-python-file-command.md +211 -0
- 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 +357 -0
- neverlib/Docs/audio_aug_test/test_snr.py +55 -0
- neverlib/Docs/audio_aug_test/test_volume.py +0 -0
- neverlib/QA/html2markdown.py +27 -0
- neverlib/__init__.py +10 -20
- neverlib/audio_aug/__init__.py +6 -1
- neverlib/audio_aug/audio_aug.py +360 -55
- neverlib/data_analyze/__init__.py +8 -2
- neverlib/data_analyze/temporal_features.py +1 -1
- neverlib/filter/__init__.py +9 -3
- neverlib/filter/auto_eq/freq_eq.py +1 -1
- neverlib/filter/auto_eq/ga_eq_basic.py +3 -3
- neverlib/filter/common.py +12 -0
- neverlib/metrics/snr.py +5 -3
- neverlib/utils/__init__.py +14 -7
- neverlib/utils/lazy_module.py +81 -0
- neverlib/utils/message.py +3 -8
- neverlib/utils/utils.py +32 -3
- neverlib/vad/__init__.py +16 -9
- neverlib/vad/utils.py +20 -6
- {neverlib-0.2.4.dist-info → neverlib-0.2.6.dist-info}/METADATA +21 -17
- neverlib-0.2.6.dist-info/RECORD +467 -0
- neverlib-0.2.4.dist-info/RECORD +0 -229
- /neverlib/{Docs/audio_aug/test_snr.py → .history/Docs/audio_aug/test_snr_20250827162033.py} +0 -0
- {neverlib-0.2.4.dist-info → neverlib-0.2.6.dist-info}/WHEEL +0 -0
- {neverlib-0.2.4.dist-info → neverlib-0.2.6.dist-info}/licenses/LICENSE +0 -0
- {neverlib-0.2.4.dist-info → neverlib-0.2.6.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-09-04
|
|
4
|
+
Description: 懒加载模块
|
|
5
|
+
'''
|
|
6
|
+
import sys
|
|
7
|
+
import importlib
|
|
8
|
+
from types import ModuleType
|
|
9
|
+
from typing import Dict, Tuple, Union, Iterable
|
|
10
|
+
|
|
11
|
+
class LazyModule(ModuleType):
|
|
12
|
+
"""
|
|
13
|
+
一个懒加载模块,可以按需导入子模块或对象。
|
|
14
|
+
- 支持 name -> 'pkg.subpkg.module' 的懒导入(返回模块对象)
|
|
15
|
+
- 支持 name -> ('pkg.subpkg.module', 'attr') 的懒导入(返回模块内的对象)
|
|
16
|
+
- 透传 __spec__/__path__/__all__ 以兼容 import 系统和 IDE 补全
|
|
17
|
+
"""
|
|
18
|
+
def __init__(self, name: str, import_structure: Dict[str, Union[str, Tuple[str, str]]], module_spec=None, module_path: Iterable[str] = None):
|
|
19
|
+
super().__init__(name)
|
|
20
|
+
# 提取代理模块配置: __all_from__ 可为 str 或 list[str]
|
|
21
|
+
proxy_modules = []
|
|
22
|
+
if import_structure and "__all_from__" in import_structure:
|
|
23
|
+
raw = import_structure.get("__all_from__")
|
|
24
|
+
if isinstance(raw, (list, tuple)):
|
|
25
|
+
proxy_modules = list(raw)
|
|
26
|
+
elif isinstance(raw, str):
|
|
27
|
+
proxy_modules = [raw]
|
|
28
|
+
# 不参与普通键映射
|
|
29
|
+
import_structure = {k: v for k, v in import_structure.items() if k != "__all_from__"}
|
|
30
|
+
|
|
31
|
+
self.__dict__["_import_structure"] = import_structure # 导入结构
|
|
32
|
+
self.__dict__["_modules"] = {} # 模块字典
|
|
33
|
+
self.__dict__["_proxy_modules"] = proxy_modules # 代理模块(其公开符号可直接在包下访问)
|
|
34
|
+
if module_spec is not None:
|
|
35
|
+
self.__dict__["__spec__"] = module_spec
|
|
36
|
+
if module_path is not None:
|
|
37
|
+
self.__dict__["__path__"] = list(module_path)
|
|
38
|
+
# 若存在代理模块,则不预设 __all__,避免阻断 import * 的 dir() 行为
|
|
39
|
+
if not proxy_modules:
|
|
40
|
+
self.__dict__["__all__"] = sorted(list(import_structure.keys()))
|
|
41
|
+
|
|
42
|
+
def __getattr__(self, name):
|
|
43
|
+
import_structure = self.__dict__["_import_structure"] # 导入结构
|
|
44
|
+
if name in import_structure:
|
|
45
|
+
target = import_structure[name]
|
|
46
|
+
# 目标是模块名: 懒导入并返回模块
|
|
47
|
+
if isinstance(target, str):
|
|
48
|
+
module = importlib.import_module(target)
|
|
49
|
+
self.__dict__["_modules"][name] = module
|
|
50
|
+
setattr(self, name, module)
|
|
51
|
+
return module
|
|
52
|
+
# 目标是 (模块, 属性): 懒导入并返回对象
|
|
53
|
+
if isinstance(target, tuple) and len(target) == 2:
|
|
54
|
+
module_name, attr_name = target
|
|
55
|
+
module = importlib.import_module(module_name)
|
|
56
|
+
obj = getattr(module, attr_name)
|
|
57
|
+
setattr(self, name, obj)
|
|
58
|
+
return obj
|
|
59
|
+
# 若未在显式映射中,尝试到代理模块中查找公开符号
|
|
60
|
+
for proxy_name in self.__dict__.get("_proxy_modules", []):
|
|
61
|
+
mod_cache_key = f"__proxy__::{proxy_name}"
|
|
62
|
+
module = self.__dict__["_modules"].get(mod_cache_key)
|
|
63
|
+
if module is None:
|
|
64
|
+
module = importlib.import_module(proxy_name)
|
|
65
|
+
self.__dict__["_modules"][mod_cache_key] = module
|
|
66
|
+
if hasattr(module, name):
|
|
67
|
+
obj = getattr(module, name)
|
|
68
|
+
setattr(self, name, obj)
|
|
69
|
+
return obj
|
|
70
|
+
raise AttributeError(f"Module {self.__name__} has no attribute {name}") # 如果模块没有属性,则抛出异常
|
|
71
|
+
|
|
72
|
+
def __dir__(self):
|
|
73
|
+
# 将懒加载键与现有属性合并,便于 IDE 补全
|
|
74
|
+
keys = set(self.__dict__.keys()) | set(self.__dict__.get("_import_structure", {}).keys())
|
|
75
|
+
# 若配置了代理模块,将其公开符号加入补全(会触发代理模块导入)
|
|
76
|
+
for proxy_name in self.__dict__.get("_proxy_modules", []):
|
|
77
|
+
module = importlib.import_module(proxy_name)
|
|
78
|
+
for n in dir(module):
|
|
79
|
+
if not n.startswith('_'):
|
|
80
|
+
keys.add(n)
|
|
81
|
+
return sorted(keys)
|
neverlib/utils/message.py
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
'''
|
|
2
2
|
Author: 凌逆战 | Never
|
|
3
|
-
Date: 2025-02-13
|
|
4
|
-
Description:
|
|
3
|
+
Date: 2025-02-13
|
|
4
|
+
Description: 通过邮件发送通知
|
|
5
5
|
'''
|
|
6
|
-
|
|
7
|
-
# Author:凌逆战 | Never
|
|
8
|
-
# Date: 2024/2/1
|
|
9
|
-
"""
|
|
10
|
-
通过邮件发送通知
|
|
11
|
-
"""
|
|
6
|
+
|
|
12
7
|
import os
|
|
13
8
|
import smtplib
|
|
14
9
|
from email.header import Header
|
neverlib/utils/utils.py
CHANGED
|
@@ -28,6 +28,37 @@ def get_path_list(source_path, end="*.wav", shuffle=False):
|
|
|
28
28
|
return wav_list
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
def get_audio_segments(sentence_len, wav_path_list, sr=16000, insert_silence=None):
|
|
32
|
+
"""
|
|
33
|
+
从音频列表中随机拼接指定长度音频
|
|
34
|
+
Args:
|
|
35
|
+
sentence_len: 需要返回的音频长度
|
|
36
|
+
wav_path_list: 音频路径列表
|
|
37
|
+
sr: 采样率
|
|
38
|
+
insert_silence: 插入静音的长度
|
|
39
|
+
Returns:返回指定长度的音频
|
|
40
|
+
"""
|
|
41
|
+
merge_wav_len = 0
|
|
42
|
+
wav_list = []
|
|
43
|
+
while merge_wav_len < sentence_len:
|
|
44
|
+
wav_path = random.choice(wav_path_list)
|
|
45
|
+
wav, wav_sr = sf.read(wav_path, always_2d=True, dtype='float32')
|
|
46
|
+
assert wav_sr == sr, f"音频采样率是{wav_sr}, 期望{sr}"
|
|
47
|
+
merge_wav_len += len(wav)
|
|
48
|
+
wav_list.append(wav)
|
|
49
|
+
if insert_silence is not None:
|
|
50
|
+
silence_len = random.randint(0, insert_silence)
|
|
51
|
+
silence = np.zeros((silence_len, ), dtype=np.float32)
|
|
52
|
+
merge_wav_len += silence_len
|
|
53
|
+
wav_list.append(silence)
|
|
54
|
+
wav = np.concatenate(wav_list, axis=0)
|
|
55
|
+
if len(wav) > sentence_len:
|
|
56
|
+
# 随机截取clean_len
|
|
57
|
+
start = random.randint(0, merge_wav_len - sentence_len)
|
|
58
|
+
wav = wav[start:start + sentence_len, :]
|
|
59
|
+
return wav
|
|
60
|
+
|
|
61
|
+
|
|
31
62
|
def rename_files_and_folders(directory, replace='_-', replacement='_'):
|
|
32
63
|
# 将路径的指定字符替换为指定字符
|
|
33
64
|
for root, dirs, files in os.walk(directory):
|
|
@@ -67,9 +98,7 @@ def TrainValSplit(dataset_dir, train_dir, val_dir, percentage=0.9):
|
|
|
67
98
|
:param val_dir: 验证集地址
|
|
68
99
|
:param percentage: 分割百分比
|
|
69
100
|
"""
|
|
70
|
-
wav_path_list =
|
|
71
|
-
random.seed(10086)
|
|
72
|
-
random.shuffle(wav_path_list) # 打乱列表的顺序
|
|
101
|
+
wav_path_list = get_path_list(dataset_dir, end="*.wav", shuffle=True)
|
|
73
102
|
total_wav_num = len(wav_path_list)
|
|
74
103
|
# 计算训练集和验证集的分割点
|
|
75
104
|
split_idx = int(total_wav_num * percentage)
|
neverlib/vad/__init__.py
CHANGED
|
@@ -7,12 +7,19 @@ from neverlib.vad import EnergyVad_C
|
|
|
7
7
|
如果没有用户必须完整路径
|
|
8
8
|
from neverlib.vad.VAD_Energy import EnergyVad_C
|
|
9
9
|
"""
|
|
10
|
-
from
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
from lazy_loader import attach
|
|
11
|
+
|
|
12
|
+
__getattr__, __dir__, __all__ = attach(
|
|
13
|
+
__name__,
|
|
14
|
+
submodules=["PreProcess", "VAD_Energy", "VAD_funasr", "VAD_Silero", "VAD_statistics", "VAD_vadlib", "VAD_WebRTC", "VAD_whisper", "utils"],
|
|
15
|
+
submod_attrs={
|
|
16
|
+
"VAD_Energy": ["EnergyVad_C"],
|
|
17
|
+
"VAD_funasr": ["FunASR_VAD_C"],
|
|
18
|
+
"VAD_Silero": ["Silero_VAD_C"],
|
|
19
|
+
"VAD_statistics": ["Statistics_VAD"],
|
|
20
|
+
"VAD_vadlib": ["Vadlib_C"],
|
|
21
|
+
"VAD_WebRTC": ["WebRTC_VAD_C"],
|
|
22
|
+
"VAD_whisper": ["Whisper_VAD_C"],
|
|
23
|
+
"utils": ["from_vadArray_to_vadEndpoint", "vad2nad"],
|
|
24
|
+
},
|
|
25
|
+
)
|
neverlib/vad/utils.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"""
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-08-22
|
|
4
|
+
Description:
|
|
5
|
+
'''
|
|
7
6
|
import numpy as np
|
|
8
7
|
|
|
9
8
|
|
|
@@ -65,3 +64,18 @@ def vad2nad(vad, total_length):
|
|
|
65
64
|
nad.append({'start': last_end, 'end': total_length})
|
|
66
65
|
|
|
67
66
|
return nad
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def vad_smooth(vad, sr=16000, min_speech_duration=0.2, min_silent_duration=0.2):
|
|
70
|
+
# 把极短的语音帧 置零
|
|
71
|
+
speech_point_list = from_vadArray_to_vadEndpoint(vad)
|
|
72
|
+
for endpoint in speech_point_list:
|
|
73
|
+
if endpoint["end"] - endpoint["start"] < min_speech_duration * sr:
|
|
74
|
+
vad[endpoint["start"]:endpoint["end"]] = 0
|
|
75
|
+
|
|
76
|
+
# 把极端的静音帧 置1
|
|
77
|
+
silent_point_list = from_vadArray_to_vadEndpoint(1 - vad)
|
|
78
|
+
for endpoint in silent_point_list:
|
|
79
|
+
if endpoint["end"] - endpoint["start"] < min_silent_duration * sr:
|
|
80
|
+
vad[endpoint["start"]:endpoint["end"]] = 1
|
|
81
|
+
return vad
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: neverlib
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: A successful sign for python setup
|
|
5
5
|
Author-email: "Never.Ling" <1786088386@qq.com>
|
|
6
6
|
License: MIT
|
|
@@ -9,19 +9,26 @@ Project-URL: Bug Tracker, https://github.com/yourusername/neverlib/issues
|
|
|
9
9
|
Project-URL: Documentation, https://github.com/yourusername/neverlib
|
|
10
10
|
Project-URL: Source Code, https://github.com/yourusername/neverlib
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
16
|
Classifier: Operating System :: OS Independent
|
|
14
17
|
Requires-Python: >=3.6
|
|
15
18
|
Description-Content-Type: text/markdown
|
|
16
19
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
|
|
20
|
+
Requires-Dist: lazy-loader>=0.4
|
|
21
|
+
Provides-Extra: analysis
|
|
22
|
+
Requires-Dist: numpy; extra == "analysis"
|
|
23
|
+
Requires-Dist: scipy; extra == "analysis"
|
|
24
|
+
Requires-Dist: tqdm; extra == "analysis"
|
|
25
|
+
Requires-Dist: joblib; extra == "analysis"
|
|
26
|
+
Requires-Dist: noisereduce; extra == "analysis"
|
|
27
|
+
Provides-Extra: io
|
|
28
|
+
Requires-Dist: soundfile; extra == "io"
|
|
29
|
+
Requires-Dist: pydub; extra == "io"
|
|
30
|
+
Provides-Extra: plot
|
|
31
|
+
Requires-Dist: matplotlib; extra == "plot"
|
|
25
32
|
Provides-Extra: vad
|
|
26
33
|
Requires-Dist: torch; extra == "vad"
|
|
27
34
|
Requires-Dist: torchaudio; extra == "vad"
|
|
@@ -33,14 +40,11 @@ Requires-Dist: transformers; extra == "vad"
|
|
|
33
40
|
Provides-Extra: gpu
|
|
34
41
|
Requires-Dist: GPUtil; extra == "gpu"
|
|
35
42
|
Provides-Extra: all
|
|
36
|
-
Requires-Dist:
|
|
37
|
-
Requires-Dist:
|
|
38
|
-
Requires-Dist:
|
|
39
|
-
Requires-Dist:
|
|
40
|
-
Requires-Dist:
|
|
41
|
-
Requires-Dist: openai-whisper; extra == "all"
|
|
42
|
-
Requires-Dist: transformers; extra == "all"
|
|
43
|
-
Requires-Dist: GPUtil; extra == "all"
|
|
43
|
+
Requires-Dist: neverlib[analysis]; extra == "all"
|
|
44
|
+
Requires-Dist: neverlib[io]; extra == "all"
|
|
45
|
+
Requires-Dist: neverlib[plot]; extra == "all"
|
|
46
|
+
Requires-Dist: neverlib[vad]; extra == "all"
|
|
47
|
+
Requires-Dist: neverlib[gpu]; extra == "all"
|
|
44
48
|
Dynamic: license-file
|
|
45
49
|
|
|
46
50
|
# NeverLib
|