PageSourceSearch

https://duan602728596.github.io/_next/static/chunks/pages/article/…paniment-using-spleeter-9f07985a7e086f10.js

js duan602728596.github.io collected 2026-10-03 09:05:45 UTC 6,941 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1886],{96273:function(e,n,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/article/python/extract-accompaniment-using-spleeter",function(){return s(97101)}])},97101:function(e,n,s){"use strict";s.r(n),s.d(n,{default:function(){return v}});var r=s(85893),t=s(67294),l=s(9008),i=s.n(l),a=s(26219),o=s(72253),c=s(14932),p=s(11151),d=s(57307),h=s(41577),u=s(52856),x=function(e){var n=(0,t.useRef)(null),s=(0,t.useRef)(null);return(0,r.jsxs)(t.Fragment,{children:[(0,r.jsx)("h4",{children:"原版音乐:《I love you 私の君》"}),(0,r.jsx)("audio",{src:"/media/extract-accompaniment-using-spleeter/1.mp4",controls:!0}),(0,r.jsx)("h4",{className:"mt-[12px]",children:"提取后的人声和伴奏"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"align-[21px]",children:"人声:"}),(0,r.jsx)("audio",{ref:n,src:"/media/extract-accompaniment-using-spleeter/vocals.wav",controls:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"align-[21px]",children:"伴奏:"}),(0,r.jsx)("audio",{ref:s,src:"/media/extract-accompaniment-using-spleeter/accompaniment.wav",controls:!0})]}),(0,r.jsxs)(u.ZP.Group,{className:"mt-[12px] mb-[16px]",children:[(0,r.jsx)(u.ZP,{type:"primary",onClick:function(e){n.current&&s.current&&(n.current.currentTime=s.current.currentTime=0,n.current.play(),s.current.play())},children:"同时播放"}),(0,r.jsx)(u.ZP,{onClick:function(e){n.current&&s.current&&(n.current.pause(),s.current.pause())},children:"暂停"})]})]})};function m(e){var n=(0,o._)({code:"code",div:"div",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul"},(0,p.a)(),e.components);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{children:"使用Spleeter提取伴奏"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(h.Z,{href:"https://github.com/deezer/spleeter",children:"Spleeter"}),"\n是由法国在线音乐流媒体服务提供商Deezer开源的分离音频库,可以将音频分离成人声、伴奏、鼓点、贝斯、钢琴等等。\n它是基于TensorFlow的深度学习模型,可以在CPU或GPU上运行。它的分离效果非常好,可以说是目前最好的分离音频库了。"]}),"\n",(0,r.jsx)(n.h2,{children:"安装流程"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"安装pyenv(可选)"}),"\n",(0,r.jsx)(n.p,{children:"Spleeter要求Python版本为3.7 - 3.10,所以我们需要安装pyenv或venv来管理Python版本。"}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"安装python:推荐版本为v3.10.5。"}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"安装FFmpeg"}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"使用pip安装Spleeter"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"/path/to/.pyenv/pyenv-win/versions/3.10.5/python.exe -m pip install spleeter\n"})}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"安装libsndfile"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Windows系统在",(0,r.jsx)(h.Z,{href:"http://www.mega-nerd.com/libsndfile/#Download",children:"http://www.mega-nerd.com/libsndfile/#Download"}),"下载。"]}),"\n",(0,r.jsxs)(n.li,{children:["使用brew下载:","\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"brew install libsndfile\n"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{children:"使用Spleeter提取伴奏"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"通过执行命令来提取伴奏"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"python.exe -m spleeter separate -p spleeter:2stems -o /path/to/output /path/to/audio.mp3\n"})}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"通过python执行代码(代码由AI生成)"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"import spleeter\n\n# Separate vocals and accompaniment from an audio file\nseparator = spleeter.Separator('spleeter:2stems')\nseparator.separate_to_file('path/to/audio/file', 'output/path')\n\n# Separate vocals, drums, bass, and other from an audio file\nseparator = spleeter.Separator('spleeter:4stems')\nseparator.separate_to_file('path/to/audio/file', 'output/path')\n\n# Separate vocals, drums, bass, piano, and other from an audio file\nseparator = spleeter.Separator('spleeter:5stems')\nseparator.separate_to_file('path/to/audio/file', 'output/path')\n"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{children:"提取效果"}),"\n",(0,r.jsx)(x,{}),"\n",(0,r.jsx)(d.Z,{type:"info",message:[(0,r.jsx)(n.div,{className:"mb-0 py-[8px] text-[16px]",children:"参考地址:"},"cankaodizhi"),(0,r.jsxs)(n.div,{className:"py-[8px]",children:["Python audiolab install, unable to install (or find) libsndfile on Mac OSX:",(0,r.jsx)(h.Z,{href:"https://stackoverflow.com/questions/13999790/python-audiolab-install-unable-to-install-or-find-libsndfile-on-mac-osx",children:"https://stackoverflow.com/questions/13999790/python-audiolab-install-unable-to-install-or-find-libsndfile-on-mac-osx"})]},"WebRTC_API")]})]})}function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,o._)({},(0,p.a)(),e.components).wrapper;return n?(0,r.jsx)(n,(0,c._)((0,o._)({},e),{children:(0,r.jsx)(m,(0,o._)({},e))})):m(e)}var f=function(e){return(0,r.jsx)(a.Z,{children:(0,r.jsx)(j,{})})};function v(e){return(0,r.jsxs)(t.Fragment,{children:[(0,r.jsxs)(i(),{children:[(0,r.jsx)("title",{children:"使用Spleeter提取伴奏"}),(0,r.jsx)("meta",{name:"keywords",content:"视频, 媒体"}),(0,r.jsx)("meta",{name:"description",content:"使用Spleeter提取伴奏"})]}),(0,r.jsx)(f,{})]})}},94914:function(e,n,s){"use strict";var r=s(85893),t=s(73935),l=s(39332),i=s(39738),a=s(52856),o=s(70612),c=s(30448),p=s(76467),d=s(1294),h=s.n(d),u=i.Z.BackTop;n.Z=function(e){var n=(0,l.useRouter)();return[(0,r.jsxs)("div",{className:h().main,children:[e.goBack?(0,r.jsx)("div",{className:"mb-[16px] text-right",children:(0,r.jsxs)(a.ZP,{onClick:function(e){n.push("/")},children:[(0,r.jsx)(c.Z,{className:"mr-[6px]"}),"返回"]})}):null,null==e?void 0:e.children]},"main"),(null==e?void 0:e.goToTop)?(0,r.jsx)(p.default,{children:"object"==typeof document?(0,t.createPortal)((0,r.jsx)(u,{type:"primary",icon:(0,r.jsx)(o.Z,{}),title:"返回顶部",tabIndex:0,role:"button","aria-label":"返回顶部"}),document.body):null},"backTop"):null]}},26219:function(e,n,s){"use strict";var r=s(85893),t=s(66252),l=s(94914);n.Z=function(e){return(0,r.jsx)(l.Z,{goToTop:!0,goBack:!0,children:(0,r.jsx)(t.Z,{children:e.children})})}},1294:function(e){e.exports={main:"main_main__IZXSv",goToTop:"main_goToTop__Py8c8"}}},function(e){e.O(0,[2856,8375,7307,2888,9774,179],function(){return e(e.s=96273)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.