import{s as ge,o as $e,n as _e}from"../chunks/scheduler.182ea377.js";import{S as be,i as we,g as p,s as o,r as v,A as ve,h as d,f as n,c as r,j as L,u as T,x as J,k as S,y as m,a as i,v as y,d as M,t as D,w as P}from"../chunks/index.abf12888.js";import{T as Te}from"../chunks/Tip.230e2334.js";import{D as re}from"../chunks/Docstring.93f6f462.js";import{C as ye}from"../chunks/CodeBlock.57fe6e13.js";import{E as Me}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as le}from"../chunks/Heading.16916d63.js";function De(X){let s,g='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=p("p"),s.innerHTML=g},l(l){s=d(l,"P",{"data-svelte-h":!0}),J(s)!=="svelte-1wmc0l4"&&(s.innerHTML=g)},m(l,u){i(l,s,u)},p:_e,d(l){l&&n(s)}}}function Pe(X){let s,g="Example:",l,u,c;return u=new ye({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBZnJvbSUyMHNjaXB5LmlvLndhdmZpbGUlMjBpbXBvcnQlMjB3cml0ZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyaGFybW9uYWklMkZtYWVzdHJvLTE1MGslMjIlMEFwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKSUwQXBpcGUlMjAlM0QlMjBwaXBlLnRvKCUyMmN1ZGElMjIpJTBBJTBBYXVkaW9zJTIwJTNEJTIwcGlwZShhdWRpb19sZW5ndGhfaW5fcyUzRDQuMCkuYXVkaW9zJTBBJTBBJTIzJTIwVG8lMjBzYXZlJTIwbG9jYWxseSUwQWZvciUyMGklMkMlMjBhdWRpbyUyMGluJTIwZW51bWVyYXRlKGF1ZGlvcyklM0ElMEElMjAlMjAlMjAlMjB3cml0ZShmJTIybWFlc3Ryb190ZXN0XyU3QmklN0Qud2F2JTIyJTJDJTIwcGlwZS51bmV0LnNhbXBsZV9yYXRlJTJDJTIwYXVkaW8udHJhbnNwb3NlKCkpJTBBJTBBJTIzJTIwVG8lMjBkaXNsYXklMjBpbiUyMGdvb2dsZSUyMGNvbGFiJTBBaW1wb3J0JTIwSVB5dGhvbi5kaXNwbGF5JTIwYXMlMjBpcGQlMEElMEFmb3IlMjBhdWRpbyUyMGluJTIwYXVkaW9zJTNBJTBBJTIwJTIwJTIwJTIwZGlzcGxheShpcGQuQXVkaW8oYXVkaW8lMkMlMjByYXRlJTNEcGlwZS51bmV0LnNhbXBsZV9yYXRlKSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">from</span> scipy.io.wavfile <span class="hljs-keyword">import</span> write

model_id = <span class="hljs-string">&quot;harmonai/maestro-150k&quot;</span>
pipe = DiffusionPipeline.from_pretrained(model_id)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

audios = pipe(audio_length_in_s=<span class="hljs-number">4.0</span>).audios

<span class="hljs-comment"># To save locally</span>
<span class="hljs-keyword">for</span> i, audio <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(audios):
    write(<span class="hljs-string">f&quot;maestro_test_<span class="hljs-subst">{i}</span>.wav&quot;</span>, pipe.unet.sample_rate, audio.transpose())

<span class="hljs-comment"># To dislay in google colab</span>
<span class="hljs-keyword">import</span> IPython.display <span class="hljs-keyword">as</span> ipd

<span class="hljs-keyword">for</span> audio <span class="hljs-keyword">in</span> audios:
    display(ipd.Audio(audio, rate=pipe.unet.sample_rate))`,wrap:!1}}),{c(){s=p("p"),s.textContent=g,l=o(),v(u.$$.fragment)},l(a){s=d(a,"P",{"data-svelte-h":!0}),J(s)!=="svelte-11lpom8"&&(s.textContent=g),l=r(a),T(u.$$.fragment,a)},m(a,h){i(a,s,h),i(a,l,h),y(u,a,h),c=!0},p:_e,i(a){c||(M(u.$$.fragment,a),c=!0)},o(a){D(u.$$.fragment,a),c=!1},d(a){a&&(n(s),n(l)),P(u,a)}}}function Je(X){let s,g,l,u,c,a,h,pe='<a href="https://github.com/Harmonai-org/sample-generator" rel="nofollow">Dance Diffusion</a> is by Zach Evans.',z,B,de='Dance Diffusion is the first in a suite of generative audio tools for producers and musicians released by <a href="https://github.com/Harmonai-org" rel="nofollow">Harmonai</a>.',H,j,ue='The original codebase of this implementation can be found at <a href="https://github.com/Harmonai-org/sample-generator" rel="nofollow">Harmonai-org</a>.',O,x,Y,G,R,f,I,te,E,fe="Pipeline for audio generation.",ne,N,ce=`This model inherits from <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,se,$,Z,ie,U,me="The call function to the pipeline for generation.",ae,k,Q,C,q,b,V,oe,W,he="Output class for audio pipelines.",F,A,K;return c=new le({props:{title:"Dance Diffusion",local:"dance-diffusion",headingTag:"h1"}}),x=new Te({props:{$$slots:{default:[De]},$$scope:{ctx:X}}}),G=new le({props:{title:"DanceDiffusionPipeline",local:"diffusers.DanceDiffusionPipeline",headingTag:"h2"}}),I=new re({props:{name:"class diffusers.DanceDiffusionPipeline",anchor:"diffusers.DanceDiffusionPipeline",parameters:[{name:"unet",val:""},{name:"scheduler",val:""}],parametersDescription:[{anchor:"diffusers.DanceDiffusionPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet#diffusers.UNet1DModel">UNet1DModel</a>) &#x2014;
A <code>UNet1DModel</code> to denoise the encoded audio.`,name:"unet"},{anchor:"diffusers.DanceDiffusionPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded audio latents. Can be one of
<a href="/docs/diffusers/main/en/api/schedulers/ipndm#diffusers.IPNDMScheduler">IPNDMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/dance_diffusion/pipeline_dance_diffusion.py#L28"}}),Z=new re({props:{name:"__call__",anchor:"diffusers.DanceDiffusionPipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"num_inference_steps",val:": int = 100"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"audio_length_in_s",val:": typing.Optional[float] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DanceDiffusionPipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of audio samples to generate.`,name:"batch_size"},{anchor:"diffusers.DanceDiffusionPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher-quality audio sample at
the expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.DanceDiffusionPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.DanceDiffusionPipeline.__call__.audio_length_in_s",description:`<strong>audio_length_in_s</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size/self.unet.config.sample_rate</code>) &#x2014;
The length of the generated audio sample in seconds.`,name:"audio_length_in_s"},{anchor:"diffusers.DanceDiffusionPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/pipelines/dance_diffusion#diffusers.AudioPipelineOutput">AudioPipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/dance_diffusion/pipeline_dance_diffusion.py#L48",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/dance_diffusion#diffusers.AudioPipelineOutput"
>AudioPipelineOutput</a> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated audio.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/pipelines/dance_diffusion#diffusers.AudioPipelineOutput"
>AudioPipelineOutput</a> or <code>tuple</code></p>
`}}),k=new Me({props:{anchor:"diffusers.DanceDiffusionPipeline.__call__.example",$$slots:{default:[Pe]},$$scope:{ctx:X}}}),C=new le({props:{title:"AudioPipelineOutput",local:"diffusers.AudioPipelineOutput",headingTag:"h2"}}),V=new re({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#L124"}}),{c(){s=p("meta"),g=o(),l=p("p"),u=o(),v(c.$$.fragment),a=o(),h=p("p"),h.innerHTML=pe,z=o(),B=p("p"),B.innerHTML=de,H=o(),j=p("p"),j.innerHTML=ue,O=o(),v(x.$$.fragment),Y=o(),v(G.$$.fragment),R=o(),f=p("div"),v(I.$$.fragment),te=o(),E=p("p"),E.textContent=fe,ne=o(),N=p("p"),N.innerHTML=ce,se=o(),$=p("div"),v(Z.$$.fragment),ie=o(),U=p("p"),U.textContent=me,ae=o(),v(k.$$.fragment),Q=o(),v(C.$$.fragment),q=o(),b=p("div"),v(V.$$.fragment),oe=o(),W=p("p"),W.textContent=he,F=o(),A=p("p"),this.h()},l(e){const t=ve("svelte-u9bgzb",document.head);s=d(t,"META",{name:!0,content:!0}),t.forEach(n),g=r(e),l=d(e,"P",{}),L(l).forEach(n),u=r(e),T(c.$$.fragment,e),a=r(e),h=d(e,"P",{"data-svelte-h":!0}),J(h)!=="svelte-z4ffbo"&&(h.innerHTML=pe),z=r(e),B=d(e,"P",{"data-svelte-h":!0}),J(B)!=="svelte-dzyais"&&(B.innerHTML=de),H=r(e),j=d(e,"P",{"data-svelte-h":!0}),J(j)!=="svelte-w5ho4d"&&(j.innerHTML=ue),O=r(e),T(x.$$.fragment,e),Y=r(e),T(G.$$.fragment,e),R=r(e),f=d(e,"DIV",{class:!0});var _=L(f);T(I.$$.fragment,_),te=r(_),E=d(_,"P",{"data-svelte-h":!0}),J(E)!=="svelte-1jvczvp"&&(E.textContent=fe),ne=r(_),N=d(_,"P",{"data-svelte-h":!0}),J(N)!=="svelte-496sm0"&&(N.innerHTML=ce),se=r(_),$=d(_,"DIV",{class:!0});var w=L($);T(Z.$$.fragment,w),ie=r(w),U=d(w,"P",{"data-svelte-h":!0}),J(U)!=="svelte-50j04k"&&(U.textContent=me),ae=r(w),T(k.$$.fragment,w),w.forEach(n),_.forEach(n),Q=r(e),T(C.$$.fragment,e),q=r(e),b=d(e,"DIV",{class:!0});var ee=L(b);T(V.$$.fragment,ee),oe=r(ee),W=d(ee,"P",{"data-svelte-h":!0}),J(W)!=="svelte-19ryw33"&&(W.textContent=he),ee.forEach(n),F=r(e),A=d(e,"P",{}),L(A).forEach(n),this.h()},h(){S(s,"name","hf:doc:metadata"),S(s,"content",xe),S($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(b,"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){m(document.head,s),i(e,g,t),i(e,l,t),i(e,u,t),y(c,e,t),i(e,a,t),i(e,h,t),i(e,z,t),i(e,B,t),i(e,H,t),i(e,j,t),i(e,O,t),y(x,e,t),i(e,Y,t),y(G,e,t),i(e,R,t),i(e,f,t),y(I,f,null),m(f,te),m(f,E),m(f,ne),m(f,N),m(f,se),m(f,$),y(Z,$,null),m($,ie),m($,U),m($,ae),y(k,$,null),i(e,Q,t),y(C,e,t),i(e,q,t),i(e,b,t),y(V,b,null),m(b,oe),m(b,W),i(e,F,t),i(e,A,t),K=!0},p(e,[t]){const _={};t&2&&(_.$$scope={dirty:t,ctx:e}),x.$set(_);const w={};t&2&&(w.$$scope={dirty:t,ctx:e}),k.$set(w)},i(e){K||(M(c.$$.fragment,e),M(x.$$.fragment,e),M(G.$$.fragment,e),M(I.$$.fragment,e),M(Z.$$.fragment,e),M(k.$$.fragment,e),M(C.$$.fragment,e),M(V.$$.fragment,e),K=!0)},o(e){D(c.$$.fragment,e),D(x.$$.fragment,e),D(G.$$.fragment,e),D(I.$$.fragment,e),D(Z.$$.fragment,e),D(k.$$.fragment,e),D(C.$$.fragment,e),D(V.$$.fragment,e),K=!1},d(e){e&&(n(g),n(l),n(u),n(a),n(h),n(z),n(B),n(H),n(j),n(O),n(Y),n(R),n(f),n(Q),n(q),n(b),n(F),n(A)),n(s),P(c,e),P(x,e),P(G,e),P(I),P(Z),P(k),P(C,e),P(V)}}}const xe='{"title":"Dance Diffusion","local":"dance-diffusion","sections":[{"title":"DanceDiffusionPipeline","local":"diffusers.DanceDiffusionPipeline","sections":[],"depth":2},{"title":"AudioPipelineOutput","local":"diffusers.AudioPipelineOutput","sections":[],"depth":2}],"depth":1}';function ke(X){return $e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xe extends be{constructor(s){super(),we(this,s,ke,Je,ge,{})}}export{Xe as component};
