neverlib 0.2.7__py3-none-any.whl → 0.2.9__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 (430) hide show
  1. neverlib/QA/ImpactNoiseRejection.py +119 -0
  2. neverlib/QA/gen_init.py +107 -6
  3. neverlib/QA/impact_noise_rejection.png +0 -0
  4. neverlib/QA/out.pcm +0 -0
  5. neverlib/QA/out.wav +0 -0
  6. neverlib/__init__.py +19 -0
  7. neverlib/audio_aug/README.md +3 -0
  8. neverlib/audio_aug/__init__.py +2 -4
  9. neverlib/filter/core.py +8 -5
  10. neverlib/metrics/README.md +35 -0
  11. neverlib/metrics/__init__.py +1 -1
  12. neverlib/metrics/pesq_c/PESQ +0 -0
  13. neverlib/signal_gen/babble_noise_generate.py +113 -0
  14. neverlib/tests/__init__.py +16 -1
  15. neverlib/tests/test_imports.py +2 -0
  16. neverlib/utils/README.md +29 -0
  17. neverlib/utils/__init__.py +7 -6
  18. neverlib/utils/audio_split.py +21 -20
  19. neverlib/utils/checkGPU.py +52 -79
  20. neverlib/utils/floder.py +115 -0
  21. neverlib/utils/pcm.py +42 -0
  22. neverlib/utils/utils.py +3 -77
  23. neverlib/vad/PreProcess.py +66 -66
  24. {neverlib-0.2.7.dist-info → neverlib-0.2.9.dist-info}/METADATA +15 -1
  25. neverlib-0.2.9.dist-info/RECORD +119 -0
  26. neverlib/.claude/settings.local.json +0 -9
  27. neverlib/.history/Docs/audio_aug/del_20250827162530.py +0 -0
  28. neverlib/.history/Docs/audio_aug/del_20250827162540.py +0 -2
  29. neverlib/.history/Docs/audio_aug/del_20250827162541.py +0 -7
  30. neverlib/.history/Docs/audio_aug/del_20250827162606.py +0 -7
  31. neverlib/.history/Docs/audio_aug/del_20250827162637.py +0 -8
  32. neverlib/.history/Docs/audio_aug/del_20250827162645.py +0 -8
  33. neverlib/.history/Docs/audio_aug/del_20250827162723.py +0 -9
  34. neverlib/.history/Docs/audio_aug/del_20250827162739.py +0 -9
  35. neverlib/.history/Docs/audio_aug/test_snr_20250806011311.py +0 -0
  36. neverlib/.history/Docs/audio_aug/test_snr_20250806011331.py +0 -75
  37. neverlib/.history/Docs/audio_aug/test_snr_20250806011342.py +0 -57
  38. neverlib/.history/Docs/audio_aug/test_snr_20250806011352.py +0 -57
  39. neverlib/.history/Docs/audio_aug/test_snr_20250806011403.py +0 -57
  40. neverlib/.history/Docs/audio_aug/test_snr_20250806011413.py +0 -57
  41. neverlib/.history/Docs/audio_aug/test_snr_20250806011435.py +0 -55
  42. neverlib/.history/Docs/audio_aug/test_snr_20250827161751.py +0 -55
  43. neverlib/.history/Docs/audio_aug/test_snr_20250827161754.py +0 -55
  44. neverlib/.history/Docs/audio_aug/test_snr_20250827161833.py +0 -54
  45. neverlib/.history/Docs/audio_aug/test_snr_20250827162017.py +0 -56
  46. neverlib/.history/Docs/audio_aug/test_snr_20250827162021.py +0 -57
  47. neverlib/.history/Docs/audio_aug/test_snr_20250827162028.py +0 -57
  48. neverlib/.history/Docs/audio_aug/test_snr_20250827162033.py +0 -55
  49. neverlib/.history/Docs/audio_aug_test/del_20250827162738.py +0 -9
  50. neverlib/.history/Docs/audio_aug_test/del_20250827162819.py +0 -9
  51. neverlib/.history/Docs/audio_aug_test/del_20250827162830.py +0 -9
  52. neverlib/.history/Docs/audio_aug_test/del_20250827162846.py +0 -9
  53. neverlib/.history/Docs/audio_aug_test/del_20250827162851.py +0 -9
  54. neverlib/.history/Docs/audio_aug_test/del_20250827162903.py +0 -10
  55. neverlib/.history/Docs/audio_aug_test/del_20250827162921.py +0 -10
  56. neverlib/.history/Docs/audio_aug_test/del_20250827162926.py +0 -10
  57. neverlib/.history/Docs/audio_aug_test/del_20250827163030.py +0 -10
  58. neverlib/.history/Docs/audio_aug_test/del_20250827163032.py +0 -10
  59. neverlib/.history/Docs/vad/1_20250810032405.py +0 -0
  60. neverlib/.history/Docs/vad/1_20250810032417.py +0 -39
  61. neverlib/.history/QA/html2markdown_20250822234112.md +0 -0
  62. neverlib/.history/QA/html2markdown_20250822234140.py +0 -9
  63. neverlib/.history/QA/html2markdown_20250822234141.md +0 -9
  64. neverlib/.history/QA/html2markdown_20250822234159.py +0 -12
  65. neverlib/.history/QA/html2markdown_20250822234200.py +0 -17
  66. neverlib/.history/QA/html2markdown_20250822234236.py +0 -17
  67. neverlib/.history/QA/html2markdown_20250822234340.py +0 -14
  68. neverlib/.history/QA/html2markdown_20250822234522.py +0 -18
  69. neverlib/.history/QA/html2markdown_20250822234601.py +0 -20
  70. neverlib/.history/QA/html2markdown_20250822234615.py +0 -22
  71. neverlib/.history/QA/html2markdown_20250822234715.py +0 -28
  72. neverlib/.history/QA/html2markdown_20250822234720.py +0 -27
  73. neverlib/.history/QA/html2markdown_20250822234903.py +0 -27
  74. neverlib/.history/__init___20250805234212.py +0 -41
  75. neverlib/.history/__init___20250904102635.py +0 -39
  76. neverlib/.history/__init___20250904102836.py +0 -34
  77. neverlib/.history/__init___20250904102838.py +0 -39
  78. neverlib/.history/__init___20250904102851.py +0 -33
  79. neverlib/.history/audio_aug/audio_aug_20250806010451.py +0 -125
  80. neverlib/.history/audio_aug/audio_aug_20250806010750.py +0 -138
  81. neverlib/.history/audio_aug/audio_aug_20250806010759.py +0 -140
  82. neverlib/.history/audio_aug/audio_aug_20250806010803.py +0 -140
  83. neverlib/.history/audio_aug/audio_aug_20250806010809.py +0 -140
  84. neverlib/.history/audio_aug/audio_aug_20250806011108.py +0 -140
  85. neverlib/.history/audio_aug/audio_aug_20250826155913.py +0 -158
  86. neverlib/.history/audio_aug/audio_aug_20250826164159.py +0 -159
  87. neverlib/.history/audio_aug/audio_aug_20250826164217.py +0 -160
  88. neverlib/.history/audio_aug/audio_aug_20250826164408.py +0 -161
  89. neverlib/.history/audio_aug/audio_aug_20250826164423.py +0 -161
  90. neverlib/.history/audio_aug/audio_aug_20250826164529.py +0 -161
  91. neverlib/.history/audio_aug/audio_aug_20250826164824.py +0 -161
  92. neverlib/.history/audio_aug/audio_aug_20250826164932.py +0 -162
  93. neverlib/.history/audio_aug/audio_aug_20250826164947.py +0 -162
  94. neverlib/.history/audio_aug/audio_aug_20250826165403.py +0 -162
  95. neverlib/.history/audio_aug/audio_aug_20250826165421.py +0 -162
  96. neverlib/.history/audio_aug/audio_aug_20250826165509.py +0 -163
  97. neverlib/.history/audio_aug/audio_aug_20250826165702.py +0 -163
  98. neverlib/.history/audio_aug/audio_aug_20250826165732.py +0 -165
  99. neverlib/.history/audio_aug/audio_aug_20250826170041.py +0 -163
  100. neverlib/.history/audio_aug/audio_aug_20250826170105.py +0 -164
  101. neverlib/.history/audio_aug/audio_aug_20250826170154.py +0 -164
  102. neverlib/.history/audio_aug/audio_aug_20250826170220.py +0 -165
  103. neverlib/.history/audio_aug/audio_aug_20250826170221.py +0 -165
  104. neverlib/.history/audio_aug/audio_aug_20250826170228.py +0 -165
  105. neverlib/.history/audio_aug/audio_aug_20250826170231.py +0 -165
  106. neverlib/.history/audio_aug/audio_aug_20250826212001.py +0 -165
  107. neverlib/.history/audio_aug/audio_aug_20250826220038.py +0 -165
  108. neverlib/.history/audio_aug/audio_aug_20250826220133.py +0 -165
  109. neverlib/.history/audio_aug/audio_aug_20250826220148.py +0 -165
  110. neverlib/.history/audio_aug/audio_aug_20250826220154.py +0 -165
  111. neverlib/.history/audio_aug/audio_aug_20250826220156.py +0 -165
  112. neverlib/.history/audio_aug/audio_aug_20250826220314.py +0 -165
  113. neverlib/.history/audio_aug/audio_aug_20250826220343.py +0 -184
  114. neverlib/.history/audio_aug/audio_aug_20250826220345.py +0 -184
  115. neverlib/.history/audio_aug/audio_aug_20250826220349.py +0 -184
  116. neverlib/.history/audio_aug/audio_aug_20250826220429.py +0 -184
  117. neverlib/.history/audio_aug/audio_aug_20250826220447.py +0 -184
  118. neverlib/.history/audio_aug/audio_aug_20250826220601.py +0 -186
  119. neverlib/.history/audio_aug/audio_aug_20250826220638.py +0 -186
  120. neverlib/.history/audio_aug/audio_aug_20250826220641.py +0 -186
  121. neverlib/.history/audio_aug/audio_aug_20250826220647.py +0 -186
  122. neverlib/.history/audio_aug/audio_aug_20250826220653.py +0 -186
  123. neverlib/.history/audio_aug/audio_aug_20250826220655.py +0 -186
  124. neverlib/.history/audio_aug/audio_aug_20250826220731.py +0 -185
  125. neverlib/.history/audio_aug/audio_aug_20250826220739.py +0 -185
  126. neverlib/.history/audio_aug/audio_aug_20250826220747.py +0 -185
  127. neverlib/.history/audio_aug/audio_aug_20250826220801.py +0 -186
  128. neverlib/.history/audio_aug/audio_aug_20250826220822.py +0 -186
  129. neverlib/.history/audio_aug/audio_aug_20250826220901.py +0 -186
  130. neverlib/.history/audio_aug/audio_aug_20250826221107.py +0 -187
  131. neverlib/.history/audio_aug/audio_aug_20250826221310.py +0 -188
  132. neverlib/.history/audio_aug/audio_aug_20250826221353.py +0 -191
  133. neverlib/.history/audio_aug/audio_aug_20250826221821.py +0 -191
  134. neverlib/.history/audio_aug/audio_aug_20250826221838.py +0 -191
  135. neverlib/.history/audio_aug/audio_aug_20250826221906.py +0 -191
  136. neverlib/.history/audio_aug/audio_aug_20250826221930.py +0 -191
  137. neverlib/.history/audio_aug/audio_aug_20250826221939.py +0 -191
  138. neverlib/.history/audio_aug/audio_aug_20250826221955.py +0 -191
  139. neverlib/.history/audio_aug/audio_aug_20250826222008.py +0 -197
  140. neverlib/.history/audio_aug/audio_aug_20250826222017.py +0 -200
  141. neverlib/.history/audio_aug/audio_aug_20250826222046.py +0 -203
  142. neverlib/.history/audio_aug/audio_aug_20250826222105.py +0 -203
  143. neverlib/.history/audio_aug/audio_aug_20250826222206.py +0 -203
  144. neverlib/.history/audio_aug/audio_aug_20250826222302.py +0 -203
  145. neverlib/.history/audio_aug/audio_aug_20250826222336.py +0 -203
  146. neverlib/.history/audio_aug/audio_aug_20250826222455.py +0 -204
  147. neverlib/.history/audio_aug/audio_aug_20250826222526.py +0 -204
  148. neverlib/.history/audio_aug/audio_aug_20250826222541.py +0 -204
  149. neverlib/.history/audio_aug/audio_aug_20250826222624.py +0 -202
  150. neverlib/.history/audio_aug/audio_aug_20250826222714.py +0 -205
  151. neverlib/.history/audio_aug/audio_aug_20250826222820.py +0 -205
  152. neverlib/.history/audio_aug/audio_aug_20250826222827.py +0 -205
  153. neverlib/.history/audio_aug/audio_aug_20250826222927.py +0 -232
  154. neverlib/.history/audio_aug/audio_aug_20250826223009.py +0 -232
  155. neverlib/.history/audio_aug/audio_aug_20250826223054.py +0 -232
  156. neverlib/.history/audio_aug/audio_aug_20250826223225.py +0 -233
  157. neverlib/.history/audio_aug/audio_aug_20250826223344.py +0 -236
  158. neverlib/.history/audio_aug/audio_aug_20250826223356.py +0 -236
  159. neverlib/.history/audio_aug/audio_aug_20250826223955.py +0 -242
  160. neverlib/.history/audio_aug/audio_aug_20250826224210.py +0 -240
  161. neverlib/.history/audio_aug/audio_aug_20250826224250.py +0 -242
  162. neverlib/.history/audio_aug/audio_aug_20250826224323.py +0 -280
  163. neverlib/.history/audio_aug/audio_aug_20250826224452.py +0 -263
  164. neverlib/.history/audio_aug/audio_aug_20250826224455.py +0 -263
  165. neverlib/.history/audio_aug/audio_aug_20250826224502.py +0 -263
  166. neverlib/.history/audio_aug/audio_aug_20250826224528.py +0 -263
  167. neverlib/.history/audio_aug/audio_aug_20250826224658.py +0 -263
  168. neverlib/.history/audio_aug/audio_aug_20250826224833.py +0 -264
  169. neverlib/.history/audio_aug/audio_aug_20250826225013.py +0 -269
  170. neverlib/.history/audio_aug/audio_aug_20250826225050.py +0 -269
  171. neverlib/.history/audio_aug/audio_aug_20250826225241.py +0 -268
  172. neverlib/.history/audio_aug/audio_aug_20250826225315.py +0 -266
  173. neverlib/.history/audio_aug/audio_aug_20250826225404.py +0 -266
  174. neverlib/.history/audio_aug/audio_aug_20250826225502.py +0 -265
  175. neverlib/.history/audio_aug/audio_aug_20250826225950.py +0 -267
  176. neverlib/.history/audio_aug/audio_aug_20250826225959.py +0 -268
  177. neverlib/.history/audio_aug/audio_aug_20250826230222.py +0 -271
  178. neverlib/.history/audio_aug/audio_aug_20250826230248.py +0 -270
  179. neverlib/.history/audio_aug/audio_aug_20250826230638.py +0 -266
  180. neverlib/.history/audio_aug/audio_aug_20250826230755.py +0 -266
  181. neverlib/.history/audio_aug/audio_aug_20250826230941.py +0 -265
  182. neverlib/.history/audio_aug/audio_aug_20250826231054.py +0 -266
  183. neverlib/.history/audio_aug/audio_aug_20250826231117.py +0 -266
  184. neverlib/.history/audio_aug/audio_aug_20250826231219.py +0 -266
  185. neverlib/.history/audio_aug/audio_aug_20250826232330.py +0 -266
  186. neverlib/.history/audio_aug/audio_aug_20250826232352.py +0 -266
  187. neverlib/.history/audio_aug/audio_aug_20250827152748.py +0 -268
  188. neverlib/.history/audio_aug/audio_aug_20250827152806.py +0 -268
  189. neverlib/.history/audio_aug/audio_aug_20250827152808.py +0 -268
  190. neverlib/.history/audio_aug/audio_aug_20250827152917.py +0 -283
  191. neverlib/.history/audio_aug/audio_aug_20250827152929.py +0 -281
  192. neverlib/.history/audio_aug/audio_aug_20250827153100.py +0 -286
  193. neverlib/.history/audio_aug/audio_aug_20250827153102.py +0 -286
  194. neverlib/.history/audio_aug/audio_aug_20250827153301.py +0 -295
  195. neverlib/.history/audio_aug/audio_aug_20250827153331.py +0 -298
  196. neverlib/.history/audio_aug/audio_aug_20250827153525.py +0 -303
  197. neverlib/.history/audio_aug/audio_aug_20250827153533.py +0 -304
  198. neverlib/.history/audio_aug/audio_aug_20250827153541.py +0 -321
  199. neverlib/.history/audio_aug/audio_aug_20250827153805.py +0 -322
  200. neverlib/.history/audio_aug/audio_aug_20250827153832.py +0 -323
  201. neverlib/.history/audio_aug/audio_aug_20250827153836.py +0 -324
  202. neverlib/.history/audio_aug/audio_aug_20250827153846.py +0 -324
  203. neverlib/.history/audio_aug/audio_aug_20250827153859.py +0 -325
  204. neverlib/.history/audio_aug/audio_aug_20250827154453.py +0 -337
  205. neverlib/.history/audio_aug/audio_aug_20250827154513.py +0 -355
  206. neverlib/.history/audio_aug/audio_aug_20250827154538.py +0 -356
  207. neverlib/.history/audio_aug/audio_aug_20250827154541.py +0 -357
  208. neverlib/.history/audio_aug/audio_aug_20250827154612.py +0 -357
  209. neverlib/.history/audio_aug/audio_aug_20250827154657.py +0 -360
  210. neverlib/.history/audio_aug/audio_aug_20250827154708.py +0 -360
  211. neverlib/.history/audio_aug/audio_aug_20250827154728.py +0 -366
  212. neverlib/.history/audio_aug/audio_aug_20250827154755.py +0 -367
  213. neverlib/.history/audio_aug/audio_aug_20250827154800.py +0 -367
  214. neverlib/.history/audio_aug/audio_aug_20250827154917.py +0 -368
  215. neverlib/.history/audio_aug/audio_aug_20250827154928.py +0 -369
  216. neverlib/.history/audio_aug/audio_aug_20250827154932.py +0 -370
  217. neverlib/.history/audio_aug/audio_aug_20250827154947.py +0 -372
  218. neverlib/.history/audio_aug/audio_aug_20250827155015.py +0 -375
  219. neverlib/.history/audio_aug/audio_aug_20250827155106.py +0 -375
  220. neverlib/.history/audio_aug/audio_aug_20250827155114.py +0 -393
  221. neverlib/.history/audio_aug/audio_aug_20250827155207.py +0 -415
  222. neverlib/.history/audio_aug/audio_aug_20250827155300.py +0 -415
  223. neverlib/.history/audio_aug/audio_aug_20250827155321.py +0 -471
  224. neverlib/.history/audio_aug/audio_aug_20250827164703.py +0 -471
  225. neverlib/.history/audio_aug/audio_aug_20250827164749.py +0 -471
  226. neverlib/.history/audio_aug/audio_aug_20250827165252.py +0 -472
  227. neverlib/.history/audio_aug/audio_aug_20250827165334.py +0 -472
  228. neverlib/.history/audio_aug/audio_aug_20250827165404.py +0 -473
  229. neverlib/.history/audio_aug/audio_aug_20250827165610.py +0 -473
  230. neverlib/.history/audio_aug/audio_aug_20250827165805.py +0 -473
  231. neverlib/.history/audio_aug/audio_aug_20250827170056.py +0 -473
  232. neverlib/.history/audio_aug/audio_aug_20250827170106.py +0 -472
  233. neverlib/.history/audio_aug/audio_aug_20250827170143.py +0 -472
  234. neverlib/.history/audio_aug/audio_aug_20250827170216.py +0 -472
  235. neverlib/.history/audio_aug/audio_aug_20250827170218.py +0 -472
  236. neverlib/.history/audio_aug/audio_aug_20250827170314.py +0 -472
  237. neverlib/.history/audio_aug/audio_aug_20250827171500.py +0 -471
  238. neverlib/.history/audio_aug/audio_aug_20250827172347.py +0 -471
  239. neverlib/.history/audio_aug/audio_aug_20250827172558.py +0 -470
  240. neverlib/.history/audio_aug/audio_aug_20250827172559.py +0 -470
  241. neverlib/.history/audio_aug/audio_aug_20250827172801.py +0 -470
  242. neverlib/.history/audio_aug/audio_aug_20250827182522.py +0 -470
  243. neverlib/.history/audio_aug/audio_aug_20250827182526.py +0 -470
  244. neverlib/.history/audio_aug/audio_aug_20250827182626.py +0 -470
  245. neverlib/.history/audio_aug/audio_aug_20250827182715.py +0 -470
  246. neverlib/.history/audio_aug/audio_aug_20250904185444.py +0 -470
  247. neverlib/.history/audio_aug/audio_aug_20250904185538.py +0 -445
  248. neverlib/.history/dataAnalyze/__init___20250805234204.py +0 -87
  249. neverlib/.history/dataAnalyze/__init___20250806204125.py +0 -14
  250. neverlib/.history/dataAnalyze/__init___20250806204139.py +0 -14
  251. neverlib/.history/dataAnalyze/__init___20250806204159.py +0 -14
  252. neverlib/.history/data_analyze/__init___20250806204158.py +0 -14
  253. neverlib/.history/data_analyze/__init___20250827163248.py +0 -14
  254. neverlib/.history/filter/__init___20250820103351.py +0 -70
  255. neverlib/.history/filter/__init___20250821102348.py +0 -70
  256. neverlib/.history/filter/__init___20250821102405.py +0 -14
  257. neverlib/.history/filter/auto_eq/__init___20250819213121.py +0 -36
  258. neverlib/.history/filter/auto_eq/__init___20250821102241.py +0 -36
  259. neverlib/.history/filter/auto_eq/__init___20250821102259.py +0 -36
  260. neverlib/.history/filter/auto_eq/__init___20250821102307.py +0 -36
  261. neverlib/.history/filter/auto_eq/__init___20250821102310.py +0 -36
  262. neverlib/.history/filter/auto_eq/__init___20250821102318.py +0 -36
  263. neverlib/.history/filter/auto_eq/__init___20250821102507.py +0 -36
  264. neverlib/.history/filter/auto_eq/de_eq_20250820103848.py +0 -361
  265. neverlib/.history/filter/auto_eq/de_eq_20250821102422.py +0 -360
  266. neverlib/.history/filter/auto_eq/freq_eq_20250805234206.py +0 -75
  267. neverlib/.history/filter/auto_eq/freq_eq_20250820140732.py +0 -75
  268. neverlib/.history/filter/auto_eq/freq_eq_20250820140745.py +0 -75
  269. neverlib/.history/filter/auto_eq/freq_eq_20250820140816.py +0 -75
  270. neverlib/.history/filter/auto_eq/freq_eq_20250820140938.py +0 -77
  271. neverlib/.history/filter/auto_eq/freq_eq_20250820141003.py +0 -77
  272. neverlib/.history/filter/auto_eq/freq_eq_20250820141006.py +0 -77
  273. neverlib/.history/filter/auto_eq/freq_eq_20250820141019.py +0 -77
  274. neverlib/.history/filter/auto_eq/freq_eq_20250820141049.py +0 -77
  275. neverlib/.history/filter/auto_eq/freq_eq_20250820141211.py +0 -77
  276. neverlib/.history/filter/auto_eq/freq_eq_20250820141227.py +0 -77
  277. neverlib/.history/filter/auto_eq/freq_eq_20250820141311.py +0 -78
  278. neverlib/.history/filter/auto_eq/freq_eq_20250820141340.py +0 -78
  279. neverlib/.history/filter/auto_eq/freq_eq_20250820141712.py +0 -78
  280. neverlib/.history/filter/auto_eq/freq_eq_20250820141733.py +0 -78
  281. neverlib/.history/filter/auto_eq/freq_eq_20250820141755.py +0 -78
  282. neverlib/.history/filter/auto_eq/freq_eq_20250821102434.py +0 -76
  283. neverlib/.history/filter/auto_eq/freq_eq_20250821102500.py +0 -76
  284. neverlib/.history/filter/auto_eq/freq_eq_20250821102502.py +0 -76
  285. neverlib/.history/filter/auto_eq/freq_eq_20250821143140.py +0 -76
  286. neverlib/.history/filter/auto_eq/freq_eq_20250821153208.py +0 -76
  287. neverlib/.history/filter/auto_eq/freq_eq_20250821153214.py +0 -76
  288. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820102957.py +0 -380
  289. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113054.py +0 -380
  290. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113150.py +0 -380
  291. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113520.py +0 -385
  292. neverlib/.history/filter/auto_eq/ga_eq_basic_20250820113525.py +0 -385
  293. neverlib/.history/filter/auto_eq/ga_eq_basic_20250821102212.py +0 -385
  294. neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110521.py +0 -385
  295. neverlib/.history/filter/auto_eq/ga_eq_basic_20250901110652.py +0 -385
  296. neverlib/.history/filter/common_20250806002134.py +0 -37
  297. neverlib/.history/filter/common_20250821120448.py +0 -49
  298. neverlib/.history/filter/common_20250821120453.py +0 -49
  299. neverlib/.history/metrics/dnsmos_20250806001612.py +0 -160
  300. neverlib/.history/metrics/dnsmos_20250815180659.py +0 -160
  301. neverlib/.history/metrics/dnsmos_20250815180701.py +0 -158
  302. neverlib/.history/metrics/dnsmos_20250815181321.py +0 -154
  303. neverlib/.history/metrics/dnsmos_20250815181327.py +0 -154
  304. neverlib/.history/metrics/dnsmos_20250815181331.py +0 -154
  305. neverlib/.history/metrics/dnsmos_20250815181620.py +0 -154
  306. neverlib/.history/metrics/dnsmos_20250815181631.py +0 -154
  307. neverlib/.history/metrics/dnsmos_20250815181742.py +0 -154
  308. neverlib/.history/metrics/dnsmos_20250815181824.py +0 -153
  309. neverlib/.history/metrics/dnsmos_20250815181834.py +0 -153
  310. neverlib/.history/metrics/dnsmos_20250815181922.py +0 -153
  311. neverlib/.history/metrics/dnsmos_20250815182011.py +0 -147
  312. neverlib/.history/metrics/dnsmos_20250815182036.py +0 -144
  313. neverlib/.history/metrics/dnsmos_20250815182936.py +0 -143
  314. neverlib/.history/metrics/dnsmos_20250815182942.py +0 -143
  315. neverlib/.history/metrics/dnsmos_20250815183032.py +0 -137
  316. neverlib/.history/metrics/dnsmos_20250815183101.py +0 -144
  317. neverlib/.history/metrics/dnsmos_20250815183121.py +0 -144
  318. neverlib/.history/metrics/dnsmos_20250815183123.py +0 -143
  319. neverlib/.history/metrics/dnsmos_20250815183214.py +0 -143
  320. neverlib/.history/metrics/dnsmos_20250815183240.py +0 -143
  321. neverlib/.history/metrics/dnsmos_20250815183248.py +0 -144
  322. neverlib/.history/metrics/dnsmos_20250815183407.py +0 -142
  323. neverlib/.history/metrics/dnsmos_20250815183409.py +0 -142
  324. neverlib/.history/metrics/dnsmos_20250815183431.py +0 -142
  325. neverlib/.history/metrics/dnsmos_20250815183507.py +0 -140
  326. neverlib/.history/metrics/dnsmos_20250815183513.py +0 -139
  327. neverlib/.history/metrics/dnsmos_20250815183618.py +0 -139
  328. neverlib/.history/metrics/dnsmos_20250815183709.py +0 -140
  329. neverlib/.history/metrics/dnsmos_20250815183756.py +0 -137
  330. neverlib/.history/metrics/dnsmos_20250815183815.py +0 -128
  331. neverlib/.history/metrics/dnsmos_20250815183827.py +0 -129
  332. neverlib/.history/metrics/dnsmos_20250815183913.py +0 -117
  333. neverlib/.history/metrics/dnsmos_20250815183914.py +0 -117
  334. neverlib/.history/metrics/dnsmos_20250815184003.py +0 -118
  335. neverlib/.history/metrics/dnsmos_20250815184040.py +0 -118
  336. neverlib/.history/metrics/dnsmos_20250815184049.py +0 -118
  337. neverlib/.history/metrics/dnsmos_20250815184104.py +0 -117
  338. neverlib/.history/metrics/dnsmos_20250815184200.py +0 -117
  339. neverlib/.history/metrics/lpc_lsp_metric_20250816015944.py +0 -128
  340. neverlib/.history/metrics/lpc_lsp_metric_20250816020142.py +0 -128
  341. neverlib/.history/metrics/lpc_lsp_metric_20250816020156.py +0 -128
  342. neverlib/.history/metrics/lpc_lsp_metric_20250816020554.py +0 -130
  343. neverlib/.history/metrics/lpc_lsp_metric_20250816020600.py +0 -125
  344. neverlib/.history/metrics/lpc_lsp_metric_20250816020631.py +0 -120
  345. neverlib/.history/metrics/lpc_lsp_metric_20250816020746.py +0 -118
  346. neverlib/.history/metrics/lpc_me_20250816013111.py +0 -0
  347. neverlib/.history/metrics/lpc_me_20250816013129.py +0 -121
  348. neverlib/.history/metrics/lpc_me_20250816015430.py +0 -103
  349. neverlib/.history/metrics/lpc_me_20250816015535.py +0 -96
  350. neverlib/.history/metrics/lpc_me_20250816015542.py +0 -96
  351. neverlib/.history/metrics/lpc_me_20250816015636.py +0 -97
  352. neverlib/.history/metrics/lpc_me_20250816015658.py +0 -104
  353. neverlib/.history/metrics/lpc_me_20250816015703.py +0 -100
  354. neverlib/.history/metrics/lpc_me_20250816015945.py +0 -128
  355. neverlib/.history/metrics/snr_20250806010538.py +0 -177
  356. neverlib/.history/metrics/snr_20250806211634.py +0 -184
  357. neverlib/.history/metrics/snr_20250827224201.py +0 -182
  358. neverlib/.history/metrics/snr_20250827234019.py +0 -186
  359. neverlib/.history/metrics/snr_20250827234028.py +0 -186
  360. neverlib/.history/metrics/snr_20250827234030.py +0 -186
  361. neverlib/.history/metrics/spec_20250805234209.py +0 -45
  362. neverlib/.history/metrics/spec_20250816135530.py +0 -11
  363. neverlib/.history/metrics/spec_20250816135654.py +0 -16
  364. neverlib/.history/metrics/spec_20250816135736.py +0 -68
  365. neverlib/.history/metrics/spec_20250816135904.py +0 -75
  366. neverlib/.history/metrics/spec_20250816135921.py +0 -82
  367. neverlib/.history/metrics/spec_20250816140111.py +0 -82
  368. neverlib/.history/metrics/spec_20250816140543.py +0 -136
  369. neverlib/.history/metrics/spec_20250816140559.py +0 -172
  370. neverlib/.history/metrics/spec_20250816140602.py +0 -172
  371. neverlib/.history/metrics/spec_20250816140608.py +0 -172
  372. neverlib/.history/metrics/spec_20250816140654.py +0 -148
  373. neverlib/.history/metrics/spec_20250816140705.py +0 -144
  374. neverlib/.history/metrics/spec_20250816140755.py +0 -138
  375. neverlib/.history/metrics/spec_20250816140823.py +0 -170
  376. neverlib/.history/metrics/spec_20250816140832.py +0 -170
  377. neverlib/.history/metrics/spec_20250816140833.py +0 -170
  378. neverlib/.history/metrics/spec_20250816140922.py +0 -147
  379. neverlib/.history/metrics/spec_20250816141148.py +0 -107
  380. neverlib/.history/metrics/spec_20250816141219.py +0 -123
  381. neverlib/.history/metrics/spec_20250816141732.py +0 -178
  382. neverlib/.history/metrics/spec_20250816141740.py +0 -178
  383. neverlib/.history/metrics/spec_20250816142030.py +0 -178
  384. neverlib/.history/metrics/spec_20250816142107.py +0 -135
  385. neverlib/.history/metrics/spec_20250816142126.py +0 -135
  386. neverlib/.history/metrics/spec_20250816142410.py +0 -135
  387. neverlib/.history/metrics/spec_20250816142415.py +0 -136
  388. neverlib/.history/metrics/spec_metric_20250816135156.py +0 -0
  389. neverlib/.history/metrics/spec_metric_20250816135226.py +0 -5
  390. neverlib/.history/metrics/spec_metric_20250816135227.py +0 -10
  391. neverlib/.history/metrics/spec_metric_20250816135306.py +0 -15
  392. neverlib/.history/metrics/spec_metric_20250816135442.py +0 -31
  393. neverlib/.history/metrics/spec_metric_20250816135448.py +0 -31
  394. neverlib/.history/metrics/spec_metric_20250816135520.py +0 -29
  395. neverlib/.history/metrics/spec_metric_20250816135537.py +0 -63
  396. neverlib/.history/metrics/spec_metric_20250816135653.py +0 -65
  397. neverlib/.history/utils/audio_split_20250805234209.py +0 -268
  398. neverlib/.history/utils/audio_split_20250904185309.py +0 -268
  399. neverlib/.history/utils/utils_20250813165516.py +0 -330
  400. neverlib/.history/utils/utils_20250904181341.py +0 -328
  401. neverlib/.history/utils/utils_20250904185546.py +0 -352
  402. neverlib/.history/utils/utils_20250904185548.py +0 -353
  403. neverlib/.history/utils/utils_20250904185603.py +0 -353
  404. neverlib/.history/utils/utils_20250904185636.py +0 -353
  405. neverlib/.history/utils/utils_20250904185658.py +0 -358
  406. neverlib/.history/utils/utils_20250904190053.py +0 -359
  407. neverlib/.history/vad/PreProcess_20250805234211.py +0 -63
  408. neverlib/.history/vad/PreProcess_20250809232455.py +0 -63
  409. neverlib/.history/vad/PreProcess_20250816020725.py +0 -66
  410. neverlib/.history/vad/VAD_Silero_20250805234211.py +0 -50
  411. neverlib/.history/vad/VAD_Silero_20250809232456.py +0 -50
  412. neverlib/.history/vad/VAD_WebRTC_20250805234211.py +0 -61
  413. neverlib/.history/vad/VAD_WebRTC_20250809232456.py +0 -61
  414. neverlib/.history/vad/VAD_funasr_20250805234211.py +0 -54
  415. neverlib/.history/vad/VAD_funasr_20250809232456.py +0 -54
  416. neverlib/.history/vad/VAD_vadlib_20250805234211.py +0 -70
  417. neverlib/.history/vad/VAD_vadlib_20250809232455.py +0 -70
  418. neverlib/.history/vad/VAD_whisper_20250805234211.py +0 -55
  419. neverlib/.history/vad/VAD_whisper_20250809232456.py +0 -55
  420. neverlib/.specstory/.what-is-this.md +0 -69
  421. 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
  422. 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
  423. neverlib/.specstory/history/2025-08-26_11-54Z-oserror-missing-shared-object-file.md +0 -87
  424. 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
  425. neverlib/.specstory/history/2025-08-27_08-29Z-delete-python-file-command.md +0 -211
  426. 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
  427. neverlib-0.2.7.dist-info/RECORD +0 -510
  428. {neverlib-0.2.7.dist-info → neverlib-0.2.9.dist-info}/WHEEL +0 -0
  429. {neverlib-0.2.7.dist-info → neverlib-0.2.9.dist-info}/licenses/LICENSE +0 -0
  430. {neverlib-0.2.7.dist-info → neverlib-0.2.9.dist-info}/top_level.txt +0 -0
@@ -1,186 +0,0 @@
1
- import librosa
2
- import numpy as np
3
- from neverlib.vad.utils import vad2nad
4
- from neverlib.filter import HPFilter
5
-
6
-
7
- def get_snr(speech, noise, hpf=False, sr=16000, order=6, cutoff=100):
8
- """计算信噪比
9
- Args:
10
- speech: 语音音频
11
- noise: 噪声音频
12
- Returns:
13
- snr: 信噪比
14
- """
15
- assert speech.ndim == noise.ndim, "speech和noise的维度不一样"
16
- if hpf:
17
- speech = HPFilter(speech, sr=sr, order=order, cutoff=cutoff)
18
- noise = HPFilter(noise, sr=sr, order=order, cutoff=cutoff)
19
-
20
- power_speech = np.mean(speech**2)
21
- power_noise = max(np.mean(noise**2), 1e-10)
22
-
23
- snr = 10 * np.log10(power_speech / power_noise)
24
- return snr
25
-
26
-
27
- def get_snr_from_noisy(noisy, speech_vad=None):
28
- """根据带噪音频计算信噪比
29
- Args:
30
- noisy: 带噪音频
31
- speech_vad: [{start:xxx, end:xxx}, ...]
32
- Returns:
33
- snr: 信噪比
34
- """
35
- assert speech_vad is not None, "speech_vad不能为空"
36
-
37
- # 提取语音段
38
- speech_segments = []
39
- for segment in speech_vad:
40
- start = segment['start']
41
- end = segment['end']
42
- speech_segments.append(noisy[start:end])
43
- speech = np.concatenate(speech_segments, axis=0)
44
-
45
- # 提取非语音段
46
- noise_segments = []
47
- noise_point_list = vad2nad(speech_vad, len(noisy))
48
- for noise_point in noise_point_list:
49
- noise_segments.append(noisy[noise_point['start']:noise_point['end']])
50
- noise = np.concatenate(noise_segments, axis=0)
51
-
52
- P_speech_noise = np.mean(speech ** 2) # 语音+噪声功率
53
- P_noise = max(np.mean(noise ** 2), EPS) # 纯噪声功率
54
-
55
- # 计算净语音功率
56
- P_speech = max(P_speech_noise - P_noise, EPS)
57
- snr = 10 * np.log10(P_speech / P_noise)
58
-
59
- return snr
60
-
61
-
62
- def seg_snr(clean, noisy, frame_length: int, hop_length: int):
63
- """
64
- 分帧计算信噪比
65
- Args:
66
- clean: 干净音频, numpy array
67
- noisy: 带噪音频, numpy array
68
- frame_length: 帧长
69
- hop_length: 帧移
70
- Returns:
71
- snr_mean: 平均信噪比, float
72
- Raises:
73
- ValueError: 当输入参数不合法时抛出
74
- """
75
- assert clean.shape == noisy.shape, "clean和noisy的维度不一样"
76
-
77
- # 分帧
78
- clean_frames = librosa.util.frame(clean, frame_length=frame_length, hop_length=hop_length) # (frame_length, n_frames)
79
- noisy_frames = librosa.util.frame(noisy, frame_length=frame_length, hop_length=hop_length) # (frame_length, n_frames)
80
-
81
- # 计算每帧的信噪比
82
- snr_frames = []
83
- for i in range(clean_frames.shape[1]):
84
- clean_frame = clean_frames[:, i]
85
- noisy_frame = noisy_frames[:, i]
86
- # 跳过静音帧
87
- if np.all(np.abs(clean_frame) < 1e-6) or np.all(np.abs(noisy_frame) < 1e-6):
88
- continue
89
- snr_frames.append(get_snr(clean_frame, noisy_frame))
90
-
91
- # 如果所有帧都是静音
92
- if not snr_frames:
93
- return float('-inf')
94
-
95
- return np.mean(snr_frames)
96
-
97
-
98
- def psnr(clean, noisy, max_val=None):
99
- """
100
- 计算峰值信噪比
101
- Args:
102
- clean: 干净音频, numpy array
103
- noisy: 带噪音频, numpy array
104
- max_val: 信号最大值, 如果为None则使用clean信号的实际最大值
105
- Returns:
106
- psnr: 峰值信噪比, 单位dB
107
- """
108
- assert clean.shape == noisy.shape, "clean和noisy的维度不一样"
109
-
110
- # 如果没有指定最大值, 使用clean信号的实际最大值
111
- if max_val is None:
112
- max_val = np.abs(clean).max()
113
-
114
- # 计算均方误差 (MSE)
115
- mse = np.mean((clean - noisy) ** 2)
116
-
117
- # 避免除以0
118
- if mse == 0:
119
- return float('inf')
120
-
121
- # 计算PSNR
122
- psnr = 10 * np.log10(max_val**2 / mse)
123
- return psnr
124
-
125
-
126
- def si_sdr(reference, estimate, epsilon=1e-8):
127
- """
128
- 计算尺度不变信噪比 (Scale-Invariant Signal-to-Distortion Ratio, SI-SDR)。
129
-
130
- Args:
131
- reference (np.ndarray): 原始的、干净的参考信号 (一维数组)。
132
- estimate (np.ndarray): 模型估计或处理后的信号 (一维数组)。
133
- epsilon (float): 一个非常小的数值, 用于防止分母为零, 保证数值稳定性。
134
-
135
- Returns:
136
- float: SI-SDR 值, 单位为分贝 (dB)。
137
- """
138
- assert reference.shape == estimate.shape, "reference和estimate的维度不一样"
139
-
140
- # 2. 零均值化 (可选但推荐)
141
- # 移除直流分量, 使计算更关注信号的动态变化
142
- reference = reference - np.mean(reference)
143
- estimate = estimate - np.mean(estimate)
144
-
145
- # 3. 计算目标信号分量 (s_target)
146
- # s_target 是 estimate 在 reference 上的投影
147
- # 公式: s_target = (<ŝ, s> / ||s||²) * s
148
- dot_product = np.dot(estimate, reference) # <ŝ, s> (点积)
149
- norm_s_squared = np.dot(reference, reference) # ||s||² (s的能量)
150
-
151
- # 检查参考信号能量, 避免除以零
152
- if norm_s_squared < epsilon:
153
- # 如果参考信号几乎是静音, SI-SDR没有意义
154
- return -np.inf # 返回负无穷或np.nan
155
-
156
- alpha = dot_product / (norm_s_squared + epsilon) # 最佳缩放因子 α
157
- s_target = alpha * reference
158
-
159
- # 4. 计算误差/失真分量 (e_noise)
160
- e_noise = estimate - s_target
161
-
162
- # 5. 计算 SI-SDR
163
- # SI-SDR = 10 * log10 ( ||s_target||² / ||e_noise||² )
164
- power_s_target = np.sum(s_target**2) # ||s_target||²
165
- power_e_noise = np.sum(e_noise**2) # ||e_noise||²
166
-
167
- # 同样加上 epsilon 防止除以零
168
- if power_e_noise < epsilon:
169
- # 如果噪声能量极小, 说明匹配得非常好
170
- return np.inf # 返回正无穷
171
-
172
- si_sdr_val = 10 * np.log10(power_s_target / (power_e_noise + epsilon))
173
-
174
- return si_sdr_val
175
-
176
-
177
- if __name__ == "__main__":
178
- # 生成测试信号
179
- speech = np.random.randn(1000)
180
- noise = np.random.randn(1000) * 0.1 # 较小的噪声
181
- noisy = speech + noise
182
-
183
- # 测试各种信噪比计算方法
184
- print(f"SNR: {get_snr(speech, noise):.2f} dB")
185
- print(f"Segmental SNR: {seg_snr(speech, noisy, 100, 50):.2f} dB")
186
- print(f"PSNR: {psnr(speech, noisy):.2f} dB")
@@ -1,186 +0,0 @@
1
- import librosa
2
- import numpy as np
3
- from neverlib.vad.utils import vad2nad
4
- from neverlib.filter import HPFilter
5
-
6
-
7
- def get_snr(speech, noise, hpf=False, sr=16000, order=6, cutoff=100):
8
- """计算信噪比
9
- Args:
10
- speech: 语音音频
11
- noise: 噪声音频
12
- Returns:
13
- snr: 信噪比
14
- """
15
- assert speech.ndim == noise.ndim, "speech和noise的维度不一样"
16
- if hpf:
17
- speech = HPFilter(speech, sr=sr, order=order, cutoff=cutoff)
18
- noise = HPFilter(noise, sr=sr, order=order, cutoff=cutoff)
19
-
20
- power_speech = np.mean(speech**2)
21
- power_noise = max(np.mean(noise**2), 1e-10)
22
-
23
- snr = 10 * np.log10(power_speech / power_noise)
24
- return snr
25
-
26
-
27
- def get_snr_from_noisy(noisy, speech_vad=None):
28
- """根据带噪音频计算信噪比
29
- Args:
30
- noisy: 带噪音频
31
- speech_vad: [{start:xxx, end:xxx}, ...]
32
- Returns:
33
- snr: 信噪比
34
- """
35
- assert speech_vad is not None, "speech_vad不能为空"
36
-
37
- # 提取语音段
38
- speech_segments = []
39
- for segment in speech_vad:
40
- start = segment['start']
41
- end = segment['end']
42
- speech_segments.append(noisy[start:end])
43
- speech = np.concatenate(speech_segments, axis=0)
44
-
45
- # 提取非语音段
46
- noise_segments = []
47
- noise_point_list = vad2nad(speech_vad, len(noisy))
48
- for noise_point in noise_point_list:
49
- noise_segments.append(noisy[noise_point['start']:noise_point['end']])
50
- noise = np.concatenate(noise_segments, axis=0)
51
-
52
- P_speech_noise = np.mean(speech ** 2) # 语音+噪声功率
53
- P_noise = max(np.mean(noise ** 2), EPS) # 纯噪声功率
54
-
55
- # 计算净语音功率
56
- P_speech = max(P_speech_noise - P_noise, EPS)
57
- snr = 10 * np.log10(P_speech / P_noise)
58
-
59
- return snr
60
-
61
-
62
- def seg_snr(clean, noisy, frame_length: int, hop_length: int):
63
- """
64
- 分帧计算信噪比
65
- Args:
66
- clean: 干净音频, numpy array
67
- noisy: 带噪音频, numpy array
68
- frame_length: 帧长
69
- hop_length: 帧移
70
- Returns:
71
- snr_mean: 平均信噪比, float
72
- Raises:
73
- ValueError: 当输入参数不合法时抛出
74
- """
75
- assert clean.shape == noisy.shape, "clean和noisy的维度不一样"
76
-
77
- # 分帧
78
- clean_frames = librosa.util.frame(clean, frame_length=frame_length, hop_length=hop_length) # (frame_length, n_frames)
79
- noisy_frames = librosa.util.frame(noisy, frame_length=frame_length, hop_length=hop_length) # (frame_length, n_frames)
80
-
81
- # 计算每帧的信噪比
82
- snr_frames = []
83
- for i in range(clean_frames.shape[1]):
84
- clean_frame = clean_frames[:, i]
85
- noisy_frame = noisy_frames[:, i]
86
- # 跳过静音帧
87
- if np.all(np.abs(clean_frame) < 1e-6) or np.all(np.abs(noisy_frame) < 1e-6):
88
- continue
89
- snr_frames.append(get_snr(clean_frame, noisy_frame))
90
-
91
- # 如果所有帧都是静音
92
- if not snr_frames:
93
- return float('-inf')
94
-
95
- return np.mean(snr_frames)
96
-
97
-
98
- def psnr(clean, noisy, max_val=None):
99
- """
100
- 计算峰值信噪比
101
- Args:
102
- clean: 干净音频, numpy array
103
- noisy: 带噪音频, numpy array
104
- max_val: 信号最大值, 如果为None则使用clean信号的实际最大值
105
- Returns:
106
- psnr: 峰值信噪比, 单位dB
107
- """
108
- assert clean.shape == noisy.shape, "clean和noisy的维度不一样"
109
-
110
- # 如果没有指定最大值, 使用clean信号的实际最大值
111
- if max_val is None:
112
- max_val = np.abs(clean).max()
113
-
114
- # 计算均方误差 (MSE)
115
- mse = np.mean((clean - noisy) ** 2)
116
-
117
- # 避免除以0
118
- if mse == 0:
119
- return float('inf')
120
-
121
- # 计算PSNR
122
- psnr = 10 * np.log10(max_val**2 / mse)
123
- return psnr
124
-
125
-
126
- def si_sdr(reference, estimate, epsilon=1e-8):
127
- """
128
- 计算尺度不变信噪比 (Scale-Invariant Signal-to-Distortion Ratio, SI-SDR)。
129
-
130
- Args:
131
- reference (np.ndarray): 原始的、干净的参考信号 (一维数组)。
132
- estimate (np.ndarray): 模型估计或处理后的信号 (一维数组)。
133
- epsilon (float): 一个非常小的数值, 用于防止分母为零, 保证数值稳定性。
134
-
135
- Returns:
136
- float: SI-SDR 值, 单位为分贝 (dB)。
137
- """
138
- assert reference.shape == estimate.shape, "reference和estimate的维度不一样"
139
-
140
- # 2. 零均值化 (可选但推荐)
141
- # 移除直流分量, 使计算更关注信号的动态变化
142
- reference = reference - np.mean(reference)
143
- estimate = estimate - np.mean(estimate)
144
-
145
- # 3. 计算目标信号分量 (s_target)
146
- # s_target 是 estimate 在 reference 上的投影
147
- # 公式: s_target = (<ŝ, s> / ||s||²) * s
148
- dot_product = np.dot(estimate, reference) # <ŝ, s> (点积)
149
- norm_s_squared = np.dot(reference, reference) # ||s||² (s的能量)
150
-
151
- # 检查参考信号能量, 避免除以零
152
- if norm_s_squared < epsilon:
153
- # 如果参考信号几乎是静音, SI-SDR没有意义
154
- return -np.inf # 返回负无穷或np.nan
155
-
156
- alpha = dot_product / (norm_s_squared + epsilon) # 最佳缩放因子 α
157
- s_target = alpha * reference
158
-
159
- # 4. 计算误差/失真分量 (e_noise)
160
- e_noise = estimate - s_target
161
-
162
- # 5. 计算 SI-SDR
163
- # SI-SDR = 10 * log10 ( ||s_target||² / ||e_noise||² )
164
- power_s_target = np.sum(s_target**2) # ||s_target||²
165
- power_e_noise = np.sum(e_noise**2) # ||e_noise||²
166
-
167
- # 同样加上 epsilon 防止除以零
168
- if power_e_noise < epsilon:
169
- # 如果噪声能量极小, 说明匹配得非常好
170
- return np.inf # 返回正无穷
171
-
172
- si_sdr_val = 10 * np.log10(power_s_target / (power_e_noise + epsilon))
173
-
174
- return si_sdr_val
175
-
176
-
177
- if __name__ == "__main__":
178
- # 生成测试信号
179
- speech = np.random.randn(1000)
180
- noise = np.random.randn(1000) * 0.1 # 较小的噪声
181
- noisy = speech + noise
182
-
183
- # 测试各种信噪比计算方法
184
- print(f"SNR: {get_snr(speech, noise):.2f} dB")
185
- print(f"Segmental SNR: {seg_snr(speech, noisy, 100, 50):.2f} dB")
186
- print(f"PSNR: {psnr(speech, noisy):.2f} dB")
@@ -1,45 +0,0 @@
1
- """
2
- 频域的客观评价指标
3
- LSD: 对数谱距离
4
- """
5
- import sys
6
- sys.path.append("..")
7
- import numpy as np
8
- import librosa
9
- from utils import EPS
10
-
11
-
12
- def lsd(reference, estimate, n_fft=2048, hop_length=512, win_length=None):
13
- """
14
- 计算两个一维音频信号之间的对数谱距离 (Log-Spectral Distance, LSD)。
15
- 该实现遵循标准的LSD定义: 整体均方根误差。
16
-
17
- Args:
18
- reference (np.ndarray): 原始的、干净的参考信号 (一维数组)。
19
- estimate (np.ndarray): 模型估计或处理后的信号 (一维数组)。
20
- n_fft (int): FFT点数, 决定了频率分辨率。
21
- hop_length (int): 帧移, 决定了时间分辨率。
22
- win_length (int, optional): 窗长。如果为None, 则默认为n_fft。
23
- epsilon (float): 一个非常小的数值, 用于防止对零取对数, 保证数值稳定性。
24
-
25
- Returns:
26
- float: 对数谱距离值, 单位为分贝 (dB)。
27
- """
28
- assert reference.ndim == 1 and estimate.ndim == 1, "输入信号必须是一维数组。"
29
-
30
- if win_length is None:
31
- win_length = n_fft
32
-
33
- reference_stft = librosa.stft(reference, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
34
- estimate_stft = librosa.stft(estimate, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
35
-
36
- reference_power_spec = np.abs(reference_stft) ** 2 # (F,T)
37
- estimate_power_spec = np.abs(estimate_stft) ** 2 # (F,T)
38
-
39
- reference_log_power_spec = 10 * np.log10(reference_power_spec + EPS)
40
- estimate_log_power_spec = 10 * np.log10(estimate_power_spec + EPS)
41
-
42
- squared_error = (reference_log_power_spec - estimate_log_power_spec) ** 2
43
- lsd_val = np.sqrt(np.mean(squared_error))
44
-
45
- return lsd_val
@@ -1,11 +0,0 @@
1
- """
2
- 频域的客观评价指标
3
- LSD: 对数谱距离
4
- """
5
- import sys
6
- sys.path.append("..")
7
- import numpy as np
8
- import librosa
9
- from utils import EPS
10
-
11
-
@@ -1,16 +0,0 @@
1
- '''
2
- Author: 凌逆战 | Never
3
- Date: 2025-08-05 23:42:10
4
- Description:
5
- '''
6
- """
7
- 频域的客观评价指标
8
- LSD: 对数谱距离
9
- """
10
- import sys
11
- sys.path.append("..")
12
- import numpy as np
13
- import librosa
14
- from utils import EPS
15
-
16
-
@@ -1,68 +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 neverlib.utils import EPS
11
-
12
-
13
-
14
-
15
-
16
- def lsd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
17
- """
18
- 计算两个一维音频信号之间的对数谱距离 (Log-Spectral Distance, LSD)。
19
- 该实现遵循标准的LSD定义: 整体均方根误差。
20
-
21
- Args:
22
- ref_wav (np.ndarray): 原始的、干净的参考信号 (一维数组)。
23
- test_wav (np.ndarray): 模型估计或处理后的信号 (一维数组)。
24
- n_fft (int): FFT点数, 决定了频率分辨率。
25
- hop_length (int): 帧移, 决定了时间分辨率。
26
- win_length (int, optional): 窗长。如果为None, 则默认为n_fft。
27
- epsilon (float): 一个非常小的数值, 用于防止对零取对数, 保证数值稳定性。
28
-
29
- Returns:
30
- float: 对数谱距离值, 单位为分贝 (dB)。
31
- """
32
- assert ref_wav.ndim == 1 and test_wav.ndim == 1, "输入信号必须是一维数组。"
33
-
34
- if win_length is None:
35
- win_length = n_fft
36
-
37
- ref_stft = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
38
- test_stft = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
39
-
40
- ref_power_spec = np.abs(ref_stft) ** 2 # (F,T)
41
- test_power_spec = np.abs(test_stft) ** 2 # (F,T)
42
-
43
- ref_log_power_spec = 10 * np.log10(ref_power_spec + EPS)
44
- test_log_power_spec = 10 * np.log10(test_power_spec + EPS)
45
-
46
- squared_error = (ref_log_power_spec - test_log_power_spec) ** 2
47
- lsd_val = np.sqrt(np.mean(squared_error))
48
-
49
- return lsd_val
50
-
51
- def mcd(ref_wav, test_wav, sr=16000):
52
- """
53
- 梅尔倒谱距离 Mel-Cepstral Distance
54
- ref_spec: 参考频谱
55
- test_spec: 测试频谱
56
- """
57
- ref_wav, ref_sr = sf.read(ref_wav)
58
- test_wav, test_sr = sf.read(test_wav)
59
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
60
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
61
-
62
- ref_mfcc = librosa.feature.mfcc(y=ref_wav, sr=sr)
63
- test_mfcc = librosa.feature.mfcc(y=test_wav, sr=sr)
64
-
65
- # 计算 MCD (跳过 0 阶)
66
- diff = ref_mfcc[1:] - test_mfcc[1:]
67
- mcd = (10.0 / np.log(10)) * np.sqrt(2 * np.mean(np.sum(diff ** 2, axis=0)))
68
- return mcd
@@ -1,75 +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 neverlib.utils import EPS
11
-
12
-
13
- def sd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
14
- """
15
- 频谱距离
16
- """
17
- ref_spec = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length)
18
- test_spec = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length)
19
- return np.sqrt(np.mean((ref_spec - test_spec) ** 2))
20
-
21
-
22
-
23
- def lsd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
24
- """
25
- 计算两个一维音频信号之间的对数谱距离 (Log-Spectral Distance, LSD)。
26
- 该实现遵循标准的LSD定义: 整体均方根误差。
27
-
28
- Args:
29
- ref_wav (np.ndarray): 原始的、干净的参考信号 (一维数组)。
30
- test_wav (np.ndarray): 模型估计或处理后的信号 (一维数组)。
31
- n_fft (int): FFT点数, 决定了频率分辨率。
32
- hop_length (int): 帧移, 决定了时间分辨率。
33
- win_length (int, optional): 窗长。如果为None, 则默认为n_fft。
34
- epsilon (float): 一个非常小的数值, 用于防止对零取对数, 保证数值稳定性。
35
-
36
- Returns:
37
- float: 对数谱距离值, 单位为分贝 (dB)。
38
- """
39
- assert ref_wav.ndim == 1 and test_wav.ndim == 1, "输入信号必须是一维数组。"
40
-
41
- if win_length is None:
42
- win_length = n_fft
43
-
44
- ref_stft = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
45
- test_stft = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
46
-
47
- ref_power_spec = np.abs(ref_stft) ** 2 # (F,T)
48
- test_power_spec = np.abs(test_stft) ** 2 # (F,T)
49
-
50
- ref_log_power_spec = 10 * np.log10(ref_power_spec + EPS)
51
- test_log_power_spec = 10 * np.log10(test_power_spec + EPS)
52
-
53
- squared_error = (ref_log_power_spec - test_log_power_spec) ** 2
54
- lsd_val = np.sqrt(np.mean(squared_error))
55
-
56
- return lsd_val
57
-
58
- def mcd(ref_wav, test_wav, sr=16000):
59
- """
60
- 梅尔倒谱距离 Mel-Cepstral Distance
61
- ref_spec: 参考频谱
62
- test_spec: 测试频谱
63
- """
64
- ref_wav, ref_sr = sf.read(ref_wav)
65
- test_wav, test_sr = sf.read(test_wav)
66
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
67
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
68
-
69
- ref_mfcc = librosa.feature.mfcc(y=ref_wav, sr=sr)
70
- test_mfcc = librosa.feature.mfcc(y=test_wav, sr=sr)
71
-
72
- # 计算 MCD (跳过 0 阶)
73
- diff = ref_mfcc[1:] - test_mfcc[1:]
74
- mcd = (10.0 / np.log(10)) * np.sqrt(2 * np.mean(np.sum(diff ** 2, axis=0)))
75
- return mcd
@@ -1,82 +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 neverlib.utils import EPS
11
-
12
-
13
- def sd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
14
- """
15
- 频谱距离
16
- """
17
- ref_spec = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length)
18
- test_spec = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length)
19
- return np.sqrt(np.mean((ref_spec - test_spec) ** 2))
20
-
21
-
22
-
23
- def lsd(ref_wav, test_wav, n_fft=2048, hop_length=512, win_length=None):
24
- """
25
- 计算两个一维音频信号之间的对数谱距离 (Log-Spectral Distance, LSD)。
26
- 该实现遵循标准的LSD定义: 整体均方根误差。
27
-
28
- Args:
29
- ref_wav (np.ndarray): 原始的、干净的参考信号 (一维数组)。
30
- test_wav (np.ndarray): 模型估计或处理后的信号 (一维数组)。
31
- n_fft (int): FFT点数, 决定了频率分辨率。
32
- hop_length (int): 帧移, 决定了时间分辨率。
33
- win_length (int, optional): 窗长。如果为None, 则默认为n_fft。
34
- epsilon (float): 一个非常小的数值, 用于防止对零取对数, 保证数值稳定性。
35
-
36
- Returns:
37
- float: 对数谱距离值, 单位为分贝 (dB)。
38
- """
39
- assert ref_wav.ndim == 1 and test_wav.ndim == 1, "输入信号必须是一维数组。"
40
-
41
- if win_length is None:
42
- win_length = n_fft
43
-
44
- ref_stft = librosa.stft(ref_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
45
- test_stft = librosa.stft(test_wav, n_fft=n_fft, hop_length=hop_length, win_length=win_length) # (F,T)
46
-
47
- ref_power_spec = np.abs(ref_stft) ** 2 # (F,T)
48
- test_power_spec = np.abs(test_stft) ** 2 # (F,T)
49
-
50
- ref_log_power_spec = 10 * np.log10(ref_power_spec + EPS)
51
- test_log_power_spec = 10 * np.log10(test_power_spec + EPS)
52
-
53
- squared_error = (ref_log_power_spec - test_log_power_spec) ** 2
54
- lsd_val = np.sqrt(np.mean(squared_error))
55
-
56
- return lsd_val
57
-
58
- def mcd(ref_wav, test_wav, sr=16000):
59
- """
60
- 梅尔倒谱距离 Mel-Cepstral Distance
61
- ref_spec: 参考频谱
62
- test_spec: 测试频谱
63
- """
64
- ref_wav, ref_sr = sf.read(ref_wav)
65
- test_wav, test_sr = sf.read(test_wav)
66
- assert ref_sr == test_sr == sr, "采样率必须为16000Hz"
67
- assert len(ref_wav) == len(test_wav), "音频长度必须相同"
68
-
69
- ref_mfcc = librosa.feature.mfcc(y=ref_wav, sr=sr)
70
- test_mfcc = librosa.feature.mfcc(y=test_wav, sr=sr)
71
-
72
- # 计算 MCD (跳过 0 阶)
73
- diff = ref_mfcc[1:] - test_mfcc[1:]
74
- mcd = (10.0 / np.log(10)) * np.sqrt(2 * np.mean(np.sum(diff ** 2, axis=0)))
75
- return mcd
76
-
77
- if __name__ == "__main__":
78
- ref_file = "../data/vad_example.wav" # 参考语音文件路径
79
- test_file = "../data/vad_example.wav" # 测试语音文件路径
80
-
81
- avg_dist, dist_list = lpc_lsp_distance(ref_file, test_file)
82
- print(f"平均 LSP MSE 失真: {avg_dist}")