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.
Files changed (466) hide show
  1. neverlib/Docs/audio_aug/test_volume.ipynb +8 -8
  2. neverlib/Docs/filter/biquad.ipynb +1 -1
  3. neverlib/Docs/filter/filter_family.ipynb +4 -4
  4. neverlib/Docs/vad/VAD_WebRTC.ipynb +4 -4
  5. neverlib/Docs/vad/VAD_whisper.ipynb +2 -2
  6. neverlib/LLM/__init__.py +37 -0
  7. neverlib/LLM/bailian.py +342 -0
  8. neverlib/LLM/image.py +73 -0
  9. neverlib/LLM/text.py +32 -0
  10. neverlib/QA/ImpactNoiseRejection.py +119 -0
  11. neverlib/QA/gen_init.py +13 -16
  12. neverlib/__init__.py +5 -5
  13. neverlib/audio_aug/HarmonicDistortion.py +11 -11
  14. neverlib/audio_aug/README.md +3 -0
  15. neverlib/audio_aug/__init__.py +2 -2
  16. neverlib/audio_aug/audio_aug.py +18 -18
  17. neverlib/audio_aug/coder_aug.py +25 -25
  18. neverlib/audio_aug/coder_aug2.py +10 -10
  19. neverlib/audio_aug/loss_packet_aug.py +16 -16
  20. neverlib/audio_aug/quant_aug.py +7 -7
  21. neverlib/data_analyze/README.md +1 -1
  22. neverlib/data_analyze/__init__.py +2 -2
  23. neverlib/data_analyze/dataset_analyzer.py +2 -2
  24. neverlib/data_analyze/quality_metrics.py +12 -12
  25. neverlib/data_analyze/statistics.py +1 -1
  26. neverlib/data_analyze/visualization.py +1 -1
  27. neverlib/filter/README.md +3 -3
  28. neverlib/filter/__init__.py +2 -2
  29. neverlib/filter/auto_eq/README.md +2 -2
  30. neverlib/filter/auto_eq/__init__.py +2 -2
  31. neverlib/filter/auto_eq/de_eq.py +1 -1
  32. neverlib/filter/auto_eq/ga_eq_advanced.py +2 -2
  33. neverlib/filter/auto_eq/ga_eq_basic.py +1 -1
  34. neverlib/filter/biquad.py +1 -1
  35. neverlib/filter/core.py +8 -5
  36. neverlib/metrics/README.md +35 -0
  37. neverlib/metrics/__init__.py +2 -2
  38. neverlib/metrics/dnsmos.py +2 -2
  39. neverlib/metrics/lpc_lsp.py +8 -8
  40. neverlib/metrics/pesq_c/PESQ +0 -0
  41. neverlib/metrics/snr.py +5 -5
  42. neverlib/metrics/spec.py +23 -23
  43. neverlib/metrics/test_pesq.py +3 -3
  44. neverlib/signal_gen/babble_noise_generate.py +113 -0
  45. neverlib/tests/__init__.py +2 -2
  46. neverlib/tests/test_imports.py +1 -1
  47. neverlib/utils/README.md +29 -0
  48. neverlib/utils/__init__.py +24 -16
  49. neverlib/utils/audio_split.py +21 -21
  50. neverlib/utils/checkGPU.py +52 -79
  51. neverlib/utils/floder.py +115 -0
  52. neverlib/utils/lazy_expose.py +1 -1
  53. neverlib/utils/lazy_module.py +6 -6
  54. neverlib/utils/message.py +2 -3
  55. neverlib/utils/pcm.py +42 -0
  56. neverlib/utils/utils.py +108 -91
  57. neverlib/vad/README.md +5 -5
  58. neverlib/vad/__init__.py +2 -2
  59. neverlib/vad/utils.py +1 -1
  60. {neverlib-0.2.8.dist-info → neverlib-0.3.0.dist-info}/METADATA +17 -3
  61. neverlib-0.3.0.dist-info/RECORD +120 -0
  62. neverlib/.claude/settings.local.json +0 -9
  63. neverlib/.history/Docs/audio_aug/del_20250827162530.py +0 -0
  64. neverlib/.history/Docs/audio_aug/del_20250827162540.py +0 -2
  65. neverlib/.history/Docs/audio_aug/del_20250827162541.py +0 -7
  66. neverlib/.history/Docs/audio_aug/del_20250827162606.py +0 -7
  67. neverlib/.history/Docs/audio_aug/del_20250827162637.py +0 -8
  68. neverlib/.history/Docs/audio_aug/del_20250827162645.py +0 -8
  69. neverlib/.history/Docs/audio_aug/del_20250827162723.py +0 -9
  70. neverlib/.history/Docs/audio_aug/del_20250827162739.py +0 -9
  71. neverlib/.history/Docs/audio_aug/test_snr_20250806011311.py +0 -0
  72. neverlib/.history/Docs/audio_aug/test_snr_20250806011331.py +0 -75
  73. neverlib/.history/Docs/audio_aug/test_snr_20250806011342.py +0 -57
  74. neverlib/.history/Docs/audio_aug/test_snr_20250806011352.py +0 -57
  75. neverlib/.history/Docs/audio_aug/test_snr_20250806011403.py +0 -57
  76. neverlib/.history/Docs/audio_aug/test_snr_20250806011413.py +0 -57
  77. neverlib/.history/Docs/audio_aug/test_snr_20250806011435.py +0 -55
  78. neverlib/.history/Docs/audio_aug/test_snr_20250827161751.py +0 -55
  79. neverlib/.history/Docs/audio_aug/test_snr_20250827161754.py +0 -55
  80. neverlib/.history/Docs/audio_aug/test_snr_20250827161833.py +0 -54
  81. neverlib/.history/Docs/audio_aug/test_snr_20250827162017.py +0 -56
  82. neverlib/.history/Docs/audio_aug/test_snr_20250827162021.py +0 -57
  83. neverlib/.history/Docs/audio_aug/test_snr_20250827162028.py +0 -57
  84. neverlib/.history/Docs/audio_aug/test_snr_20250827162033.py +0 -55
  85. neverlib/.history/Docs/audio_aug_test/del_20250827162738.py +0 -9
  86. neverlib/.history/Docs/audio_aug_test/del_20250827162819.py +0 -9
  87. neverlib/.history/Docs/audio_aug_test/del_20250827162830.py +0 -9
  88. neverlib/.history/Docs/audio_aug_test/del_20250827162846.py +0 -9
  89. neverlib/.history/Docs/audio_aug_test/del_20250827162851.py +0 -9
  90. neverlib/.history/Docs/audio_aug_test/del_20250827162903.py +0 -10
  91. neverlib/.history/Docs/audio_aug_test/del_20250827162921.py +0 -10
  92. neverlib/.history/Docs/audio_aug_test/del_20250827162926.py +0 -10
  93. neverlib/.history/Docs/audio_aug_test/del_20250827163030.py +0 -10
  94. neverlib/.history/Docs/audio_aug_test/del_20250827163032.py +0 -10
  95. neverlib/.history/Docs/vad/1_20250810032405.py +0 -0
  96. neverlib/.history/Docs/vad/1_20250810032417.py +0 -39
  97. neverlib/.history/QA/html2markdown_20250822234112.md +0 -0
  98. neverlib/.history/QA/html2markdown_20250822234140.py +0 -9
  99. neverlib/.history/QA/html2markdown_20250822234141.md +0 -9
  100. neverlib/.history/QA/html2markdown_20250822234159.py +0 -12
  101. neverlib/.history/QA/html2markdown_20250822234200.py +0 -17
  102. neverlib/.history/QA/html2markdown_20250822234236.py +0 -17
  103. neverlib/.history/QA/html2markdown_20250822234340.py +0 -14
  104. neverlib/.history/QA/html2markdown_20250822234522.py +0 -18
  105. neverlib/.history/QA/html2markdown_20250822234601.py +0 -20
  106. neverlib/.history/QA/html2markdown_20250822234615.py +0 -22
  107. neverlib/.history/QA/html2markdown_20250822234715.py +0 -28
  108. neverlib/.history/QA/html2markdown_20250822234720.py +0 -27
  109. neverlib/.history/QA/html2markdown_20250822234903.py +0 -27
  110. neverlib/.history/__init___20250805234212.py +0 -41
  111. neverlib/.history/__init___20250904102635.py +0 -39
  112. neverlib/.history/__init___20250904102836.py +0 -34
  113. neverlib/.history/__init___20250904102838.py +0 -39
  114. neverlib/.history/__init___20250904102851.py +0 -33
  115. neverlib/.history/audio_aug/audio_aug_20250806010451.py +0 -125
  116. neverlib/.history/audio_aug/audio_aug_20250806010750.py +0 -138
  117. neverlib/.history/audio_aug/audio_aug_20250806010759.py +0 -140
  118. neverlib/.history/audio_aug/audio_aug_20250806010803.py +0 -140
  119. neverlib/.history/audio_aug/audio_aug_20250806010809.py +0 -140
  120. neverlib/.history/audio_aug/audio_aug_20250806011108.py +0 -140
  121. neverlib/.history/audio_aug/audio_aug_20250826155913.py +0 -158
  122. neverlib/.history/audio_aug/audio_aug_20250826164159.py +0 -159
  123. neverlib/.history/audio_aug/audio_aug_20250826164217.py +0 -160
  124. neverlib/.history/audio_aug/audio_aug_20250826164408.py +0 -161
  125. neverlib/.history/audio_aug/audio_aug_20250826164423.py +0 -161
  126. neverlib/.history/audio_aug/audio_aug_20250826164529.py +0 -161
  127. neverlib/.history/audio_aug/audio_aug_20250826164824.py +0 -161
  128. neverlib/.history/audio_aug/audio_aug_20250826164932.py +0 -162
  129. neverlib/.history/audio_aug/audio_aug_20250826164947.py +0 -162
  130. neverlib/.history/audio_aug/audio_aug_20250826165403.py +0 -162
  131. neverlib/.history/audio_aug/audio_aug_20250826165421.py +0 -162
  132. neverlib/.history/audio_aug/audio_aug_20250826165509.py +0 -163
  133. neverlib/.history/audio_aug/audio_aug_20250826165702.py +0 -163
  134. neverlib/.history/audio_aug/audio_aug_20250826165732.py +0 -165
  135. neverlib/.history/audio_aug/audio_aug_20250826170041.py +0 -163
  136. neverlib/.history/audio_aug/audio_aug_20250826170105.py +0 -164
  137. neverlib/.history/audio_aug/audio_aug_20250826170154.py +0 -164
  138. neverlib/.history/audio_aug/audio_aug_20250826170220.py +0 -165
  139. neverlib/.history/audio_aug/audio_aug_20250826170221.py +0 -165
  140. neverlib/.history/audio_aug/audio_aug_20250826170228.py +0 -165
  141. neverlib/.history/audio_aug/audio_aug_20250826170231.py +0 -165
  142. neverlib/.history/audio_aug/audio_aug_20250826212001.py +0 -165
  143. neverlib/.history/audio_aug/audio_aug_20250826220038.py +0 -165
  144. neverlib/.history/audio_aug/audio_aug_20250826220133.py +0 -165
  145. neverlib/.history/audio_aug/audio_aug_20250826220148.py +0 -165
  146. neverlib/.history/audio_aug/audio_aug_20250826220154.py +0 -165
  147. neverlib/.history/audio_aug/audio_aug_20250826220156.py +0 -165
  148. neverlib/.history/audio_aug/audio_aug_20250826220314.py +0 -165
  149. neverlib/.history/audio_aug/audio_aug_20250826220343.py +0 -184
  150. neverlib/.history/audio_aug/audio_aug_20250826220345.py +0 -184
  151. neverlib/.history/audio_aug/audio_aug_20250826220349.py +0 -184
  152. neverlib/.history/audio_aug/audio_aug_20250826220429.py +0 -184
  153. neverlib/.history/audio_aug/audio_aug_20250826220447.py +0 -184
  154. neverlib/.history/audio_aug/audio_aug_20250826220601.py +0 -186
  155. neverlib/.history/audio_aug/audio_aug_20250826220638.py +0 -186
  156. neverlib/.history/audio_aug/audio_aug_20250826220641.py +0 -186
  157. neverlib/.history/audio_aug/audio_aug_20250826220647.py +0 -186
  158. neverlib/.history/audio_aug/audio_aug_20250826220653.py +0 -186
  159. neverlib/.history/audio_aug/audio_aug_20250826220655.py +0 -186
  160. neverlib/.history/audio_aug/audio_aug_20250826220731.py +0 -185
  161. neverlib/.history/audio_aug/audio_aug_20250826220739.py +0 -185
  162. neverlib/.history/audio_aug/audio_aug_20250826220747.py +0 -185
  163. neverlib/.history/audio_aug/audio_aug_20250826220801.py +0 -186
  164. neverlib/.history/audio_aug/audio_aug_20250826220822.py +0 -186
  165. neverlib/.history/audio_aug/audio_aug_20250826220901.py +0 -186
  166. neverlib/.history/audio_aug/audio_aug_20250826221107.py +0 -187
  167. neverlib/.history/audio_aug/audio_aug_20250826221310.py +0 -188
  168. neverlib/.history/audio_aug/audio_aug_20250826221353.py +0 -191
  169. neverlib/.history/audio_aug/audio_aug_20250826221821.py +0 -191
  170. neverlib/.history/audio_aug/audio_aug_20250826221838.py +0 -191
  171. neverlib/.history/audio_aug/audio_aug_20250826221906.py +0 -191
  172. neverlib/.history/audio_aug/audio_aug_20250826221930.py +0 -191
  173. neverlib/.history/audio_aug/audio_aug_20250826221939.py +0 -191
  174. neverlib/.history/audio_aug/audio_aug_20250826221955.py +0 -191
  175. neverlib/.history/audio_aug/audio_aug_20250826222008.py +0 -197
  176. neverlib/.history/audio_aug/audio_aug_20250826222017.py +0 -200
  177. neverlib/.history/audio_aug/audio_aug_20250826222046.py +0 -203
  178. neverlib/.history/audio_aug/audio_aug_20250826222105.py +0 -203
  179. neverlib/.history/audio_aug/audio_aug_20250826222206.py +0 -203
  180. neverlib/.history/audio_aug/audio_aug_20250826222302.py +0 -203
  181. neverlib/.history/audio_aug/audio_aug_20250826222336.py +0 -203
  182. neverlib/.history/audio_aug/audio_aug_20250826222455.py +0 -204
  183. neverlib/.history/audio_aug/audio_aug_20250826222526.py +0 -204
  184. neverlib/.history/audio_aug/audio_aug_20250826222541.py +0 -204
  185. neverlib/.history/audio_aug/audio_aug_20250826222624.py +0 -202
  186. neverlib/.history/audio_aug/audio_aug_20250826222714.py +0 -205
  187. neverlib/.history/audio_aug/audio_aug_20250826222820.py +0 -205
  188. neverlib/.history/audio_aug/audio_aug_20250826222827.py +0 -205
  189. neverlib/.history/audio_aug/audio_aug_20250826222927.py +0 -232
  190. neverlib/.history/audio_aug/audio_aug_20250826223009.py +0 -232
  191. neverlib/.history/audio_aug/audio_aug_20250826223054.py +0 -232
  192. neverlib/.history/audio_aug/audio_aug_20250826223225.py +0 -233
  193. neverlib/.history/audio_aug/audio_aug_20250826223344.py +0 -236
  194. neverlib/.history/audio_aug/audio_aug_20250826223356.py +0 -236
  195. neverlib/.history/audio_aug/audio_aug_20250826223955.py +0 -242
  196. neverlib/.history/audio_aug/audio_aug_20250826224210.py +0 -240
  197. neverlib/.history/audio_aug/audio_aug_20250826224250.py +0 -242
  198. neverlib/.history/audio_aug/audio_aug_20250826224323.py +0 -280
  199. neverlib/.history/audio_aug/audio_aug_20250826224452.py +0 -263
  200. neverlib/.history/audio_aug/audio_aug_20250826224455.py +0 -263
  201. neverlib/.history/audio_aug/audio_aug_20250826224502.py +0 -263
  202. neverlib/.history/audio_aug/audio_aug_20250826224528.py +0 -263
  203. neverlib/.history/audio_aug/audio_aug_20250826224658.py +0 -263
  204. neverlib/.history/audio_aug/audio_aug_20250826224833.py +0 -264
  205. neverlib/.history/audio_aug/audio_aug_20250826225013.py +0 -269
  206. neverlib/.history/audio_aug/audio_aug_20250826225050.py +0 -269
  207. neverlib/.history/audio_aug/audio_aug_20250826225241.py +0 -268
  208. neverlib/.history/audio_aug/audio_aug_20250826225315.py +0 -266
  209. neverlib/.history/audio_aug/audio_aug_20250826225404.py +0 -266
  210. neverlib/.history/audio_aug/audio_aug_20250826225502.py +0 -265
  211. neverlib/.history/audio_aug/audio_aug_20250826225950.py +0 -267
  212. neverlib/.history/audio_aug/audio_aug_20250826225959.py +0 -268
  213. neverlib/.history/audio_aug/audio_aug_20250826230222.py +0 -271
  214. neverlib/.history/audio_aug/audio_aug_20250826230248.py +0 -270
  215. neverlib/.history/audio_aug/audio_aug_20250826230638.py +0 -266
  216. neverlib/.history/audio_aug/audio_aug_20250826230755.py +0 -266
  217. neverlib/.history/audio_aug/audio_aug_20250826230941.py +0 -265
  218. neverlib/.history/audio_aug/audio_aug_20250826231054.py +0 -266
  219. neverlib/.history/audio_aug/audio_aug_20250826231117.py +0 -266
  220. neverlib/.history/audio_aug/audio_aug_20250826231219.py +0 -266
  221. neverlib/.history/audio_aug/audio_aug_20250826232330.py +0 -266
  222. neverlib/.history/audio_aug/audio_aug_20250826232352.py +0 -266
  223. neverlib/.history/audio_aug/audio_aug_20250827152748.py +0 -268
  224. neverlib/.history/audio_aug/audio_aug_20250827152806.py +0 -268
  225. neverlib/.history/audio_aug/audio_aug_20250827152808.py +0 -268
  226. neverlib/.history/audio_aug/audio_aug_20250827152917.py +0 -283
  227. neverlib/.history/audio_aug/audio_aug_20250827152929.py +0 -281
  228. neverlib/.history/audio_aug/audio_aug_20250827153100.py +0 -286
  229. neverlib/.history/audio_aug/audio_aug_20250827153102.py +0 -286
  230. neverlib/.history/audio_aug/audio_aug_20250827153301.py +0 -295
  231. neverlib/.history/audio_aug/audio_aug_20250827153331.py +0 -298
  232. neverlib/.history/audio_aug/audio_aug_20250827153525.py +0 -303
  233. neverlib/.history/audio_aug/audio_aug_20250827153533.py +0 -304
  234. neverlib/.history/audio_aug/audio_aug_20250827153541.py +0 -321
  235. neverlib/.history/audio_aug/audio_aug_20250827153805.py +0 -322
  236. neverlib/.history/audio_aug/audio_aug_20250827153832.py +0 -323
  237. neverlib/.history/audio_aug/audio_aug_20250827153836.py +0 -324
  238. neverlib/.history/audio_aug/audio_aug_20250827153846.py +0 -324
  239. neverlib/.history/audio_aug/audio_aug_20250827153859.py +0 -325
  240. neverlib/.history/audio_aug/audio_aug_20250827154453.py +0 -337
  241. neverlib/.history/audio_aug/audio_aug_20250827154513.py +0 -355
  242. neverlib/.history/audio_aug/audio_aug_20250827154538.py +0 -356
  243. neverlib/.history/audio_aug/audio_aug_20250827154541.py +0 -357
  244. neverlib/.history/audio_aug/audio_aug_20250827154612.py +0 -357
  245. neverlib/.history/audio_aug/audio_aug_20250827154657.py +0 -360
  246. neverlib/.history/audio_aug/audio_aug_20250827154708.py +0 -360
  247. neverlib/.history/audio_aug/audio_aug_20250827154728.py +0 -366
  248. neverlib/.history/audio_aug/audio_aug_20250827154755.py +0 -367
  249. neverlib/.history/audio_aug/audio_aug_20250827154800.py +0 -367
  250. neverlib/.history/audio_aug/audio_aug_20250827154917.py +0 -368
  251. neverlib/.history/audio_aug/audio_aug_20250827154928.py +0 -369
  252. neverlib/.history/audio_aug/audio_aug_20250827154932.py +0 -370
  253. neverlib/.history/audio_aug/audio_aug_20250827154947.py +0 -372
  254. neverlib/.history/audio_aug/audio_aug_20250827155015.py +0 -375
  255. neverlib/.history/audio_aug/audio_aug_20250827155106.py +0 -375
  256. neverlib/.history/audio_aug/audio_aug_20250827155114.py +0 -393
  257. neverlib/.history/audio_aug/audio_aug_20250827155207.py +0 -415
  258. neverlib/.history/audio_aug/audio_aug_20250827155300.py +0 -415
  259. neverlib/.history/audio_aug/audio_aug_20250827155321.py +0 -471
  260. neverlib/.history/audio_aug/audio_aug_20250827164703.py +0 -471
  261. neverlib/.history/audio_aug/audio_aug_20250827164749.py +0 -471
  262. neverlib/.history/audio_aug/audio_aug_20250827165252.py +0 -472
  263. neverlib/.history/audio_aug/audio_aug_20250827165334.py +0 -472
  264. neverlib/.history/audio_aug/audio_aug_20250827165404.py +0 -473
  265. neverlib/.history/audio_aug/audio_aug_20250827165610.py +0 -473
  266. neverlib/.history/audio_aug/audio_aug_20250827165805.py +0 -473
  267. neverlib/.history/audio_aug/audio_aug_20250827170056.py +0 -473
  268. neverlib/.history/audio_aug/audio_aug_20250827170106.py +0 -472
  269. neverlib/.history/audio_aug/audio_aug_20250827170143.py +0 -472
  270. neverlib/.history/audio_aug/audio_aug_20250827170216.py +0 -472
  271. neverlib/.history/audio_aug/audio_aug_20250827170218.py +0 -472
  272. neverlib/.history/audio_aug/audio_aug_20250827170314.py +0 -472
  273. neverlib/.history/audio_aug/audio_aug_20250827171500.py +0 -471
  274. neverlib/.history/audio_aug/audio_aug_20250827172347.py +0 -471
  275. neverlib/.history/audio_aug/audio_aug_20250827172558.py +0 -470
  276. neverlib/.history/audio_aug/audio_aug_20250827172559.py +0 -470
  277. neverlib/.history/audio_aug/audio_aug_20250827172801.py +0 -470
  278. neverlib/.history/audio_aug/audio_aug_20250827182522.py +0 -470
  279. neverlib/.history/audio_aug/audio_aug_20250827182526.py +0 -470
  280. neverlib/.history/audio_aug/audio_aug_20250827182626.py +0 -470
  281. neverlib/.history/audio_aug/audio_aug_20250827182715.py +0 -470
  282. neverlib/.history/audio_aug/audio_aug_20250904185444.py +0 -470
  283. neverlib/.history/audio_aug/audio_aug_20250904185538.py +0 -445
  284. neverlib/.history/dataAnalyze/__init___20250805234204.py +0 -87
  285. neverlib/.history/dataAnalyze/__init___20250806204125.py +0 -14
  286. neverlib/.history/dataAnalyze/__init___20250806204139.py +0 -14
  287. neverlib/.history/dataAnalyze/__init___20250806204159.py +0 -14
  288. neverlib/.history/data_analyze/__init___20250806204158.py +0 -14
  289. neverlib/.history/data_analyze/__init___20250827163248.py +0 -14
  290. neverlib/.history/filter/__init___20250820103351.py +0 -70
  291. neverlib/.history/filter/__init___20250821102348.py +0 -70
  292. neverlib/.history/filter/__init___20250821102405.py +0 -14
  293. neverlib/.history/filter/auto_eq/__init___20250819213121.py +0 -36
  294. neverlib/.history/filter/auto_eq/__init___20250821102241.py +0 -36
  295. neverlib/.history/filter/auto_eq/__init___20250821102259.py +0 -36
  296. neverlib/.history/filter/auto_eq/__init___20250821102307.py +0 -36
  297. neverlib/.history/filter/auto_eq/__init___20250821102310.py +0 -36
  298. neverlib/.history/filter/auto_eq/__init___20250821102318.py +0 -36
  299. neverlib/.history/filter/auto_eq/__init___20250821102507.py +0 -36
  300. neverlib/.history/filter/auto_eq/de_eq_20250820103848.py +0 -361
  301. neverlib/.history/filter/auto_eq/de_eq_20250821102422.py +0 -360
  302. neverlib/.history/filter/auto_eq/freq_eq_20250805234206.py +0 -75
  303. neverlib/.history/filter/auto_eq/freq_eq_20250820140732.py +0 -75
  304. neverlib/.history/filter/auto_eq/freq_eq_20250820140745.py +0 -75
  305. neverlib/.history/filter/auto_eq/freq_eq_20250820140816.py +0 -75
  306. neverlib/.history/filter/auto_eq/freq_eq_20250820140938.py +0 -77
  307. neverlib/.history/filter/auto_eq/freq_eq_20250820141003.py +0 -77
  308. neverlib/.history/filter/auto_eq/freq_eq_20250820141006.py +0 -77
  309. neverlib/.history/filter/auto_eq/freq_eq_20250820141019.py +0 -77
  310. neverlib/.history/filter/auto_eq/freq_eq_20250820141049.py +0 -77
  311. neverlib/.history/filter/auto_eq/freq_eq_20250820141211.py +0 -77
  312. neverlib/.history/filter/auto_eq/freq_eq_20250820141227.py +0 -77
  313. neverlib/.history/filter/auto_eq/freq_eq_20250820141311.py +0 -78
  314. neverlib/.history/filter/auto_eq/freq_eq_20250820141340.py +0 -78
  315. neverlib/.history/filter/auto_eq/freq_eq_20250820141712.py +0 -78
  316. neverlib/.history/filter/auto_eq/freq_eq_20250820141733.py +0 -78
  317. neverlib/.history/filter/auto_eq/freq_eq_20250820141755.py +0 -78
  318. neverlib/.history/filter/auto_eq/freq_eq_20250821102434.py +0 -76
  319. neverlib/.history/filter/auto_eq/freq_eq_20250821102500.py +0 -76
  320. neverlib/.history/filter/auto_eq/freq_eq_20250821102502.py +0 -76
  321. neverlib/.history/filter/auto_eq/freq_eq_20250821143140.py +0 -76
  322. neverlib/.history/filter/auto_eq/freq_eq_20250821153208.py +0 -76
  323. neverlib/.history/filter/auto_eq/freq_eq_20250821153214.py +0 -76
  324. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820102957.py +0 -380
  325. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113054.py +0 -380
  326. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113150.py +0 -380
  327. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113520.py +0 -385
  328. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113525.py +0 -385
  329. neverlib/.history/filter/auto_eq/ga_eq_basic_20250821102212.py +0 -385
  330. neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110521.py +0 -385
  331. neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110652.py +0 -385
  332. neverlib/.history/filter/common_20250806002134.py +0 -37
  333. neverlib/.history/filter/common_20250821120448.py +0 -49
  334. neverlib/.history/filter/common_20250821120453.py +0 -49
  335. neverlib/.history/metrics/dnsmos_20250806001612.py +0 -160
  336. neverlib/.history/metrics/dnsmos_20250815180659.py +0 -160
  337. neverlib/.history/metrics/dnsmos_20250815180701.py +0 -158
  338. neverlib/.history/metrics/dnsmos_20250815181321.py +0 -154
  339. neverlib/.history/metrics/dnsmos_20250815181327.py +0 -154
  340. neverlib/.history/metrics/dnsmos_20250815181331.py +0 -154
  341. neverlib/.history/metrics/dnsmos_20250815181620.py +0 -154
  342. neverlib/.history/metrics/dnsmos_20250815181631.py +0 -154
  343. neverlib/.history/metrics/dnsmos_20250815181742.py +0 -154
  344. neverlib/.history/metrics/dnsmos_20250815181824.py +0 -153
  345. neverlib/.history/metrics/dnsmos_20250815181834.py +0 -153
  346. neverlib/.history/metrics/dnsmos_20250815181922.py +0 -153
  347. neverlib/.history/metrics/dnsmos_20250815182011.py +0 -147
  348. neverlib/.history/metrics/dnsmos_20250815182036.py +0 -144
  349. neverlib/.history/metrics/dnsmos_20250815182936.py +0 -143
  350. neverlib/.history/metrics/dnsmos_20250815182942.py +0 -143
  351. neverlib/.history/metrics/dnsmos_20250815183032.py +0 -137
  352. neverlib/.history/metrics/dnsmos_20250815183101.py +0 -144
  353. neverlib/.history/metrics/dnsmos_20250815183121.py +0 -144
  354. neverlib/.history/metrics/dnsmos_20250815183123.py +0 -143
  355. neverlib/.history/metrics/dnsmos_20250815183214.py +0 -143
  356. neverlib/.history/metrics/dnsmos_20250815183240.py +0 -143
  357. neverlib/.history/metrics/dnsmos_20250815183248.py +0 -144
  358. neverlib/.history/metrics/dnsmos_20250815183407.py +0 -142
  359. neverlib/.history/metrics/dnsmos_20250815183409.py +0 -142
  360. neverlib/.history/metrics/dnsmos_20250815183431.py +0 -142
  361. neverlib/.history/metrics/dnsmos_20250815183507.py +0 -140
  362. neverlib/.history/metrics/dnsmos_20250815183513.py +0 -139
  363. neverlib/.history/metrics/dnsmos_20250815183618.py +0 -139
  364. neverlib/.history/metrics/dnsmos_20250815183709.py +0 -140
  365. neverlib/.history/metrics/dnsmos_20250815183756.py +0 -137
  366. neverlib/.history/metrics/dnsmos_20250815183815.py +0 -128
  367. neverlib/.history/metrics/dnsmos_20250815183827.py +0 -129
  368. neverlib/.history/metrics/dnsmos_20250815183913.py +0 -117
  369. neverlib/.history/metrics/dnsmos_20250815183914.py +0 -117
  370. neverlib/.history/metrics/dnsmos_20250815184003.py +0 -118
  371. neverlib/.history/metrics/dnsmos_20250815184040.py +0 -118
  372. neverlib/.history/metrics/dnsmos_20250815184049.py +0 -118
  373. neverlib/.history/metrics/dnsmos_20250815184104.py +0 -117
  374. neverlib/.history/metrics/dnsmos_20250815184200.py +0 -117
  375. neverlib/.history/metrics/lpc_lsp_metric_20250816015944.py +0 -128
  376. neverlib/.history/metrics/lpc_lsp_metric_20250816020142.py +0 -128
  377. neverlib/.history/metrics/lpc_lsp_metric_20250816020156.py +0 -128
  378. neverlib/.history/metrics/lpc_lsp_metric_20250816020554.py +0 -130
  379. neverlib/.history/metrics/lpc_lsp_metric_20250816020600.py +0 -125
  380. neverlib/.history/metrics/lpc_lsp_metric_20250816020631.py +0 -120
  381. neverlib/.history/metrics/lpc_lsp_metric_20250816020746.py +0 -118
  382. neverlib/.history/metrics/lpc_me_20250816013111.py +0 -0
  383. neverlib/.history/metrics/lpc_me_20250816013129.py +0 -121
  384. neverlib/.history/metrics/lpc_me_20250816015430.py +0 -103
  385. neverlib/.history/metrics/lpc_me_20250816015535.py +0 -96
  386. neverlib/.history/metrics/lpc_me_20250816015542.py +0 -96
  387. neverlib/.history/metrics/lpc_me_20250816015636.py +0 -97
  388. neverlib/.history/metrics/lpc_me_20250816015658.py +0 -104
  389. neverlib/.history/metrics/lpc_me_20250816015703.py +0 -100
  390. neverlib/.history/metrics/lpc_me_20250816015945.py +0 -128
  391. neverlib/.history/metrics/snr_20250806010538.py +0 -177
  392. neverlib/.history/metrics/snr_20250806211634.py +0 -184
  393. neverlib/.history/metrics/snr_20250827224201.py +0 -182
  394. neverlib/.history/metrics/snr_20250827234019.py +0 -186
  395. neverlib/.history/metrics/snr_20250827234028.py +0 -186
  396. neverlib/.history/metrics/snr_20250827234030.py +0 -186
  397. neverlib/.history/metrics/spec_20250805234209.py +0 -45
  398. neverlib/.history/metrics/spec_20250816135530.py +0 -11
  399. neverlib/.history/metrics/spec_20250816135654.py +0 -16
  400. neverlib/.history/metrics/spec_20250816135736.py +0 -68
  401. neverlib/.history/metrics/spec_20250816135904.py +0 -75
  402. neverlib/.history/metrics/spec_20250816135921.py +0 -82
  403. neverlib/.history/metrics/spec_20250816140111.py +0 -82
  404. neverlib/.history/metrics/spec_20250816140543.py +0 -136
  405. neverlib/.history/metrics/spec_20250816140559.py +0 -172
  406. neverlib/.history/metrics/spec_20250816140602.py +0 -172
  407. neverlib/.history/metrics/spec_20250816140608.py +0 -172
  408. neverlib/.history/metrics/spec_20250816140654.py +0 -148
  409. neverlib/.history/metrics/spec_20250816140705.py +0 -144
  410. neverlib/.history/metrics/spec_20250816140755.py +0 -138
  411. neverlib/.history/metrics/spec_20250816140823.py +0 -170
  412. neverlib/.history/metrics/spec_20250816140832.py +0 -170
  413. neverlib/.history/metrics/spec_20250816140833.py +0 -170
  414. neverlib/.history/metrics/spec_20250816140922.py +0 -147
  415. neverlib/.history/metrics/spec_20250816141148.py +0 -107
  416. neverlib/.history/metrics/spec_20250816141219.py +0 -123
  417. neverlib/.history/metrics/spec_20250816141732.py +0 -178
  418. neverlib/.history/metrics/spec_20250816141740.py +0 -178
  419. neverlib/.history/metrics/spec_20250816142030.py +0 -178
  420. neverlib/.history/metrics/spec_20250816142107.py +0 -135
  421. neverlib/.history/metrics/spec_20250816142126.py +0 -135
  422. neverlib/.history/metrics/spec_20250816142410.py +0 -135
  423. neverlib/.history/metrics/spec_20250816142415.py +0 -136
  424. neverlib/.history/metrics/spec_metric_20250816135156.py +0 -0
  425. neverlib/.history/metrics/spec_metric_20250816135226.py +0 -5
  426. neverlib/.history/metrics/spec_metric_20250816135227.py +0 -10
  427. neverlib/.history/metrics/spec_metric_20250816135306.py +0 -15
  428. neverlib/.history/metrics/spec_metric_20250816135442.py +0 -31
  429. neverlib/.history/metrics/spec_metric_20250816135448.py +0 -31
  430. neverlib/.history/metrics/spec_metric_20250816135520.py +0 -29
  431. neverlib/.history/metrics/spec_metric_20250816135537.py +0 -63
  432. neverlib/.history/metrics/spec_metric_20250816135653.py +0 -65
  433. neverlib/.history/utils/audio_split_20250805234209.py +0 -268
  434. neverlib/.history/utils/audio_split_20250904185309.py +0 -268
  435. neverlib/.history/utils/utils_20250813165516.py +0 -330
  436. neverlib/.history/utils/utils_20250904181341.py +0 -328
  437. neverlib/.history/utils/utils_20250904185546.py +0 -352
  438. neverlib/.history/utils/utils_20250904185548.py +0 -353
  439. neverlib/.history/utils/utils_20250904185603.py +0 -353
  440. neverlib/.history/utils/utils_20250904185636.py +0 -353
  441. neverlib/.history/utils/utils_20250904185658.py +0 -358
  442. neverlib/.history/utils/utils_20250904190053.py +0 -359
  443. neverlib/.history/vad/PreProcess_20250805234211.py +0 -63
  444. neverlib/.history/vad/PreProcess_20250809232455.py +0 -63
  445. neverlib/.history/vad/PreProcess_20250816020725.py +0 -66
  446. neverlib/.history/vad/VAD_Silero_20250805234211.py +0 -50
  447. neverlib/.history/vad/VAD_Silero_20250809232456.py +0 -50
  448. neverlib/.history/vad/VAD_WebRTC_20250805234211.py +0 -61
  449. neverlib/.history/vad/VAD_WebRTC_20250809232456.py +0 -61
  450. neverlib/.history/vad/VAD_funasr_20250805234211.py +0 -54
  451. neverlib/.history/vad/VAD_funasr_20250809232456.py +0 -54
  452. neverlib/.history/vad/VAD_vadlib_20250805234211.py +0 -70
  453. neverlib/.history/vad/VAD_vadlib_20250809232455.py +0 -70
  454. neverlib/.history/vad/VAD_whisper_20250805234211.py +0 -55
  455. neverlib/.history/vad/VAD_whisper_20250809232456.py +0 -55
  456. neverlib/.specstory/.what-is-this.md +0 -69
  457. 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
  458. 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
  459. neverlib/.specstory/history/2025-08-26_11-54Z-oserror-missing-shared-object-file.md +0 -87
  460. 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
  461. neverlib/.specstory/history/2025-08-27_08-29Z-delete-python-file-command.md +0 -211
  462. 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
  463. neverlib-0.2.8.dist-info/RECORD +0 -510
  464. {neverlib-0.2.8.dist-info → neverlib-0.3.0.dist-info}/WHEEL +0 -0
  465. {neverlib-0.2.8.dist-info → neverlib-0.3.0.dist-info}/licenses/LICENSE +0 -0
  466. {neverlib-0.2.8.dist-info → neverlib-0.3.0.dist-info}/top_level.txt +0 -0
@@ -1,136 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description: 音频信号频域客观度量指标计算工具
5
- 主要功能:
6
- 1. SD (Spectral Distance) - 频谱距离
7
- - 计算两个音频信号在频域上的差异程度
8
- - 适用于音频质量评估和信号相似性分析
9
-
10
- 2. LSD (Log-Spectral Distance) - 对数谱距离
11
- - 在对数功率谱域计算信号距离
12
- - 更符合人耳听觉特性,常用于语音质量评估
13
-
14
- 3. MCD (Mel-Cepstral Distance) - 梅尔倒谱距离
15
- - 基于MFCC特征的音频相似性度量
16
- - 广泛应用于语音合成、语音识别等任务
17
- '''
18
-
19
- import librosa
20
- import numpy as np
21
- import soundfile as sf
22
- from neverlib.utils import EPS
23
-
24
-
25
- def sd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
26
- """
27
- 计算两个音频信号之间的频谱距离 (Spectral Distance)。
28
- 该指标衡量两个信号在频域上的差异程度。
29
- Args:
30
- ref_wav (np.ndarray): 参考音频信号 (一维数组)
31
- test_wav (np.ndarray): 测试音频信号 (一维数组)
32
- n_fft (int): FFT点数,决定频率分辨率,默认为2048
33
- hop_length (int): 帧移,决定时间分辨率,默认为512
34
- win_length (int, optional): 窗长,如果为None则默认为n_fft
35
- Returns:
36
- float: 频谱距离值,值越小表示两个信号越相似
37
- """
38
- assert len(ref_wav) == len(test_wav), "输入信号长度必须相同"
39
-
40
- # 计算短时傅里叶变换
41
- ref_spec = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length)
42
- test_spec = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length)
43
-
44
- # 计算频谱距离:均方根误差
45
- spec_diff = ref_spec - test_spec
46
- squared_diff = np.abs(spec_diff) ** 2
47
- mean_squared_diff = np.mean(squared_diff)
48
- sd_value = np.sqrt(mean_squared_diff)
49
-
50
- return sd_value
51
-
52
-
53
-
54
-
55
- def lsd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
56
- """
57
- 计算两个一维音频信号之间的对数谱距离 (Log-Spectral Distance, LSD)。
58
- 该实现遵循标准的LSD定义: 整体均方根误差。
59
-
60
- Args:
61
- ref_wav (np.ndarray): 原始的、干净的参考信号 (一维数组)。
62
- test_wav (np.ndarray): 模型估计或处理后的信号 (一维数组)。
63
- n_fft (int): FFT点数, 决定了频率分辨率。
64
- hop_length (int): 帧移, 决定了时间分辨率。
65
- win_length (int, optional): 窗长。如果为None, 则默认为n_fft。
66
- epsilon (float): 一个非常小的数值, 用于防止对零取对数, 保证数值稳定性。
67
-
68
- Returns:
69
- float: 对数谱距离值, 单位为分贝 (dB)。
70
- """
71
- assert ref_wav.ndim == 1 and test_wav.ndim == 1, "输入信号必须是一维数组。"
72
-
73
- if win_length is None:
74
- win_length = n_fft
75
-
76
- ref_stft = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
77
- test_stft = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
78
-
79
- ref_power_spec = np.abs(ref_stft) ** 2 # (F,T)
80
- test_power_spec = np.abs(test_stft) ** 2 # (F,T)
81
-
82
- ref_log_power_spec = 10 * np.log10(ref_power_spec + EPS)
83
- test_log_power_spec = 10 * np.log10(test_power_spec + EPS)
84
-
85
- squared_error = (ref_log_power_spec - test_log_power_spec) ** 2
86
- lsd_val = np.sqrt(np.mean(squared_error))
87
-
88
- return lsd_val
89
-
90
-
91
- def mcd(ref_wav, test_wav, sr=16000, n_mfcc=13):
92
- """
93
- 计算两个音频信号之间的梅尔倒谱距离 (Mel-Cepstral Distance, MCD)。
94
- 该指标常用于语音合成质量评估,值越小表示两个信号越相似。
95
-
96
- Args:
97
- ref_wav (np.ndarray): 参考音频信号 (一维数组)
98
- test_wav (np.ndarray): 测试音频信号 (一维数组)
99
- sr (int): 采样率,默认为16000Hz
100
- n_mfcc (int): MFCC系数个数,默认为13
101
-
102
- Returns:
103
- float: 梅尔倒谱距离值,值越小表示两个信号越相似
104
-
105
- """
106
- assert len(ref_wav) == len(test_wav), "输入信号长度必须相同"
107
-
108
- # 计算MFCC特征
109
- ref_mfcc = librosa.feature.mfcc(y=ref_wav, sr=sr, n_mfcc=n_mfcc)
110
- test_mfcc = librosa.feature.mfcc(y=test_wav, sr=sr, n_mfcc=n_mfcc)
111
-
112
- # 计算MCD (跳过0阶系数,因为0阶主要表示能量)
113
- diff = ref_mfcc[1:] - test_mfcc[1:]
114
- mcd_value = (10.0 / np.log(10)) * np.sqrt(2 * np.mean(np.sum(diff ** 2, axis=0)))
115
-
116
- return mcd_value
117
-
118
-
119
- if __name__ == "__main__":
120
- ref_file = "../data/vad_example.wav" # 参考语音文件路径
121
- test_file = "../data/vad_example.wav" # 测试语音文件路径
122
-
123
- ref_wav, ref_sr = sf.read(ref_file)
124
- test_wav, test_sr = sf.read(test_file)
125
- assert ref_sr == test_sr == 16000, "采样率必须为16000Hz"
126
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
127
-
128
- mcd_value = mcd(ref_wav, test_wav)
129
- print(f"梅尔倒谱距离: {mcd_value:.2f}")
130
-
131
- lsd_value = lsd(ref_wav, test_wav)
132
- print(f"对数谱距离: {lsd_value:.2f}")
133
-
134
- sd_value = sd(ref_wav, test_wav)
135
- print(f"频谱距离: {sd_value:.2f}")
136
-
File without changes
@@ -1,5 +0,0 @@
1
-
2
-
3
-
4
- def mcd(ref_spec, test_spec):
5
- #
@@ -1,10 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description:
5
- '''
6
-
7
-
8
-
9
- def mcd(ref_spec, test_spec):
10
- #
@@ -1,15 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description:
5
- '''
6
-
7
-
8
-
9
- def mcd(ref_spec, test_spec):
10
- """
11
- 梅尔倒谱距离 Mel-Cepstral Distance(MCD)
12
- ref_spec: 参考频谱
13
- test_spec: 测试频谱
14
- """
15
-
@@ -1,31 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description:
5
- '''
6
-
7
- import librosa
8
- import numpy as np
9
- import soundfile as sf
10
-
11
-
12
- def mcd(ref_wav, test_wav, sr=16000):
13
- """
14
- 梅尔倒谱距离 Mel-Cepstral Distance(MCD)
15
- ref_spec: 参考频谱
16
- test_spec: 测试频谱
17
- """
18
- ref_wav, ref_sr = sf.read(ref_wav)
19
- test_wav, test_sr = sf.read(test_wav)
20
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
21
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
22
-
23
- ref_mfc = librosa.feature.mfcc(y=ref_wav, sr=sr)
24
- test_mfc = librosa.feature.mfcc(y=test_wav, sr=sr)
25
-
26
- mcd = np.mean(np.abs(ref_mfc - test_mfc))
27
-
28
-
29
-
30
- return mcd
31
-
@@ -1,31 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description:
5
- '''
6
-
7
- import librosa
8
- import numpy as np
9
- import soundfile as sf
10
-
11
-
12
- def mcd(ref_wav, test_wav, sr=16000):
13
- """
14
- 梅尔倒谱距离 Mel-Cepstral Distance(MCD)
15
- ref_spec: 参考频谱
16
- test_spec: 测试频谱
17
- """
18
- ref_wav, ref_sr = sf.read(ref_wav)
19
- test_wav, test_sr = sf.read(test_wav)
20
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
21
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
22
-
23
- ref_mfc = librosa.feature.mfcc(y=ref_wav, sr=sr)
24
- test_mfc = librosa.feature.mfcc(y=test_wav, sr=sr)
25
-
26
- # 计算 MCD (跳过 0 阶)
27
-
28
-
29
-
30
- return mcd
31
-
@@ -1,29 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description:
5
- '''
6
-
7
- import librosa
8
- import numpy as np
9
- import soundfile as sf
10
-
11
-
12
- def mcd(ref_wav, test_wav, sr=16000):
13
- """
14
- 梅尔倒谱距离 Mel-Cepstral Distance
15
- ref_spec: 参考频谱
16
- test_spec: 测试频谱
17
- """
18
- ref_wav, ref_sr = sf.read(ref_wav)
19
- test_wav, test_sr = sf.read(test_wav)
20
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
21
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
22
-
23
- ref_mfcc = librosa.feature.mfcc(y=ref_wav, sr=sr)
24
- test_mfcc = librosa.feature.mfcc(y=test_wav, sr=sr)
25
-
26
- # 计算 MCD (跳过 0 阶)
27
- diff = ref_mfcc[1:] - test_mfcc[1:]
28
- mcd = (10.0 / np.log(10)) * np.sqrt(2 * np.mean(np.sum(diff ** 2, axis=0)))
29
- return mcd
@@ -1,63 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description:
5
- '''
6
-
7
- import librosa
8
- import numpy as np
9
- import soundfile as sf
10
-
11
- def lsd(reference, estimate, n_fft=2048, hop_length=512, win_length=None):
12
- """
13
- 计算两个一维音频信号之间的对数谱距离 (Log-Spectral Distance, LSD)。
14
- 该实现遵循标准的LSD定义: 整体均方根误差。
15
-
16
- Args:
17
- reference (np.ndarray): 原始的、干净的参考信号 (一维数组)。
18
- estimate (np.ndarray): 模型估计或处理后的信号 (一维数组)。
19
- n_fft (int): FFT点数, 决定了频率分辨率。
20
- hop_length (int): 帧移, 决定了时间分辨率。
21
- win_length (int, optional): 窗长。如果为None, 则默认为n_fft。
22
- epsilon (float): 一个非常小的数值, 用于防止对零取对数, 保证数值稳定性。
23
-
24
- Returns:
25
- float: 对数谱距离值, 单位为分贝 (dB)。
26
- """
27
- assert reference.ndim == 1 and estimate.ndim == 1, "输入信号必须是一维数组。"
28
-
29
- if win_length is None:
30
- win_length = n_fft
31
-
32
- reference_stft = librosa.stft(reference, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
33
- estimate_stft = librosa.stft(estimate, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
34
-
35
- reference_power_spec = np.abs(reference_stft) ** 2 # (F,T)
36
- estimate_power_spec = np.abs(estimate_stft) ** 2 # (F,T)
37
-
38
- reference_log_power_spec = 10 * np.log10(reference_power_spec + EPS)
39
- estimate_log_power_spec = 10 * np.log10(estimate_power_spec + EPS)
40
-
41
- squared_error = (reference_log_power_spec - estimate_log_power_spec) ** 2
42
- lsd_val = np.sqrt(np.mean(squared_error))
43
-
44
- return lsd_val
45
-
46
- def mcd(ref_wav, test_wav, sr=16000):
47
- """
48
- 梅尔倒谱距离 Mel-Cepstral Distance
49
- ref_spec: 参考频谱
50
- test_spec: 测试频谱
51
- """
52
- ref_wav, ref_sr = sf.read(ref_wav)
53
- test_wav, test_sr = sf.read(test_wav)
54
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
55
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
56
-
57
- ref_mfcc = librosa.feature.mfcc(y=ref_wav, sr=sr)
58
- test_mfcc = librosa.feature.mfcc(y=test_wav, sr=sr)
59
-
60
- # 计算 MCD (跳过 0 阶)
61
- diff = ref_mfcc[1:] - test_mfcc[1:]
62
- mcd = (10.0 / np.log(10)) * np.sqrt(2 * np.mean(np.sum(diff ** 2, axis=0)))
63
- return mcd
@@ -1,65 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-16 13:51:57
4
- Description:
5
- '''
6
-
7
- import librosa
8
- import numpy as np
9
- import soundfile as sf
10
- from utils import EPS
11
-
12
-
13
- def lsd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
14
- """
15
- 计算两个一维音频信号之间的对数谱距离 (Log-Spectral Distance, LSD)。
16
- 该实现遵循标准的LSD定义: 整体均方根误差。
17
-
18
- Args:
19
- ref_wav (np.ndarray): 原始的、干净的参考信号 (一维数组)。
20
- test_wav (np.ndarray): 模型估计或处理后的信号 (一维数组)。
21
- n_fft (int): FFT点数, 决定了频率分辨率。
22
- hop_length (int): 帧移, 决定了时间分辨率。
23
- win_length (int, optional): 窗长。如果为None, 则默认为n_fft。
24
- epsilon (float): 一个非常小的数值, 用于防止对零取对数, 保证数值稳定性。
25
-
26
- Returns:
27
- float: 对数谱距离值, 单位为分贝 (dB)。
28
- """
29
- assert ref_wav.ndim == 1 and test_wav.ndim == 1, "输入信号必须是一维数组。"
30
-
31
- if win_length is None:
32
- win_length = n_fft
33
-
34
- ref_stft = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
35
- test_stft = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
36
-
37
- ref_power_spec = np.abs(ref_stft) ** 2 # (F,T)
38
- test_power_spec = np.abs(test_stft) ** 2 # (F,T)
39
-
40
- ref_log_power_spec = 10 * np.log10(ref_power_spec + EPS)
41
- test_log_power_spec = 10 * np.log10(test_power_spec + EPS)
42
-
43
- squared_error = (ref_log_power_spec - test_log_power_spec) ** 2
44
- lsd_val = np.sqrt(np.mean(squared_error))
45
-
46
- return lsd_val
47
-
48
- def mcd(ref_wav, test_wav, sr=16000):
49
- """
50
- 梅尔倒谱距离 Mel-Cepstral Distance
51
- ref_spec: 参考频谱
52
- test_spec: 测试频谱
53
- """
54
- ref_wav, ref_sr = sf.read(ref_wav)
55
- test_wav, test_sr = sf.read(test_wav)
56
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
57
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
58
-
59
- ref_mfcc = librosa.feature.mfcc(y=ref_wav, sr=sr)
60
- test_mfcc = librosa.feature.mfcc(y=test_wav, sr=sr)
61
-
62
- # 计算 MCD (跳过 0 阶)
63
- diff = ref_mfcc[1:] - test_mfcc[1:]
64
- mcd = (10.0 / np.log(10)) * np.sqrt(2 * np.mean(np.sum(diff ** 2, axis=0)))
65
- return mcd
@@ -1,268 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-04-10 18:07:03
4
- Description: 音频切割
5
- '''
6
- import os
7
- import random
8
- import subprocess
9
- from tqdm import tqdm
10
- import soundfile as sf
11
- import numpy as np
12
- from .utils import get_path_list
13
- from pydub import AudioSegment
14
-
15
-
16
- def audio_split_ffmpeg(source_path, target_path, sr, channel_num, duration, endwith="*.pcm"):
17
- """ 切割音频切不准, 会留点尾巴0.016s
18
- 使用ffmpeg分割音频, 分割为短音频(单位:秒), 似乎无法非常准确的分割到指定长度
19
- :param source_path: 源音频路径
20
- :param target_path: 目标音频路径
21
- :param sr: 源音频采样率
22
- :param channel_num: 源音频声道数
23
- :param duration: 分割为时长(短音频)(单位:秒)
24
- :param endwith: 音频格式(支持pcm和wav)
25
- """
26
- wav_path_list = get_path_list(source_path, end=endwith)
27
- print("待分割的音频数: ", len(wav_path_list))
28
- for wav_path in wav_path_list:
29
- wav_folder = wav_path[:-4].replace(source_path, target_path)
30
- os.makedirs(wav_folder, exist_ok=True)
31
-
32
- if endwith == "*.pcm":
33
- # 将pcm文件切割成30s的语音, 有括号会报错
34
- # ffmpeg -f s16le -ar 16000 -ac 6 -i ./NO.1_A3035_2.pcm -f segment -segment_time 30 -c copy NO.1_A3035_2/%03d.wav
35
- command = ["ffmpeg", "-f", "s16le", "-ar", f"{sr}", "-ac", str(channel_num),
36
- "-i", wav_path, "-f", "segment", "-segment_time",
37
- f"{duration}", "-c", "copy", f"{wav_folder}/%03d.wav"]
38
- subprocess.run(command, check=True)
39
- elif endwith == "*.wav":
40
- # ffmpeg -i ./NO.1_A3035_2.wav -f segment -segment_time 30 -c copy NO.1_A3035_2/%03d.wav
41
- command = ["ffmpeg", "-i", wav_path, "-f", "segment", "-segment_time",
42
- f"{duration}", "-c", "copy", f"{wav_folder}/%03d.wav"]
43
- subprocess.run(command, check=True)
44
- else:
45
- assert False, "不支持的音频格式"
46
- print("分割完毕: done!")
47
-
48
-
49
- def audio_split_sox(source_path, target_path, duration, endwith="*.wav"):
50
- """
51
- 使用sox分割音频, 分割为短音频(单位:秒), 可以非常准确的分割到指定长度
52
- :param source_path: 源音频路径
53
- :param target_path: 目标音频路径
54
- :param duration: 分割为时长(短音频)(单位:秒)
55
- :param endwith: 音频格式(只支持wav)
56
- """
57
- wav_path_list = get_path_list(source_path, end=endwith)
58
-
59
- for wav_path in wav_path_list:
60
- wav_folder = wav_path[:-4].replace(source_path, target_path)
61
- os.makedirs(wav_folder, exist_ok=True)
62
-
63
- output_pattern = f"{wav_folder}/%.wav"
64
-
65
- if endwith == "*.wav":
66
- # 对 WAV 文件直接进行分割
67
- os.system(f"sox {wav_path} {output_pattern} trim 0 {str(duration)} : newfile : restart")
68
- else:
69
- assert False, "不支持的音频格式"
70
-
71
- print("分割完毕: done!")
72
-
73
-
74
- def audio_split_np(source_path, target_path, sr, channel_num, duration, endwith="*.pcm"):
75
- """
76
- 使用numpy读取pcm文件并切割保存为wav文件, 保持通道数一致, 保存不足30秒的最后一段音频
77
- :param source_path: 源音频路径
78
- :param target_path: 目标音频路径
79
- :param sr: 采样率
80
- :param channel_num: 声道数
81
- :param duration: 分割的时长 (秒)
82
- :param endwith: 音频格式 (支持 pcm)
83
- """
84
- assert endwith == "*.pcm", "只支持pcm格式的音频"
85
- wav_path_list = get_path_list(source_path, end=endwith) # 获取音频文件列表
86
- print("待分割的音频数: ", len(wav_path_list))
87
-
88
- segment_length_samples = duration * sr # 每个切片音频的采样点数
89
-
90
- for wav_path in wav_path_list:
91
- print("正在分割: ", wav_path)
92
- wav_folder = wav_path[:-4].replace(source_path, target_path)
93
- os.makedirs(wav_folder, exist_ok=True)
94
-
95
- # 注意读取时使用正确的dtype(例如int16表示16位PCM)
96
- pcm_data = np.fromfile(wav_path, dtype=np.int16)
97
- pcm_data = pcm_data[:(len(pcm_data) // channel_num) * channel_num]
98
- pcm_data = pcm_data.reshape(-1, channel_num)
99
-
100
- # 计算分割的数量
101
- num_segments = len(pcm_data) // segment_length_samples
102
-
103
- # 切割并保存每段音频
104
- for i in tqdm(range(num_segments)):
105
- start_idx = i * segment_length_samples
106
- end_idx = (i + 1) * segment_length_samples
107
- segment = pcm_data[start_idx:end_idx]
108
- segment_filename = os.path.join(wav_folder, f"{i + 1:03d}.wav") # 保存为wav文件
109
- sf.write(segment_filename, segment, sr, subtype='PCM_16')
110
-
111
- # 如果剩余部分少于30秒, 保存最后一段不足30秒的音频
112
- remaining_samples = len(pcm_data) % segment_length_samples
113
- if remaining_samples > 0:
114
- segment = pcm_data[-remaining_samples:]
115
- # 保存剩余部分
116
- remaining_filename = os.path.join(wav_folder, f"{num_segments + 1:03d}.wav")
117
- sf.write(remaining_filename, segment, sr, subtype='PCM_16')
118
-
119
- print("分割完毕: done!")
120
-
121
-
122
- def audio_split_pydub(source_path, target_path, sr, channel_num, duration, endwith="*.pcm", sample_width=2):
123
- """
124
- 使用pydub分割音频, 进行精确的分割
125
- :param source_path: 源音频路径
126
- :param target_path: 目标音频路径
127
- :param sr: 源音频采样率
128
- :param channel_num: 源音频声道数
129
- :param duration: 分割为时长(短音频)(单位:秒), 必须是1s的整数倍
130
- :param endwith: 音频格式(支持pcm和wav)
131
- :param sample_width: 音频的样本宽度(字节数), 默认为2, 表示16位音频
132
- """
133
- assert duration % 1 == 0, "duration必须是1s的整数倍"
134
- wav_path_list = get_path_list(source_path, end=endwith) # 获取音频文件列表
135
- print("待分割的音频数: ", len(wav_path_list))
136
-
137
- for wav_path in wav_path_list:
138
- print("正在分割: ", wav_path)
139
- wav_folder = wav_path[:-4].replace(source_path, target_path) # 设置目标文件夹
140
- os.makedirs(wav_folder, exist_ok=True)
141
-
142
- # 使用pydub加载音频
143
- if endwith == "*.pcm":
144
- # 读取pcm文件, 指定采样率、声道数和样本宽度
145
- audio = AudioSegment.from_file(wav_path, format="raw", channels=channel_num, frame_rate=sr, sample_width=sample_width)
146
- elif endwith == "*.wav":
147
- # 读取wav文件
148
- audio = AudioSegment.from_wav(wav_path)
149
- else:
150
- assert False, "不支持的音频格式"
151
-
152
- # 计算每段的时长(以毫秒为单位)
153
- segment_length = duration * 1000 # 转换为毫秒
154
-
155
- # 切割音频并保存为多个文件
156
- segment_number = 1
157
- for i in tqdm(range(0, len(audio), segment_length)):
158
- segment = audio[i:i + segment_length]
159
- segment_filename = os.path.join(wav_folder, f"{segment_number:03d}.wav")
160
- segment.export(segment_filename, format="wav")
161
- segment_number += 1
162
-
163
- print("分割完毕: done!")
164
-
165
-
166
- def audio_split_random(source_dir, target_dir, min_duration=3, max_duration=10, sr=16000):
167
- """
168
- 将音频切割成 3 到 10 秒的多个片段并保存。
169
- 参数:
170
- - input_audio_path: 输入音频文件路径
171
- - output_dir: 输出音频文件夹路径
172
- - min_duration: 最短切割片段长度 (秒), 默认3秒
173
- - max_duration: 最长切割片段长度 (秒), 默认10秒
174
- - sample_rate: 采样率, 默认16000
175
- """
176
- wav_path_list = get_path_list(source_dir, "*.wav")
177
- for wav_path in wav_path_list:
178
- output_dir = wav_path[:-4].replace(source_dir, target_dir)
179
- os.makedirs(output_dir, exist_ok=True)
180
-
181
- wav, wav_sr = sf.read(wav_path, always_2d=True)
182
- assert wav_sr == sr, f"音频采样率不匹配: {wav_sr} != {sr}"
183
- count = 0
184
- while len(wav) > max_duration * sr:
185
- segment_len = random.randint(min_duration * sr, max_duration * sr)
186
- segment = wav[0: segment_len]
187
- wav = wav[segment_len:]
188
- count += 1
189
- sf.write(os.path.join(output_dir, f"{count}.wav"), segment, sr)
190
- sf.write(os.path.join(output_dir, f"{count + 1}.wav"), wav, sr)
191
-
192
-
193
- def audio_split_VADfunasr(source_dir, target_dir, sr=16000):
194
- """
195
- 使用funasr的vad模型将音频中的语音分割成短句
196
- """
197
- from filter import HPFilter
198
- from audio_aug import volume_norm
199
- from funasr import AutoModel
200
- model = AutoModel(model="fsmn-vad", model_revision="v2.0.4")
201
-
202
- wav_path_list = get_path_list(source_dir, "*.wav")
203
- for wav_path in wav_path_list:
204
- wav_folder = wav_path[:-4].replace(source_dir, target_dir)
205
- os.makedirs(wav_folder, exist_ok=True)
206
-
207
- wav_orig, wav_sr = sf.read(wav_path, always_2d=True)
208
- assert wav_sr == sr, f"音频采样率为{wav_sr}, 期望为{sr}"
209
-
210
- wav = HPFilter(wav_orig[:, 0], sr=sr, order=6, cutoff=100)
211
- wav = volume_norm(wav)
212
-
213
- res_list = model.generate(input=wav)
214
-
215
- for res in res_list:
216
- for i, value_item in enumerate(res["value"]):
217
- start, end = value_item
218
- start, end = int(start * wav_sr / 1000), int(end * wav_sr / 1000)
219
-
220
- # short_wav = wav_orig[start - int(0.5 * sr):end + int(0.5 * sr)]
221
- # duration = (end - start) / sr
222
- # assert len(short_wav) > sr * 3, f"{end/sr:.2f}-{start/sr:.2f}={duration:.2f}"
223
- sf.write(os.path.join(wav_folder, f"{i}.wav"), wav_orig[start:end], sr)
224
- # break
225
-
226
-
227
- def audio_split_VADsilero(source_dir, target_dir, sr, threshold=0.4,
228
- min_speech_duration_ms=400, min_silence_duration_ms=400,
229
- window_size_samples=512, speech_pad_ms=500):
230
- """
231
- 使用silero的vad模型将音频中的语音分割成短句
232
- source_dir: 音频文件目录
233
- target_dir: 分割后的音频文件目录
234
- sr: 音频采样率
235
- threshold: 阈值
236
- min_speech_duration_ms: 语音块的最小持续时间 ms
237
- min_silence_duration_ms: 语音块之间的最小静音时间 ms
238
- window_size_samples: 512\1024\1536
239
- """
240
- import torch
241
- from filter import HPFilter
242
- from audio_aug import volume_norm
243
- model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad', model='silero_vad', force_reload=False, onnx=True)
244
- (get_speech_timestamps, save_audio, read_audio, VADIterator, collect_chunks) = utils
245
-
246
- wav_path_list = get_path_list(source_dir, "*.wav")
247
- for wav_path in wav_path_list:
248
- wav_folder = wav_path[:-4].replace(source_dir, target_dir)
249
- os.makedirs(wav_folder, exist_ok=True)
250
-
251
- wav_orig, wav_sr = sf.read(wav_path, always_2d=True)
252
- assert wav_sr == sr, f"音频采样率为{wav_sr}, 期望为{sr}"
253
-
254
- wav = HPFilter(wav_orig[:, 0], sr=sr, order=6, cutoff=100)
255
- wav = volume_norm(wav)
256
-
257
- speech_timestamps = get_speech_timestamps(wav, model,
258
- sampling_rate=sr,
259
- threshold=threshold,
260
- min_speech_duration_ms=min_speech_duration_ms, # 语音块的最小持续时间 ms
261
- min_silence_duration_ms=min_silence_duration_ms, # 语音块之间的最小静音时间 ms
262
- window_size_samples=window_size_samples, # 512\1024\1536
263
- speech_pad_ms=speech_pad_ms, # 最后的语音块由两侧的speech_pad_ms填充
264
- )
265
- for i, timestamp in enumerate(speech_timestamps):
266
- wav_vad = wav_orig[timestamp["start"]:timestamp["end"]]
267
-
268
- sf.write(os.path.join(wav_folder, f"{i}.wav"), wav_vad, sr)