import{s as ce,o as he,n as ge}from"../chunks/scheduler.182ea377.js";import{S as $e,i as ve,g as o,s as a,r as C,A as we,h as l,f as i,c as r,j as N,u as I,x as c,k as j,y as S,a as n,v as A,d as L,t as H,w as E}from"../chunks/index.abf12888.js";import{T as _e}from"../chunks/Tip.230e2334.js";import{D as ae}from"../chunks/Docstring.93f6f462.js";import{H as re}from"../chunks/Heading.16916d63.js";function be(G){let s,h='Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-components-across-pipelines">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.';return{c(){s=o("p"),s.innerHTML=h},l(f){s=l(f,"P",{"data-svelte-h":!0}),c(s)!=="svelte-1wmc0l4"&&(s.innerHTML=h)},m(f,k){n(f,s,k)},p:ge,d(f){f&&i(s)}}}function ye(G){let s,h,f,k,g,F,$,oe='<a href="https://huggingface.co/papers/2206.05408" rel="nofollow">Spectrogram Diffusion</a> is by Curtis Hawthorne, Ian Simon, Adam Roberts, Neil Zeghidour, Josh Gardner, Ethan Manilow, and Jesse Engel.',R,v,le="<em>An ideal music synthesizer should be both interactive and expressive, generating high-fidelity audio in realtime for arbitrary combinations of instruments and notes. Recent neural synthesizers have exhibited a tradeoff between domain-specific models that offer detailed control of only specific instruments, or raw waveform models that can train on any music but with minimal control and slow generation. In this work, we focus on a middle ground of neural synthesizers that can generate audio from MIDI sequences with arbitrary combinations of instruments in realtime. This enables training on a wide range of transcription datasets with a single model, which in turn offers note-level control of composition and instrumentation across a wide range of instruments. We use a simple two-stage process: MIDI to spectrograms with an encoder-decoder Transformer, then spectrograms to audio with a generative adversarial network (GAN) spectrogram inverter. We compare training the decoder as an autoregressive model and as a Denoising Diffusion Probabilistic Model (DDPM) and find that the DDPM approach is superior both qualitatively and as measured by audio reconstruction and Fréchet distance metrics. Given the interactivity and generality of this approach, we find this to be a promising first step towards interactive and expressive neural synthesis for arbitrary combinations of instruments and notes.</em>",V,w,fe='The original codebase can be found at <a href="https://github.com/magenta/music-spectrogram-diffusion" rel="nofollow">magenta/music-spectrogram-diffusion</a>.',J,_,pe='<img src="https://storage.googleapis.com/music-synthesis-with-spectrogram-diffusion/architecture.png" alt="img"/>',W,b,de="As depicted above the model takes as input a MIDI file and tokenizes it into a sequence of 5 second intervals. Each tokenized interval then together with positional encodings is passed through the Note Encoder and its representation is concatenated with the previous window’s generated spectrogram representation obtained via the Context Encoder. For the initial 5 second window this is set to zero. The resulting context is then used as conditioning to sample the denoised Spectrogram from the MIDI window and we concatenate this spectrogram to the final output as well as use it for the context of the next MIDI window. The process repeats till we have gone over all the MIDI inputs. Finally a MelGAN decoder converts the potentially long spectrogram to audio which is the final result of this pipeline.",U,u,Z,y,B,p,x,ie,m,P,ne,z,ue="Call self as a function.",K,D,Q,d,M,se,O,me="Output class for audio pipelines.",X,q,Y;return g=new re({props:{title:"Spectrogram Diffusion",local:"spectrogram-diffusion",headingTag:"h1"}}),u=new _e({props:{$$slots:{default:[be]},$$scope:{ctx:G}}}),y=new re({props:{title:"SpectrogramDiffusionPipeline",local:"diffusers.SpectrogramDiffusionPipeline",headingTag:"h2"}}),x=new ae({props:{name:"class diffusers.SpectrogramDiffusionPipeline",anchor:"diffusers.SpectrogramDiffusionPipeline",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/dummy_transformers_and_torch_and_note_seq_objects.py#L5"}}),P=new ae({props:{name:"__call__",anchor:"diffusers.SpectrogramDiffusionPipeline.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}]}}),D=new re({props:{title:"AudioPipelineOutput",local:"diffusers.AudioPipelineOutput",headingTag:"h2"}}),M=new ae({props:{name:"class diffusers.AudioPipelineOutput",anchor:"diffusers.AudioPipelineOutput",parameters:[{name:"audios",val:": ndarray"}],parametersDescription:[{anchor:"diffusers.AudioPipelineOutput.audios",description:`<strong>audios</strong> (<code>np.ndarray</code>) &#x2014;
List of denoised audio samples of a NumPy array of shape <code>(batch_size, num_channels, sample_rate)</code>.`,name:"audios"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L125"}}),{c(){s=o("meta"),h=a(),f=o("p"),k=a(),C(g.$$.fragment),F=a(),$=o("p"),$.innerHTML=oe,R=a(),v=o("p"),v.innerHTML=le,V=a(),w=o("p"),w.innerHTML=fe,J=a(),_=o("p"),_.innerHTML=pe,W=a(),b=o("p"),b.textContent=de,U=a(),C(u.$$.fragment),Z=a(),C(y.$$.fragment),B=a(),p=o("div"),C(x.$$.fragment),ie=a(),m=o("div"),C(P.$$.fragment),ne=a(),z=o("p"),z.textContent=ue,K=a(),C(D.$$.fragment),Q=a(),d=o("div"),C(M.$$.fragment),se=a(),O=o("p"),O.textContent=me,X=a(),q=o("p"),this.h()},l(e){const t=we("svelte-u9bgzb",document.head);s=l(t,"META",{name:!0,content:!0}),t.forEach(i),h=r(e),f=l(e,"P",{}),N(f).forEach(i),k=r(e),I(g.$$.fragment,e),F=r(e),$=l(e,"P",{"data-svelte-h":!0}),c($)!=="svelte-1tf296s"&&($.innerHTML=oe),R=r(e),v=l(e,"P",{"data-svelte-h":!0}),c(v)!=="svelte-prtjfk"&&(v.innerHTML=le),V=r(e),w=l(e,"P",{"data-svelte-h":!0}),c(w)!=="svelte-519pxd"&&(w.innerHTML=fe),J=r(e),_=l(e,"P",{"data-svelte-h":!0}),c(_)!=="svelte-1xdv57j"&&(_.innerHTML=pe),W=r(e),b=l(e,"P",{"data-svelte-h":!0}),c(b)!=="svelte-1xhf7qc"&&(b.textContent=de),U=r(e),I(u.$$.fragment,e),Z=r(e),I(y.$$.fragment,e),B=r(e),p=l(e,"DIV",{class:!0});var T=N(p);I(x.$$.fragment,T),ie=r(T),m=l(T,"DIV",{class:!0});var ee=N(m);I(P.$$.fragment,ee),ne=r(ee),z=l(ee,"P",{"data-svelte-h":!0}),c(z)!=="svelte-1eed40t"&&(z.textContent=ue),ee.forEach(i),T.forEach(i),K=r(e),I(D.$$.fragment,e),Q=r(e),d=l(e,"DIV",{class:!0});var te=N(d);I(M.$$.fragment,te),se=r(te),O=l(te,"P",{"data-svelte-h":!0}),c(O)!=="svelte-19ryw33"&&(O.textContent=me),te.forEach(i),X=r(e),q=l(e,"P",{}),N(q).forEach(i),this.h()},h(){j(s,"name","hf:doc:metadata"),j(s,"content",xe),j(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){S(document.head,s),n(e,h,t),n(e,f,t),n(e,k,t),A(g,e,t),n(e,F,t),n(e,$,t),n(e,R,t),n(e,v,t),n(e,V,t),n(e,w,t),n(e,J,t),n(e,_,t),n(e,W,t),n(e,b,t),n(e,U,t),A(u,e,t),n(e,Z,t),A(y,e,t),n(e,B,t),n(e,p,t),A(x,p,null),S(p,ie),S(p,m),A(P,m,null),S(m,ne),S(m,z),n(e,K,t),A(D,e,t),n(e,Q,t),n(e,d,t),A(M,d,null),S(d,se),S(d,O),n(e,X,t),n(e,q,t),Y=!0},p(e,[t]){const T={};t&2&&(T.$$scope={dirty:t,ctx:e}),u.$set(T)},i(e){Y||(L(g.$$.fragment,e),L(u.$$.fragment,e),L(y.$$.fragment,e),L(x.$$.fragment,e),L(P.$$.fragment,e),L(D.$$.fragment,e),L(M.$$.fragment,e),Y=!0)},o(e){H(g.$$.fragment,e),H(u.$$.fragment,e),H(y.$$.fragment,e),H(x.$$.fragment,e),H(P.$$.fragment,e),H(D.$$.fragment,e),H(M.$$.fragment,e),Y=!1},d(e){e&&(i(h),i(f),i(k),i(F),i($),i(R),i(v),i(V),i(w),i(J),i(_),i(W),i(b),i(U),i(Z),i(B),i(p),i(K),i(Q),i(d),i(X),i(q)),i(s),E(g,e),E(u,e),E(y,e),E(x),E(P),E(D,e),E(M)}}}const xe='{"title":"Spectrogram Diffusion","local":"spectrogram-diffusion","sections":[{"title":"SpectrogramDiffusionPipeline","local":"diffusers.SpectrogramDiffusionPipeline","sections":[],"depth":2},{"title":"AudioPipelineOutput","local":"diffusers.AudioPipelineOutput","sections":[],"depth":2}],"depth":1}';function Pe(G){return he(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Se extends $e{constructor(s){super(),ve(this,s,Pe,ye,ce,{})}}export{Se as component};
