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,96 +0,0 @@
1
- import numpy as np
2
- import librosa
3
-
4
- def pre_emphasis(signal, coeff=0.97):
5
- """预加重"""
6
- return np.append(signal[0], signal[1:] - coeff * signal[:-1])
7
-
8
- def framing(signal, frame_size, frame_stride, fs):
9
- """分帧 + 汉明窗"""
10
- frame_length = int(round(frame_size * fs))
11
- frame_step = int(round(frame_stride * fs))
12
-
13
- # 使用 librosa 进行分帧
14
- frames = librosa.util.frame(signal, frame_length=frame_length, hop_length=frame_step, axis=0)
15
-
16
- # 应用汉明窗
17
- hamming_window = np.hamming(frame_length)
18
- frames = frames.T * hamming_window
19
-
20
- return frames
21
-
22
-
23
- def lpc_analysis(frame, order):
24
- """对一帧做 LPC 分析"""
25
- a = librosa.lpc(frame, order=order)
26
- return a
27
-
28
- def lpc_to_lsp(a, num_points=512):
29
- """
30
- LPC -> LSP 转换(简易近似版,零点搜索法)
31
- """
32
- p = len(a) - 1
33
- a = np.array(a)
34
- # 构造P(z) Q(z)
35
- P = np.zeros(p+1)
36
- Q = np.zeros(p+1)
37
- for i in range(p+1):
38
- if i == 0:
39
- P[i] = 1 + a[i]
40
- Q[i] = 1 - a[i]
41
- else:
42
- P[i] = a[i] + a[p - i]
43
- Q[i] = a[i] - a[p - i]
44
- # 频域采样找过零点
45
- w = np.linspace(0, np.pi, num_points)
46
- Pw = np.polyval(P[::-1], np.cos(w))
47
- Qw = np.polyval(Q[::-1], np.cos(w))
48
-
49
- # 找零点近似位置
50
- roots_P = w[np.where(np.diff(np.sign(Pw)) != 0)]
51
- roots_Q = w[np.where(np.diff(np.sign(Qw)) != 0)]
52
- lsp = np.sort(np.concatenate([roots_P, roots_Q]))
53
- return lsp
54
-
55
- def lsp_mse(lsp1, lsp2):
56
- """计算两个 LSP 向量的均方差"""
57
- return np.mean((lsp1 - lsp2) ** 2)
58
-
59
-
60
- def lpc_lsp_distance(ref_wav, test_wav, frame_size=0.025, frame_stride=0.01, order=12):
61
- """主函数:计算 LPC-LSP 参数失真"""
62
- ref_sig, fs_r = librosa.load(ref_wav, sr=None)
63
- test_sig, fs_t = librosa.load(test_wav, sr=None)
64
-
65
- # 预加重
66
- ref_sig = pre_emphasis(ref_sig)
67
- test_sig = pre_emphasis(test_sig)
68
-
69
- # 分帧
70
- ref_frames = framing(ref_sig, frame_size, frame_stride, fs_r)
71
- test_frames = framing(test_sig, frame_size, frame_stride, fs_t)
72
-
73
- # 对齐帧数(简单切到最短)
74
- num_frames = min(len(ref_frames), len(test_frames))
75
- ref_frames = ref_frames[:num_frames]
76
- test_frames = test_frames[:num_frames]
77
-
78
- distances = []
79
- for i in range(num_frames):
80
- a_ref = lpc_analysis(ref_frames[i], order)
81
- a_test = lpc_analysis(test_frames[i], order)
82
- lsp_ref = lpc_to_lsp(a_ref)
83
- lsp_test = lpc_to_lsp(a_test)
84
- # 对齐长度(简单裁切)
85
- min_len = min(len(lsp_ref), len(lsp_test))
86
- dist = lsp_mse(lsp_ref[:min_len], lsp_test[:min_len])
87
- distances.append(dist)
88
-
89
- return np.mean(distances), distances
90
-
91
- if __name__ == "__main__":
92
- ref_file = "ref.wav" # 参考语音文件路径
93
- test_file = "test.wav" # 测试语音文件路径
94
-
95
- avg_dist, dist_list = lpc_lsp_distance(ref_file, test_file)
96
- print(f"平均 LSP MSE 失真: {avg_dist}")
@@ -1,97 +0,0 @@
1
- import numpy as np
2
- import librosa
3
- import soundfile as sf
4
-
5
- def pre_emphasis(signal, coeff=0.97):
6
- """预加重"""
7
- return np.append(signal[0], signal[1:] - coeff * signal[:-1])
8
-
9
- def framing(signal, frame_size, frame_stride, fs):
10
- """分帧 + 汉明窗"""
11
- frame_length = int(round(frame_size * fs))
12
- frame_step = int(round(frame_stride * fs))
13
-
14
- # 使用 librosa 进行分帧
15
- frames = librosa.util.frame(signal, frame_length=frame_length, hop_length=frame_step, axis=0)
16
-
17
- # 应用汉明窗
18
- hamming_window = np.hamming(frame_length)
19
- frames = frames.T * hamming_window
20
-
21
- return frames
22
-
23
-
24
- def lpc_analysis(frame, order):
25
- """对一帧做 LPC 分析"""
26
- a = librosa.lpc(frame, order=order)
27
- return a
28
-
29
- def lpc_to_lsp(a, num_points=512):
30
- """
31
- LPC -> LSP 转换(简易近似版,零点搜索法)
32
- """
33
- p = len(a) - 1
34
- a = np.array(a)
35
- # 构造P(z) Q(z)
36
- P = np.zeros(p+1)
37
- Q = np.zeros(p+1)
38
- for i in range(p+1):
39
- if i == 0:
40
- P[i] = 1 + a[i]
41
- Q[i] = 1 - a[i]
42
- else:
43
- P[i] = a[i] + a[p - i]
44
- Q[i] = a[i] - a[p - i]
45
- # 频域采样找过零点
46
- w = np.linspace(0, np.pi, num_points)
47
- Pw = np.polyval(P[::-1], np.cos(w))
48
- Qw = np.polyval(Q[::-1], np.cos(w))
49
-
50
- # 找零点近似位置
51
- roots_P = w[np.where(np.diff(np.sign(Pw)) != 0)]
52
- roots_Q = w[np.where(np.diff(np.sign(Qw)) != 0)]
53
- lsp = np.sort(np.concatenate([roots_P, roots_Q]))
54
- return lsp
55
-
56
- def lsp_mse(lsp1, lsp2):
57
- """计算两个 LSP 向量的均方差"""
58
- return np.mean((lsp1 - lsp2) ** 2)
59
-
60
-
61
- def lpc_lsp_distance(ref_wav, test_wav, frame_size=0.025, frame_stride=0.01, order=12):
62
- """主函数:计算 LPC-LSP 参数失真"""
63
- ref_sig, fs_r = sf.read(ref_wav, dtype='float32')
64
- test_sig, fs_t = sf.read(test_wav, dtype='float32')
65
-
66
- # 预加重
67
- ref_sig = pre_emphasis(ref_sig)
68
- test_sig = pre_emphasis(test_sig)
69
-
70
- # 分帧
71
- ref_frames = framing(ref_sig, frame_size, frame_stride, fs_r)
72
- test_frames = framing(test_sig, frame_size, frame_stride, fs_t)
73
-
74
- # 对齐帧数(简单切到最短)
75
- num_frames = min(len(ref_frames), len(test_frames))
76
- ref_frames = ref_frames[:num_frames]
77
- test_frames = test_frames[:num_frames]
78
-
79
- distances = []
80
- for i in range(num_frames):
81
- a_ref = lpc_analysis(ref_frames[i], order)
82
- a_test = lpc_analysis(test_frames[i], order)
83
- lsp_ref = lpc_to_lsp(a_ref)
84
- lsp_test = lpc_to_lsp(a_test)
85
- # 对齐长度(简单裁切)
86
- min_len = min(len(lsp_ref), len(lsp_test))
87
- dist = lsp_mse(lsp_ref[:min_len], lsp_test[:min_len])
88
- distances.append(dist)
89
-
90
- return np.mean(distances), distances
91
-
92
- if __name__ == "__main__":
93
- ref_file = "ref.wav" # 参考语音文件路径
94
- test_file = "test.wav" # 测试语音文件路径
95
-
96
- avg_dist, dist_list = lpc_lsp_distance(ref_file, test_file)
97
- print(f"平均 LSP MSE 失真: {avg_dist}")
@@ -1,104 +0,0 @@
1
- '''
2
- LPC-LSP 参数失真计算
3
-
4
-
5
-
6
-
7
- '''
8
- import numpy as np
9
- import librosa
10
- import soundfile as sf
11
-
12
- def pre_emphasis(signal, coeff=0.97):
13
- """预加重"""
14
- return np.append(signal[0], signal[1:] - coeff * signal[:-1])
15
-
16
- def framing(signal, frame_size, frame_stride, fs):
17
- """分帧 + 汉明窗"""
18
- frame_length = int(round(frame_size * fs))
19
- frame_step = int(round(frame_stride * fs))
20
-
21
- # 使用 librosa 进行分帧
22
- frames = librosa.util.frame(signal, frame_length=frame_length, hop_length=frame_step, axis=0)
23
-
24
- # 应用汉明窗
25
- hamming_window = np.hamming(frame_length)
26
- frames = frames.T * hamming_window
27
-
28
- return frames
29
-
30
-
31
- def lpc_analysis(frame, order):
32
- """对一帧做 LPC 分析"""
33
- a = librosa.lpc(frame, order=order)
34
- return a
35
-
36
- def lpc_to_lsp(a, num_points=512):
37
- """
38
- LPC -> LSP 转换(简易近似版,零点搜索法)
39
- """
40
- p = len(a) - 1
41
- a = np.array(a)
42
- # 构造P(z) Q(z)
43
- P = np.zeros(p+1)
44
- Q = np.zeros(p+1)
45
- for i in range(p+1):
46
- if i == 0:
47
- P[i] = 1 + a[i]
48
- Q[i] = 1 - a[i]
49
- else:
50
- P[i] = a[i] + a[p - i]
51
- Q[i] = a[i] - a[p - i]
52
- # 频域采样找过零点
53
- w = np.linspace(0, np.pi, num_points)
54
- Pw = np.polyval(P[::-1], np.cos(w))
55
- Qw = np.polyval(Q[::-1], np.cos(w))
56
-
57
- # 找零点近似位置
58
- roots_P = w[np.where(np.diff(np.sign(Pw)) != 0)]
59
- roots_Q = w[np.where(np.diff(np.sign(Qw)) != 0)]
60
- lsp = np.sort(np.concatenate([roots_P, roots_Q]))
61
- return lsp
62
-
63
- def lsp_mse(lsp1, lsp2):
64
- """计算两个 LSP 向量的均方差"""
65
- return np.mean((lsp1 - lsp2) ** 2)
66
-
67
-
68
- def lpc_lsp_distance(ref_wav, test_wav, frame_size=0.025, frame_stride=0.01, order=12):
69
- """主函数:计算 LPC-LSP 参数失真"""
70
- ref_sig, fs_r = sf.read(ref_wav, dtype='float32')
71
- test_sig, fs_t = sf.read(test_wav, dtype='float32')
72
-
73
- # 预加重
74
- ref_sig = pre_emphasis(ref_sig)
75
- test_sig = pre_emphasis(test_sig)
76
-
77
- # 分帧
78
- ref_frames = framing(ref_sig, frame_size, frame_stride, fs_r)
79
- test_frames = framing(test_sig, frame_size, frame_stride, fs_t)
80
-
81
- # 对齐帧数(简单切到最短)
82
- num_frames = min(len(ref_frames), len(test_frames))
83
- ref_frames = ref_frames[:num_frames]
84
- test_frames = test_frames[:num_frames]
85
-
86
- distances = []
87
- for i in range(num_frames):
88
- a_ref = lpc_analysis(ref_frames[i], order)
89
- a_test = lpc_analysis(test_frames[i], order)
90
- lsp_ref = lpc_to_lsp(a_ref)
91
- lsp_test = lpc_to_lsp(a_test)
92
- # 对齐长度(简单裁切)
93
- min_len = min(len(lsp_ref), len(lsp_test))
94
- dist = lsp_mse(lsp_ref[:min_len], lsp_test[:min_len])
95
- distances.append(dist)
96
-
97
- return np.mean(distances), distances
98
-
99
- if __name__ == "__main__":
100
- ref_file = "ref.wav" # 参考语音文件路径
101
- test_file = "test.wav" # 测试语音文件路径
102
-
103
- avg_dist, dist_list = lpc_lsp_distance(ref_file, test_file)
104
- print(f"平均 LSP MSE 失真: {avg_dist}")
@@ -1,100 +0,0 @@
1
- '''
2
- LPC-LSP 参数失真计算
3
- '''
4
- import numpy as np
5
- import librosa
6
- import soundfile as sf
7
-
8
- def pre_emphasis(signal, coeff=0.97):
9
- """预加重"""
10
- return np.append(signal[0], signal[1:] - coeff * signal[:-1])
11
-
12
- def framing(signal, frame_size, frame_stride, fs):
13
- """分帧 + 汉明窗"""
14
- frame_length = int(round(frame_size * fs))
15
- frame_step = int(round(frame_stride * fs))
16
-
17
- # 使用 librosa 进行分帧
18
- frames = librosa.util.frame(signal, frame_length=frame_length, hop_length=frame_step, axis=0)
19
-
20
- # 应用汉明窗
21
- hamming_window = np.hamming(frame_length)
22
- frames = frames.T * hamming_window
23
-
24
- return frames
25
-
26
-
27
- def lpc_analysis(frame, order):
28
- """对一帧做 LPC 分析"""
29
- a = librosa.lpc(frame, order=order)
30
- return a
31
-
32
- def lpc_to_lsp(a, num_points=512):
33
- """
34
- LPC -> LSP 转换(简易近似版,零点搜索法)
35
- """
36
- p = len(a) - 1
37
- a = np.array(a)
38
- # 构造P(z) Q(z)
39
- P = np.zeros(p+1)
40
- Q = np.zeros(p+1)
41
- for i in range(p+1):
42
- if i == 0:
43
- P[i] = 1 + a[i]
44
- Q[i] = 1 - a[i]
45
- else:
46
- P[i] = a[i] + a[p - i]
47
- Q[i] = a[i] - a[p - i]
48
- # 频域采样找过零点
49
- w = np.linspace(0, np.pi, num_points)
50
- Pw = np.polyval(P[::-1], np.cos(w))
51
- Qw = np.polyval(Q[::-1], np.cos(w))
52
-
53
- # 找零点近似位置
54
- roots_P = w[np.where(np.diff(np.sign(Pw)) != 0)]
55
- roots_Q = w[np.where(np.diff(np.sign(Qw)) != 0)]
56
- lsp = np.sort(np.concatenate([roots_P, roots_Q]))
57
- return lsp
58
-
59
- def lsp_mse(lsp1, lsp2):
60
- """计算两个 LSP 向量的均方差"""
61
- return np.mean((lsp1 - lsp2) ** 2)
62
-
63
-
64
- def lpc_lsp_distance(ref_wav, test_wav, frame_size=0.025, frame_stride=0.01, order=12):
65
- """主函数:计算 LPC-LSP 参数失真"""
66
- ref_sig, fs_r = sf.read(ref_wav, dtype='float32')
67
- test_sig, fs_t = sf.read(test_wav, dtype='float32')
68
-
69
- # 预加重
70
- ref_sig = pre_emphasis(ref_sig)
71
- test_sig = pre_emphasis(test_sig)
72
-
73
- # 分帧
74
- ref_frames = framing(ref_sig, frame_size, frame_stride, fs_r)
75
- test_frames = framing(test_sig, frame_size, frame_stride, fs_t)
76
-
77
- # 对齐帧数(简单切到最短)
78
- num_frames = min(len(ref_frames), len(test_frames))
79
- ref_frames = ref_frames[:num_frames]
80
- test_frames = test_frames[:num_frames]
81
-
82
- distances = []
83
- for i in range(num_frames):
84
- a_ref = lpc_analysis(ref_frames[i], order)
85
- a_test = lpc_analysis(test_frames[i], order)
86
- lsp_ref = lpc_to_lsp(a_ref)
87
- lsp_test = lpc_to_lsp(a_test)
88
- # 对齐长度(简单裁切)
89
- min_len = min(len(lsp_ref), len(lsp_test))
90
- dist = lsp_mse(lsp_ref[:min_len], lsp_test[:min_len])
91
- distances.append(dist)
92
-
93
- return np.mean(distances), distances
94
-
95
- if __name__ == "__main__":
96
- ref_file = "ref.wav" # 参考语音文件路径
97
- test_file = "test.wav" # 测试语音文件路径
98
-
99
- avg_dist, dist_list = lpc_lsp_distance(ref_file, test_file)
100
- print(f"平均 LSP MSE 失真: {avg_dist}")
@@ -1,128 +0,0 @@
1
- '''
2
- 功能描述
3
-
4
- 计算参考语音和测试语音之间的线性预测编码-线谱对(LPC-LSP)参
5
- 数失真度
6
-
7
- 主要组件
8
-
9
- 预处理函数:
10
- - pre_emphasis(): 预加重滤波,增强高频成分
11
- - framing(): 分帧处理并应用汉明窗
12
-
13
- LPC分析:
14
- - lpc_analysis(): 使用librosa.lpc进行线性预测分析
15
- - lpc_to_lsp(): LPC系数转换为线谱对参数
16
-
17
- 距离计算:
18
- - lsp_mse(): 计算LSP向量间的均方误差
19
- - lpc_lsp_distance(): 主函数,返回平均失真度和逐帧失真列表
20
-
21
- 技术特点
22
-
23
- - 使用soundfile读取音频(支持多种格式)
24
- - librosa进行LPC分析(替代了自定义算法)
25
- - 基于LSP的频域失真测量,对量化误差敏感度更低
26
- - 逐帧分析捕捉语音时变特性
27
-
28
- 应用场景
29
-
30
- 语音编码器质量评估、语音增强效果测量、语音合成质量分析
31
- '''
32
- import numpy as np
33
- import librosa
34
- import soundfile as sf
35
-
36
- def pre_emphasis(signal, coeff=0.97):
37
- """预加重"""
38
- return np.append(signal[0], signal[1:] - coeff * signal[:-1])
39
-
40
- def framing(signal, frame_size, frame_stride, fs):
41
- """分帧 + 汉明窗"""
42
- frame_length = int(round(frame_size * fs))
43
- frame_step = int(round(frame_stride * fs))
44
-
45
- # 使用 librosa 进行分帧
46
- frames = librosa.util.frame(signal, frame_length=frame_length, hop_length=frame_step, axis=0)
47
-
48
- # 应用汉明窗
49
- hamming_window = np.hamming(frame_length)
50
- frames = frames.T * hamming_window
51
-
52
- return frames
53
-
54
-
55
- def lpc_analysis(frame, order):
56
- """对一帧做 LPC 分析"""
57
- a = librosa.lpc(frame, order=order)
58
- return a
59
-
60
- def lpc_to_lsp(a, num_points=512):
61
- """
62
- LPC -> LSP 转换(简易近似版,零点搜索法)
63
- """
64
- p = len(a) - 1
65
- a = np.array(a)
66
- # 构造P(z) Q(z)
67
- P = np.zeros(p+1)
68
- Q = np.zeros(p+1)
69
- for i in range(p+1):
70
- if i == 0:
71
- P[i] = 1 + a[i]
72
- Q[i] = 1 - a[i]
73
- else:
74
- P[i] = a[i] + a[p - i]
75
- Q[i] = a[i] - a[p - i]
76
- # 频域采样找过零点
77
- w = np.linspace(0, np.pi, num_points)
78
- Pw = np.polyval(P[::-1], np.cos(w))
79
- Qw = np.polyval(Q[::-1], np.cos(w))
80
-
81
- # 找零点近似位置
82
- roots_P = w[np.where(np.diff(np.sign(Pw)) != 0)]
83
- roots_Q = w[np.where(np.diff(np.sign(Qw)) != 0)]
84
- lsp = np.sort(np.concatenate([roots_P, roots_Q]))
85
- return lsp
86
-
87
- def lsp_mse(lsp1, lsp2):
88
- """计算两个 LSP 向量的均方差"""
89
- return np.mean((lsp1 - lsp2) ** 2)
90
-
91
-
92
- def lpc_lsp_distance(ref_wav, test_wav, frame_size=0.025, frame_stride=0.01, order=12):
93
- """主函数:计算 LPC-LSP 参数失真"""
94
- ref_sig, fs_r = sf.read(ref_wav, dtype='float32')
95
- test_sig, fs_t = sf.read(test_wav, dtype='float32')
96
-
97
- # 预加重
98
- ref_sig = pre_emphasis(ref_sig)
99
- test_sig = pre_emphasis(test_sig)
100
-
101
- # 分帧
102
- ref_frames = framing(ref_sig, frame_size, frame_stride, fs_r)
103
- test_frames = framing(test_sig, frame_size, frame_stride, fs_t)
104
-
105
- # 对齐帧数(简单切到最短)
106
- num_frames = min(len(ref_frames), len(test_frames))
107
- ref_frames = ref_frames[:num_frames]
108
- test_frames = test_frames[:num_frames]
109
-
110
- distances = []
111
- for i in range(num_frames):
112
- a_ref = lpc_analysis(ref_frames[i], order)
113
- a_test = lpc_analysis(test_frames[i], order)
114
- lsp_ref = lpc_to_lsp(a_ref)
115
- lsp_test = lpc_to_lsp(a_test)
116
- # 对齐长度(简单裁切)
117
- min_len = min(len(lsp_ref), len(lsp_test))
118
- dist = lsp_mse(lsp_ref[:min_len], lsp_test[:min_len])
119
- distances.append(dist)
120
-
121
- return np.mean(distances), distances
122
-
123
- if __name__ == "__main__":
124
- ref_file = "ref.wav" # 参考语音文件路径
125
- test_file = "test.wav" # 测试语音文件路径
126
-
127
- avg_dist, dist_list = lpc_lsp_distance(ref_file, test_file)
128
- print(f"平均 LSP MSE 失真: {avg_dist}")
@@ -1,177 +0,0 @@
1
- import sys
2
- sys.path.append("../")
3
- import librosa
4
- import numpy as np
5
- from neverlib.vad.utils import vad2nad
6
-
7
-
8
- def get_snr(speech, noise):
9
- """计算信噪比
10
- Args:
11
- speech: 语音音频
12
- noise: 噪声音频
13
- Returns:
14
- snr: 信噪比
15
- """
16
- assert speech.ndim == noise.ndim, "speech和noise的维度不一样"
17
-
18
- power_speech = np.mean(speech**2)
19
- power_noise = max(np.mean(noise**2), 1e-10)
20
-
21
- snr = 10 * np.log10(power_speech / power_noise)
22
- return snr
23
-
24
-
25
- def get_snr_from_noisy(noisy, speech_vad=None):
26
- """根据带噪音频计算信噪比
27
- Args:
28
- noisy: 带噪音频
29
- speech_vad: [{start:xxx, end:xxx}, ...]
30
- Returns:
31
- snr: 信噪比
32
- """
33
- assert speech_vad is not None, "speech_vad不能为空"
34
-
35
- # 提取语音段
36
- speech_segments = []
37
- for segment in speech_vad:
38
- start = segment['start']
39
- end = segment['end']
40
- speech_segments.append(noisy[start:end])
41
- speech = np.concatenate(speech_segments, axis=0)
42
-
43
- # 提取非语音段
44
- noise_segments = []
45
- noise_point_list = vad2nad(speech_vad, len(noisy))
46
- for noise_point in noise_point_list:
47
- noise_segments.append(noisy[noise_point['start']:noise_point['end']])
48
- noise = np.concatenate(noise_segments, axis=0)
49
-
50
- return get_snr(speech, noise)
51
-
52
-
53
- def seg_snr(clean, noisy, frame_length: int, hop_length: int):
54
- """
55
- 分帧计算信噪比
56
- Args:
57
- clean: 干净音频, numpy array
58
- noisy: 带噪音频, numpy array
59
- frame_length: 帧长
60
- hop_length: 帧移
61
- Returns:
62
- snr_mean: 平均信噪比, float
63
- Raises:
64
- ValueError: 当输入参数不合法时抛出
65
- """
66
- assert clean.shape == noisy.shape, "clean和noisy的维度不一样"
67
-
68
- # 分帧
69
- clean_frames = librosa.util.frame(clean, frame_length=frame_length, hop_length=hop_length) # (frame_length, n_frames)
70
- noisy_frames = librosa.util.frame(noisy, frame_length=frame_length, hop_length=hop_length) # (frame_length, n_frames)
71
-
72
- # 计算每帧的信噪比
73
- snr_frames = []
74
- for i in range(clean_frames.shape[1]):
75
- clean_frame = clean_frames[:, i]
76
- noisy_frame = noisy_frames[:, i]
77
- # 跳过静音帧
78
- if np.all(np.abs(clean_frame) < 1e-6) or np.all(np.abs(noisy_frame) < 1e-6):
79
- continue
80
- snr_frames.append(get_snr(clean_frame, noisy_frame))
81
-
82
- # 如果所有帧都是静音
83
- if not snr_frames:
84
- return float('-inf')
85
-
86
- return np.mean(snr_frames)
87
-
88
-
89
- def psnr(clean, noisy, max_val=None):
90
- """
91
- 计算峰值信噪比
92
- Args:
93
- clean: 干净音频, numpy array
94
- noisy: 带噪音频, numpy array
95
- max_val: 信号最大值, 如果为None则使用clean信号的实际最大值
96
- Returns:
97
- psnr: 峰值信噪比, 单位dB
98
- """
99
- assert clean.shape == noisy.shape, "clean和noisy的维度不一样"
100
-
101
- # 如果没有指定最大值, 使用clean信号的实际最大值
102
- if max_val is None:
103
- max_val = np.abs(clean).max()
104
-
105
- # 计算均方误差 (MSE)
106
- mse = np.mean((clean - noisy) ** 2)
107
-
108
- # 避免除以0
109
- if mse == 0:
110
- return float('inf')
111
-
112
- # 计算PSNR
113
- psnr = 10 * np.log10(max_val**2 / mse)
114
- return psnr
115
-
116
-
117
- def si_sdr(reference, estimate, epsilon=1e-8):
118
- """
119
- 计算尺度不变信噪比 (Scale-Invariant Signal-to-Distortion Ratio, SI-SDR)。
120
-
121
- Args:
122
- reference (np.ndarray): 原始的、干净的参考信号 (一维数组)。
123
- estimate (np.ndarray): 模型估计或处理后的信号 (一维数组)。
124
- epsilon (float): 一个非常小的数值, 用于防止分母为零, 保证数值稳定性。
125
-
126
- Returns:
127
- float: SI-SDR 值, 单位为分贝 (dB)。
128
- """
129
- assert reference.shape == estimate.shape, "reference和estimate的维度不一样"
130
-
131
- # 2. 零均值化 (可选但推荐)
132
- # 移除直流分量, 使计算更关注信号的动态变化
133
- reference = reference - np.mean(reference)
134
- estimate = estimate - np.mean(estimate)
135
-
136
- # 3. 计算目标信号分量 (s_target)
137
- # s_target 是 estimate 在 reference 上的投影
138
- # 公式: s_target = (<ŝ, s> / ||s||²) * s
139
- dot_product = np.dot(estimate, reference) # <ŝ, s> (点积)
140
- norm_s_squared = np.dot(reference, reference) # ||s||² (s的能量)
141
-
142
- # 检查参考信号能量, 避免除以零
143
- if norm_s_squared < epsilon:
144
- # 如果参考信号几乎是静音, SI-SDR没有意义
145
- return -np.inf # 返回负无穷或np.nan
146
-
147
- alpha = dot_product / (norm_s_squared + epsilon) # 最佳缩放因子 α
148
- s_target = alpha * reference
149
-
150
- # 4. 计算误差/失真分量 (e_noise)
151
- e_noise = estimate - s_target
152
-
153
- # 5. 计算 SI-SDR
154
- # SI-SDR = 10 * log10 ( ||s_target||² / ||e_noise||² )
155
- power_s_target = np.sum(s_target**2) # ||s_target||²
156
- power_e_noise = np.sum(e_noise**2) # ||e_noise||²
157
-
158
- # 同样加上 epsilon 防止除以零
159
- if power_e_noise < epsilon:
160
- # 如果噪声能量极小, 说明匹配得非常好
161
- return np.inf # 返回正无穷
162
-
163
- si_sdr_val = 10 * np.log10(power_s_target / (power_e_noise + epsilon))
164
-
165
- return si_sdr_val
166
-
167
-
168
- if __name__ == "__main__":
169
- # 生成测试信号
170
- speech = np.random.randn(1000)
171
- noise = np.random.randn(1000) * 0.1 # 较小的噪声
172
- noisy = speech + noise
173
-
174
- # 测试各种信噪比计算方法
175
- print(f"SNR: {get_snr(speech, noise):.2f} dB")
176
- print(f"Segmental SNR: {seg_snr(speech, noisy, 100, 50):.2f} dB")
177
- print(f"PSNR: {psnr(speech, noisy):.2f} dB")