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,28 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-08-22 23:41:13
|
|
4
|
+
Description: pip install 'markitdown[all]
|
|
5
|
+
'''
|
|
6
|
+
import os
|
|
7
|
+
from markitdown import MarkItDown
|
|
8
|
+
|
|
9
|
+
from neverlib.utils import get_path_list
|
|
10
|
+
|
|
11
|
+
source_dir = "./html"
|
|
12
|
+
target_dir = "./markdown"
|
|
13
|
+
html_path_list = get_path_list(source_dir, end="*.html")
|
|
14
|
+
|
|
15
|
+
for html_path in html_path_list:
|
|
16
|
+
html_name = os.path.basename(html_path)
|
|
17
|
+
md = MarkItDown(enable_plugins=False) # Set to True to enable plugins
|
|
18
|
+
result = md.convert(html_path)
|
|
19
|
+
print(result.text_content)
|
|
20
|
+
|
|
21
|
+
# 写入文件
|
|
22
|
+
with open(os.path.join(target_dir, html_name.replace(".html", ".md")), "w") as f:
|
|
23
|
+
f.write(result.text_content)
|
|
24
|
+
|
|
25
|
+
break
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-08-22 23:41:13
|
|
4
|
+
Description: pip install 'markitdown[all]
|
|
5
|
+
'''
|
|
6
|
+
import os
|
|
7
|
+
from markitdown import MarkItDown
|
|
8
|
+
|
|
9
|
+
from neverlib.utils import get_path_list
|
|
10
|
+
|
|
11
|
+
source_dir = "./html"
|
|
12
|
+
target_dir = "./markdown"
|
|
13
|
+
html_path_list = get_path_list(source_dir, end="*.html")
|
|
14
|
+
|
|
15
|
+
for html_path in html_path_list:
|
|
16
|
+
html_name = os.path.basename(html_path)
|
|
17
|
+
md = MarkItDown(enable_plugins=False) # Set to True to enable plugins
|
|
18
|
+
result = md.convert(html_path)
|
|
19
|
+
print(result.text_content)
|
|
20
|
+
|
|
21
|
+
# 写入文件
|
|
22
|
+
with open(os.path.join(target_dir, html_name.replace(".html", ".md")), "w") as f:
|
|
23
|
+
f.write(result.text_content)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-08-22 23:41:13
|
|
4
|
+
Description: pip install 'markitdown[all]
|
|
5
|
+
'''
|
|
6
|
+
import os
|
|
7
|
+
from markitdown import MarkItDown
|
|
8
|
+
|
|
9
|
+
from neverlib.utils import get_path_list
|
|
10
|
+
|
|
11
|
+
source_dir = "./html"
|
|
12
|
+
target_dir = "./markdown"
|
|
13
|
+
html_path_list = get_path_list(source_dir, end="*.html")
|
|
14
|
+
|
|
15
|
+
for html_path in html_path_list:
|
|
16
|
+
html_name = os.path.basename(html_path)
|
|
17
|
+
md = MarkItDown(enable_plugins=False) # Set to True to enable plugins
|
|
18
|
+
result = md.convert(html_path)
|
|
19
|
+
# print(result.text_content)
|
|
20
|
+
|
|
21
|
+
# 写入文件
|
|
22
|
+
with open(os.path.join(target_dir, html_name.replace(".html", ".md")), "w") as f:
|
|
23
|
+
f.write(result.text_content)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-03-17 18:01:55
|
|
4
|
+
LastEditTime: 2025-03-17 19:38:50
|
|
5
|
+
FilePath: \neverlib\neverlib\__init__.py
|
|
6
|
+
Description:
|
|
7
|
+
'''
|
|
8
|
+
# -*- coding:utf-8 -*-
|
|
9
|
+
# Author:凌逆战 | Never
|
|
10
|
+
# Date: 2024/5/17
|
|
11
|
+
"""
|
|
12
|
+
neverlib - 音频处理和VAD工具集
|
|
13
|
+
"""
|
|
14
|
+
# 从pyproject.toml中读取版本号
|
|
15
|
+
__version__ = "0.1.2" # 默认版本号
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
import re
|
|
19
|
+
import pathlib
|
|
20
|
+
|
|
21
|
+
# 获取pyproject.toml的路径
|
|
22
|
+
_pyproject_path = pathlib.Path(__file__).parent.parent / "pyproject.toml"
|
|
23
|
+
|
|
24
|
+
# 读取版本号
|
|
25
|
+
if _pyproject_path.exists():
|
|
26
|
+
with open(_pyproject_path, "r", encoding="utf-8") as f:
|
|
27
|
+
content = f.read()
|
|
28
|
+
# 使用正则表达式匹配版本号
|
|
29
|
+
version_match = re.search(r'version\s*=\s*"([^"]+)"', content)
|
|
30
|
+
if version_match:
|
|
31
|
+
__version__ = version_match.group(1)
|
|
32
|
+
except Exception:
|
|
33
|
+
pass # 如果出错, 使用默认版本号
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# from neverlib import vad # 只导入vad子包, 减少内存
|
|
37
|
+
# 如果没有neverlib.utils会报错
|
|
38
|
+
from . import utils
|
|
39
|
+
from . import vad
|
|
40
|
+
from . import audio_aug
|
|
41
|
+
from . import filter
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-03-17 18:01:55
|
|
4
|
+
Description:
|
|
5
|
+
'''
|
|
6
|
+
# -*- coding:utf-8 -*-
|
|
7
|
+
# Author:凌逆战 | Never
|
|
8
|
+
# Date: 2024/5/17
|
|
9
|
+
"""
|
|
10
|
+
neverlib - 音频处理和VAD工具集
|
|
11
|
+
"""
|
|
12
|
+
# 从pyproject.toml中读取版本号
|
|
13
|
+
__version__ = "0.1.2" # 默认版本号
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
import re
|
|
17
|
+
import pathlib
|
|
18
|
+
|
|
19
|
+
# 获取pyproject.toml的路径
|
|
20
|
+
_pyproject_path = pathlib.Path(__file__).parent.parent / "pyproject.toml"
|
|
21
|
+
|
|
22
|
+
# 读取版本号
|
|
23
|
+
if _pyproject_path.exists():
|
|
24
|
+
with open(_pyproject_path, "r", encoding="utf-8") as f:
|
|
25
|
+
content = f.read()
|
|
26
|
+
# 使用正则表达式匹配版本号
|
|
27
|
+
version_match = re.search(r'version\s*=\s*"([^"]+)"', content)
|
|
28
|
+
if version_match:
|
|
29
|
+
__version__ = version_match.group(1)
|
|
30
|
+
except Exception:
|
|
31
|
+
pass # 如果出错, 使用默认版本号
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# from neverlib import vad # 只导入vad子包, 减少内存
|
|
35
|
+
# 如果没有neverlib.utils会报错
|
|
36
|
+
from . import utils
|
|
37
|
+
from . import vad
|
|
38
|
+
from . import audio_aug
|
|
39
|
+
from . import filter
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
# Author:凌逆战 | Never
|
|
3
|
+
# Date: 2024/5/17
|
|
4
|
+
"""
|
|
5
|
+
neverlib - 音频处理和VAD工具集
|
|
6
|
+
"""
|
|
7
|
+
# 从pyproject.toml中读取版本号
|
|
8
|
+
__version__ = "0.1.2" # 默认版本号
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
import re
|
|
12
|
+
import pathlib
|
|
13
|
+
|
|
14
|
+
# 获取pyproject.toml的路径
|
|
15
|
+
_pyproject_path = pathlib.Path(__file__).parent.parent / "pyproject.toml"
|
|
16
|
+
|
|
17
|
+
# 读取版本号
|
|
18
|
+
if _pyproject_path.exists():
|
|
19
|
+
with open(_pyproject_path, "r", encoding="utf-8") as f:
|
|
20
|
+
content = f.read()
|
|
21
|
+
# 使用正则表达式匹配版本号
|
|
22
|
+
version_match = re.search(r'version\s*=\s*"([^"]+)"', content)
|
|
23
|
+
if version_match:
|
|
24
|
+
__version__ = version_match.group(1)
|
|
25
|
+
except Exception:
|
|
26
|
+
pass # 如果出错, 使用默认版本号
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# from neverlib import vad # 只导入vad子包, 减少内存
|
|
30
|
+
# 如果没有neverlib.utils会报错
|
|
31
|
+
from . import utils
|
|
32
|
+
from . import vad
|
|
33
|
+
from . import audio_aug
|
|
34
|
+
from . import filter
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-08-22
|
|
4
|
+
Description:
|
|
5
|
+
'''
|
|
6
|
+
# -*- coding:utf-8 -*-
|
|
7
|
+
# Author:凌逆战 | Never
|
|
8
|
+
# Date: 2024/5/17
|
|
9
|
+
"""
|
|
10
|
+
neverlib - 音频处理和VAD工具集
|
|
11
|
+
"""
|
|
12
|
+
# 从pyproject.toml中读取版本号
|
|
13
|
+
__version__ = "0.1.2" # 默认版本号
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
import re
|
|
17
|
+
import pathlib
|
|
18
|
+
|
|
19
|
+
# 获取pyproject.toml的路径
|
|
20
|
+
_pyproject_path = pathlib.Path(__file__).parent.parent / "pyproject.toml"
|
|
21
|
+
|
|
22
|
+
# 读取版本号
|
|
23
|
+
if _pyproject_path.exists():
|
|
24
|
+
with open(_pyproject_path, "r", encoding="utf-8") as f:
|
|
25
|
+
content = f.read()
|
|
26
|
+
# 使用正则表达式匹配版本号
|
|
27
|
+
version_match = re.search(r'version\s*=\s*"([^"]+)"', content)
|
|
28
|
+
if version_match:
|
|
29
|
+
__version__ = version_match.group(1)
|
|
30
|
+
except Exception:
|
|
31
|
+
pass # 如果出错, 使用默认版本号
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# from neverlib import vad # 只导入vad子包, 减少内存
|
|
35
|
+
# 如果没有neverlib.utils会报错
|
|
36
|
+
from . import utils
|
|
37
|
+
from . import vad
|
|
38
|
+
from . import audio_aug
|
|
39
|
+
from . import filter
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Author: 凌逆战 | Never
|
|
3
|
+
Date: 2025-08-22
|
|
4
|
+
Description: neverlib - 音频处理和VAD工具集
|
|
5
|
+
'''
|
|
6
|
+
# 从pyproject.toml中读取版本号
|
|
7
|
+
__version__ = "0.1.2" # 默认版本号
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import re
|
|
11
|
+
import pathlib
|
|
12
|
+
|
|
13
|
+
# 获取pyproject.toml的路径
|
|
14
|
+
_pyproject_path = pathlib.Path(__file__).parent.parent / "pyproject.toml"
|
|
15
|
+
|
|
16
|
+
# 读取版本号
|
|
17
|
+
if _pyproject_path.exists():
|
|
18
|
+
with open(_pyproject_path, "r", encoding="utf-8") as f:
|
|
19
|
+
content = f.read()
|
|
20
|
+
# 使用正则表达式匹配版本号
|
|
21
|
+
version_match = re.search(r'version\s*=\s*"([^"]+)"', content)
|
|
22
|
+
if version_match:
|
|
23
|
+
__version__ = version_match.group(1)
|
|
24
|
+
except Exception:
|
|
25
|
+
pass # 如果出错, 使用默认版本号
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# from neverlib import vad # 只导入vad子包, 减少内存
|
|
29
|
+
# 如果没有neverlib.utils会报错
|
|
30
|
+
from . import utils
|
|
31
|
+
from . import vad
|
|
32
|
+
from . import audio_aug
|
|
33
|
+
from . import filter
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
# Author:凌逆战 | Never
|
|
3
|
+
# Date: 2024/9/27
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
import random
|
|
8
|
+
import numpy as np
|
|
9
|
+
import soundfile as sf
|
|
10
|
+
from scipy import signal
|
|
11
|
+
from neverlib.utils import EPS
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def volume_norm(wav):
|
|
15
|
+
"""
|
|
16
|
+
音量归一化
|
|
17
|
+
:param wav: (T,)
|
|
18
|
+
:return: (T,)
|
|
19
|
+
"""
|
|
20
|
+
wav = wav / (np.max(np.abs(wav)) + 1e-8)
|
|
21
|
+
return wav
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def add_reverb(wav, rir, ratio=1, mode="same"):
|
|
25
|
+
"""添加混响,
|
|
26
|
+
Args:
|
|
27
|
+
wav: [T, channel]
|
|
28
|
+
rir: [T, channel]
|
|
29
|
+
ratio: 0-1
|
|
30
|
+
mode: "same" for SE or "full" for kws
|
|
31
|
+
"""
|
|
32
|
+
if random.random() < ratio:
|
|
33
|
+
wav = signal.fftconvolve(wav, rir, mode=mode) # (28671, 3)
|
|
34
|
+
# note: 建议过完添加混响后再进行归一化, 否则可能会出现溢出
|
|
35
|
+
# 防止削波
|
|
36
|
+
if np.max(np.abs(wav)) > 1:
|
|
37
|
+
scale_factor = 1 / np.max(np.abs(wav))
|
|
38
|
+
wav *= scale_factor
|
|
39
|
+
return wav
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def snr_aug_changeNoise(clean, noise, snr):
|
|
43
|
+
"""
|
|
44
|
+
保持语音不变, 改变噪声的幅度
|
|
45
|
+
snr = 10 * log10(signal_power / k*noise_power)
|
|
46
|
+
"""
|
|
47
|
+
assert clean.shape == noise.shape, "clean and noise must have the same shape"
|
|
48
|
+
clean_power = np.mean(clean ** 2) # 纯净语音功率
|
|
49
|
+
noise_power = np.mean(noise ** 2) # 噪声功率
|
|
50
|
+
noise_scale = np.sqrt(clean_power / (noise_power * 10 ** (snr / 10) + EPS))
|
|
51
|
+
noisy = clean + noise_scale * noise
|
|
52
|
+
# 防止削波
|
|
53
|
+
if np.max(np.abs(noisy)) > 1:
|
|
54
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
55
|
+
noisy *= scale_factor
|
|
56
|
+
return noisy, noise_scale
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def snr_aug_changeNoise_v2(clean, noise, snr):
|
|
60
|
+
"""
|
|
61
|
+
保持语音不变, 改变噪声的幅度
|
|
62
|
+
snr = 10 * log10(signal_power / k*noise_power)
|
|
63
|
+
"""
|
|
64
|
+
assert clean.shape == noise.shape, "clean and noise must have the same shape"
|
|
65
|
+
clean_power = np.mean(clean ** 2) # 纯净语音功率
|
|
66
|
+
noise_power = np.mean(noise ** 2) # 噪声功率
|
|
67
|
+
snr_in = 10 * np.log10(clean_power / (noise_power + EPS) + EPS)
|
|
68
|
+
snr_gain = snr_in - snr
|
|
69
|
+
gain = 10 ** (snr_gain / 20)
|
|
70
|
+
noisy = clean + gain * noise
|
|
71
|
+
# 防止削波
|
|
72
|
+
if np.max(np.abs(noisy)) > 1:
|
|
73
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
74
|
+
noisy *= scale_factor
|
|
75
|
+
return noisy, gain
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def snr_aug_changeClean(clean, noise, snr):
|
|
79
|
+
"""
|
|
80
|
+
保持噪声不变, 改变语音的幅度
|
|
81
|
+
snr = 10 * log10(k*signal_power/ noise_power)
|
|
82
|
+
"""
|
|
83
|
+
assert clean.shape == noise.shape, "clean and noise must have the same shape"
|
|
84
|
+
clean_power = np.mean(clean ** 2)
|
|
85
|
+
noise_power = np.mean(noise ** 2)
|
|
86
|
+
clean_scale = np.sqrt(noise_power * 10 ** (snr / 10) / (clean_power + 1e-8))
|
|
87
|
+
noisy = clean * clean_scale + noise
|
|
88
|
+
# 防止削波
|
|
89
|
+
if np.max(np.abs(noisy)) > 1:
|
|
90
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
91
|
+
noisy *= scale_factor
|
|
92
|
+
return noisy, clean_scale
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def snr_aug_Interpolation(clean, noise, snr):
|
|
96
|
+
"""
|
|
97
|
+
在已知clean_len<=noise_len的情况下
|
|
98
|
+
将clean插入到noise中的snr aug方法
|
|
99
|
+
Args:
|
|
100
|
+
clean: 语音
|
|
101
|
+
noise: 噪声
|
|
102
|
+
snr: snr=random.uniform(*snr_range)
|
|
103
|
+
"""
|
|
104
|
+
clean_len, noise_len = clean.shape[0], noise.shape[0]
|
|
105
|
+
assert clean_len <= noise_len, f"clean_len must be less than noise_len."
|
|
106
|
+
noisy = noise.copy()
|
|
107
|
+
index = random.randint(0, noise_len - clean_len)
|
|
108
|
+
noise = noise[index:index + clean_len, :]
|
|
109
|
+
noisy_tmp, _ = snr_aug_changeClean(clean, noise, snr)
|
|
110
|
+
noisy[index:index + clean_len, :] = noisy_tmp
|
|
111
|
+
# 防止削波
|
|
112
|
+
if np.max(np.abs(noisy)) > 1:
|
|
113
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
114
|
+
noisy *= scale_factor
|
|
115
|
+
return noisy
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def get_audio_segments(wav_len, audio_path_list, sr=16000):
|
|
119
|
+
"""
|
|
120
|
+
从音频列表中随机拼接指定长度音频
|
|
121
|
+
Args:
|
|
122
|
+
wav_len: 需要返回的音频长度
|
|
123
|
+
audio_path_list: 音频路径列表
|
|
124
|
+
sr: 采样率
|
|
125
|
+
Returns:返回指定长度的音频
|
|
126
|
+
"""
|
|
127
|
+
audio_len = 0
|
|
128
|
+
wav_list = []
|
|
129
|
+
while audio_len < wav_len:
|
|
130
|
+
audio_path = random.choice(audio_path_list)
|
|
131
|
+
wav, wav_sr = sf.read(audio_path, always_2d=True, dtype='float32')
|
|
132
|
+
assert wav_sr == sr, f"音频采样率是{wav_sr}, 期望{sr}"
|
|
133
|
+
audio_len += len(wav)
|
|
134
|
+
wav_list.append(wav)
|
|
135
|
+
wav = np.concatenate(wav_list, axis=0)
|
|
136
|
+
if len(wav) > wav_len:
|
|
137
|
+
# 随机截取clean_len
|
|
138
|
+
start = random.randint(0, len(wav) - wav_len)
|
|
139
|
+
wav = wav[start:start + wav_len, :]
|
|
140
|
+
return wav
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def volume_aug(wav, range, rate, method="linmax"):
|
|
144
|
+
"""音量增强 """
|
|
145
|
+
if random.random() < rate:
|
|
146
|
+
target_level = random.uniform(range[0], range[1])
|
|
147
|
+
if method == "dbrms":
|
|
148
|
+
wav_rms = (wav ** 2).mean() ** 0.5
|
|
149
|
+
scalar = 10 ** (target_level / 20) / (np.max(wav_rms) + EPS)
|
|
150
|
+
elif method == "linmax":
|
|
151
|
+
ipt_max = np.max(np.abs(wav))
|
|
152
|
+
# wav/wav_max*target_level=target_level_wav
|
|
153
|
+
# 处理后音频的 最大值就是target_level
|
|
154
|
+
scalar = target_level / (ipt_max + EPS)
|
|
155
|
+
else:
|
|
156
|
+
raise ValueError("method must be 'dbrms' or 'linmax'")
|
|
157
|
+
wav *= scalar
|
|
158
|
+
return wav
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
# Author:凌逆战 | Never
|
|
3
|
+
# Date: 2024/9/27
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
import random
|
|
8
|
+
import numpy as np
|
|
9
|
+
import soundfile as sf
|
|
10
|
+
from scipy import signal
|
|
11
|
+
from neverlib.utils import EPS
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def volume_norm(wav):
|
|
15
|
+
"""
|
|
16
|
+
音量归一化
|
|
17
|
+
:param wav: (T,)
|
|
18
|
+
:return: (T,)
|
|
19
|
+
"""
|
|
20
|
+
wav = wav / (np.max(np.abs(wav)) + 1e-8)
|
|
21
|
+
return wav
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def add_reverb(wav, rir, ratio=1, mode="same"):
|
|
25
|
+
"""添加混响,
|
|
26
|
+
Args:
|
|
27
|
+
wav: [T, channel]
|
|
28
|
+
rir: [T, channel]
|
|
29
|
+
ratio: 0-1
|
|
30
|
+
mode: "same" for SE or "full" for kws
|
|
31
|
+
"""
|
|
32
|
+
if random.random() < ratio:
|
|
33
|
+
wav = signal.fftconvolve(wav, rir, mode=mode) # (28671, 3)
|
|
34
|
+
# note: 建议过完添加混响后再进行归一化, 否则可能会出现溢出
|
|
35
|
+
# 防止削波
|
|
36
|
+
if np.max(np.abs(wav)) > 1:
|
|
37
|
+
scale_factor = 1 / np.max(np.abs(wav))
|
|
38
|
+
wav *= scale_factor
|
|
39
|
+
return wav
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def snr_aug_changeNoise(clean, noise, snr):
|
|
43
|
+
"""
|
|
44
|
+
保持语音不变, 改变噪声的幅度
|
|
45
|
+
snr = 10 * log10(signal_power / k*noise_power)
|
|
46
|
+
"""
|
|
47
|
+
assert clean.shape == noise.shape, "clean and noise must have the same shape"
|
|
48
|
+
clean_power = np.mean(clean ** 2) # 纯净语音功率
|
|
49
|
+
noise_power = np.mean(noise ** 2) # 噪声功率
|
|
50
|
+
noise_scale = np.sqrt(clean_power / (noise_power * 10 ** (snr / 10) + EPS))
|
|
51
|
+
noisy = clean + noise_scale * noise
|
|
52
|
+
# 防止削波
|
|
53
|
+
if np.max(np.abs(noisy)) > 1:
|
|
54
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
55
|
+
noisy *= scale_factor
|
|
56
|
+
clean *= scale_factor
|
|
57
|
+
return noisy, clean
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def snr_aug_changeNoise_v2(clean, noise, snr):
|
|
61
|
+
"""
|
|
62
|
+
保持语音不变, 改变噪声的幅度
|
|
63
|
+
snr = 10 * log10(signal_power / k*noise_power)
|
|
64
|
+
"""
|
|
65
|
+
assert clean.shape == noise.shape, "clean and noise must have the same shape"
|
|
66
|
+
clean_power = np.mean(clean ** 2) # 纯净语音功率
|
|
67
|
+
noise_power = np.mean(noise ** 2) # 噪声功率
|
|
68
|
+
snr_in = 10 * np.log10(clean_power / (noise_power + EPS) + EPS)
|
|
69
|
+
snr_gain = snr_in - snr
|
|
70
|
+
gain = 10 ** (snr_gain / 20)
|
|
71
|
+
noisy = clean + gain * noise
|
|
72
|
+
# 防止削波
|
|
73
|
+
if np.max(np.abs(noisy)) > 1:
|
|
74
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
75
|
+
noisy *= scale_factor
|
|
76
|
+
return noisy, gain
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def snr_aug_changeClean(clean, noise, snr):
|
|
80
|
+
"""
|
|
81
|
+
保持噪声不变, 改变语音的幅度
|
|
82
|
+
snr = 10 * log10(k*signal_power/ noise_power)
|
|
83
|
+
"""
|
|
84
|
+
assert clean.shape == noise.shape, "clean and noise must have the same shape"
|
|
85
|
+
clean_power = np.mean(clean ** 2)
|
|
86
|
+
noise_power = np.mean(noise ** 2)
|
|
87
|
+
clean_scale = np.sqrt(noise_power * 10 ** (snr / 10) / (clean_power + 1e-8))
|
|
88
|
+
noisy = clean * clean_scale + noise
|
|
89
|
+
# 防止削波
|
|
90
|
+
if np.max(np.abs(noisy)) > 1:
|
|
91
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
92
|
+
noisy *= scale_factor
|
|
93
|
+
return noisy, clean_scale
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def snr_aug_Interpolation(clean, noise, snr):
|
|
97
|
+
"""
|
|
98
|
+
在已知clean_len<=noise_len的情况下
|
|
99
|
+
将clean插入到noise中的snr aug方法
|
|
100
|
+
Args:
|
|
101
|
+
clean: 语音
|
|
102
|
+
noise: 噪声
|
|
103
|
+
snr: snr=random.uniform(*snr_range)
|
|
104
|
+
"""
|
|
105
|
+
clean_len, noise_len = clean.shape[0], noise.shape[0]
|
|
106
|
+
assert clean_len <= noise_len, f"clean_len must be less than noise_len."
|
|
107
|
+
noisy = noise.copy()
|
|
108
|
+
index = random.randint(0, noise_len - clean_len)
|
|
109
|
+
noise = noise[index:index + clean_len, :]
|
|
110
|
+
noisy_tmp, _ = snr_aug_changeClean(clean, noise, snr)
|
|
111
|
+
noisy[index:index + clean_len, :] = noisy_tmp
|
|
112
|
+
# 防止削波
|
|
113
|
+
if np.max(np.abs(noisy)) > 1:
|
|
114
|
+
scale_factor = 1 / np.max(np.abs(noisy))
|
|
115
|
+
noisy *= scale_factor
|
|
116
|
+
return noisy
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def get_audio_segments(wav_len, audio_path_list, sr=16000):
|
|
120
|
+
"""
|
|
121
|
+
从音频列表中随机拼接指定长度音频
|
|
122
|
+
Args:
|
|
123
|
+
wav_len: 需要返回的音频长度
|
|
124
|
+
audio_path_list: 音频路径列表
|
|
125
|
+
sr: 采样率
|
|
126
|
+
Returns:返回指定长度的音频
|
|
127
|
+
"""
|
|
128
|
+
audio_len = 0
|
|
129
|
+
wav_list = []
|
|
130
|
+
while audio_len < wav_len:
|
|
131
|
+
audio_path = random.choice(audio_path_list)
|
|
132
|
+
wav, wav_sr = sf.read(audio_path, always_2d=True, dtype='float32')
|
|
133
|
+
assert wav_sr == sr, f"音频采样率是{wav_sr}, 期望{sr}"
|
|
134
|
+
audio_len += len(wav)
|
|
135
|
+
wav_list.append(wav)
|
|
136
|
+
wav = np.concatenate(wav_list, axis=0)
|
|
137
|
+
if len(wav) > wav_len:
|
|
138
|
+
# 随机截取clean_len
|
|
139
|
+
start = random.randint(0, len(wav) - wav_len)
|
|
140
|
+
wav = wav[start:start + wav_len, :]
|
|
141
|
+
return wav
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def volume_aug(wav, range, rate, method="linmax"):
|
|
145
|
+
"""音量增强 """
|
|
146
|
+
if random.random() < rate:
|
|
147
|
+
target_level = random.uniform(range[0], range[1])
|
|
148
|
+
if method == "dbrms":
|
|
149
|
+
wav_rms = (wav ** 2).mean() ** 0.5
|
|
150
|
+
scalar = 10 ** (target_level / 20) / (np.max(wav_rms) + EPS)
|
|
151
|
+
elif method == "linmax":
|
|
152
|
+
ipt_max = np.max(np.abs(wav))
|
|
153
|
+
# wav/wav_max*target_level=target_level_wav
|
|
154
|
+
# 处理后音频的 最大值就是target_level
|
|
155
|
+
scalar = target_level / (ipt_max + EPS)
|
|
156
|
+
else:
|
|
157
|
+
raise ValueError("method must be 'dbrms' or 'linmax'")
|
|
158
|
+
wav *= scalar
|
|
159
|
+
return wav
|