import{S as Qo,i as en,s as tn,e as n,k as d,w as $,t as i,M as on,c as a,d as o,m as p,a as s,x as k,h as r,b as u,G as t,g as c,y as P,q as A,o as U,B as C,v as nn,L as an}from"../../../chunks/vendor-hf-doc-builder.js";import{T as sn}from"../../../chunks/Tip-hf-doc-builder.js";import{D as pt}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as rn}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as bo}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ln}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function cn(de){let m,w,h,g,v,f,M,j;return{c(){m=n("p"),w=i("Make sure to check out the Schedulers "),h=n("a"),g=i("guide"),v=i(` to learn how to explore the tradeoff between
scheduler speed and quality, and see the `),f=n("a"),M=i("reuse components across pipelines"),j=i(`
section to learn how to efficiently load the same components into multiple pipelines.`),this.h()},l(S){m=a(S,"P",{});var y=s(m);w=r(y,"Make sure to check out the Schedulers "),h=a(y,"A",{href:!0});var x=s(h);g=r(x,"guide"),x.forEach(o),v=r(y,` to learn how to explore the tradeoff between
scheduler speed and quality, and see the `),f=a(y,"A",{href:!0});var pe=s(f);M=r(pe,"reuse components across pipelines"),pe.forEach(o),j=r(y,`
section to learn how to efficiently load the same components into multiple pipelines.`),y.forEach(o),this.h()},h(){u(h,"href","/using-diffusers/schedulers"),u(f,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(S,y){c(S,m,y),t(m,w),t(m,h),t(h,g),t(m,v),t(m,f),t(f,M),t(m,j)},d(S){S&&o(m)}}}function dn(de){let m,w,h,g,v;return g=new rn({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyME11c2ljTERNUGlwZWxpbmUlMEFpbXBvcnQlMjB0b3JjaCUwQWltcG9ydCUyMHNjaXB5JTBBJTBBcmVwb19pZCUyMCUzRCUyMCUyMmN2c3NwJTJGYXVkaW9sZG0tcy1mdWxsLXYyJTIyJTBBcGlwZSUyMCUzRCUyME11c2ljTERNUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKHJlcG9faWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZSUyMCUzRCUyMHBpcGUudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJUZWNobm8lMjBtdXNpYyUyMHdpdGglMjBhJTIwc3Ryb25nJTJDJTIwdXBiZWF0JTIwdGVtcG8lMjBhbmQlMjBoaWdoJTIwbWVsb2RpYyUyMHJpZmZzJTIyJTBBYXVkaW8lMjAlM0QlMjBwaXBlKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxMCUyQyUyMGF1ZGlvX2xlbmd0aF9pbl9zJTNENS4wKS5hdWRpb3MlNUIwJTVEJTBBJTBBJTIzJTIwc2F2ZSUyMHRoZSUyMGF1ZGlvJTIwc2FtcGxlJTIwYXMlMjBhJTIwLndhdiUyMGZpbGUlMEFzY2lweS5pby53YXZmaWxlLndyaXRlKCUyMnRlY2huby53YXYlMjIlMkMlMjByYXRlJTNEMTYwMDAlMkMlMjBkYXRhJTNEYXVkaW8p",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> MusicLDMPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> scipy

<span class="hljs-meta">&gt;&gt;&gt; </span>repo_id = <span class="hljs-string">&quot;cvssp/audioldm-s-full-v2&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = MusicLDMPipeline.from_pretrained(repo_id, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Techno music with a strong, upbeat tempo and high melodic riffs&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>audio = pipe(prompt, num_inference_steps=<span class="hljs-number">10</span>, audio_length_in_s=<span class="hljs-number">5.0</span>).audios[<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># save the audio sample as a .wav file</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>scipy.io.wavfile.write(<span class="hljs-string">&quot;techno.wav&quot;</span>, rate=<span class="hljs-number">16000</span>, data=audio)`}}),{c(){m=n("p"),w=i("Examples:"),h=d(),$(g.$$.fragment)},l(f){m=a(f,"P",{});var M=s(m);w=r(M,"Examples:"),M.forEach(o),h=p(f),k(g.$$.fragment,f)},m(f,M){c(f,m,M),t(m,w),c(f,h,M),P(g,f,M),v=!0},p:an,i(f){v||(A(g.$$.fragment,f),v=!0)},o(f){U(g.$$.fragment,f),v=!1},d(f){f&&o(m),f&&o(h),C(g,f)}}}function pn(de){let m,w,h,g,v,f,M,j,S,y,x,pe,R,ut,ft,qe,b,mt,Y,ht,gt,O,_t,vt,we,Mt,bt,X,yt,wt,Je,ue,Dt,Ve,fe,xt,ze,me,De,Lt,Fe,q,Tt,K,Et,$t,We,N,J,xe,Q,kt,Le,Pt,Ze,he,At,He,V,Te,Ut,Ct,ee,jt,Ee,St,Nt,Re,ge,It,Ye,L,I,Bt,$e,Gt,qt,ke,Jt,Vt,zt,te,Ft,Pe,Wt,Zt,Ht,B,Rt,Ae,Yt,Ot,Ue,Xt,Kt,Oe,z,Xe,G,F,Ce,oe,Qt,je,eo,Ke,_,ne,to,Se,oo,no,ae,ao,_e,so,io,ro,T,se,lo,Ne,co,po,W,uo,Z,ie,fo,re,mo,Ie,ho,go,_o,H,le,vo,Be,Mo,Qe;return f=new bo({}),Q=new bo({}),z=new sn({props:{$$slots:{default:[cn]},$$scope:{ctx:de}}}),oe=new bo({}),ne=new pt({props:{name:"class diffusers.MusicLDMPipeline",anchor:"diffusers.MusicLDMPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": typing.Union[transformers.models.clap.modeling_clap.ClapTextModelWithProjection, transformers.models.clap.modeling_clap.ClapModel]"},{name:"tokenizer",val:": typing.Union[transformers.models.roberta.tokenization_roberta.RobertaTokenizer, transformers.models.roberta.tokenization_roberta_fast.RobertaTokenizerFast]"},{name:"feature_extractor",val:": typing.Optional[transformers.models.clap.feature_extraction_clap.ClapFeatureExtractor]"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"vocoder",val:": SpeechT5HifiGan"}],parametersDescription:[{anchor:"diffusers.MusicLDMPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.21.0/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.MusicLDMPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>ClapModel</code>) &#x2014;
Frozen text-audio embedding model (<code>ClapTextModel</code>), specifically the
<a href="https://huggingface.co/laion/clap-htsat-unfused" rel="nofollow">laion/clap-htsat-unfused</a> variant.`,name:"text_encoder"},{anchor:"diffusers.MusicLDMPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>PreTrainedTokenizer</code>) &#x2014;
A <code>RobertaTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.MusicLDMPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>ClapFeatureExtractor</code>) &#x2014;
Feature extractor to compute mel-spectrograms from audio waveforms.`,name:"feature_extractor"},{anchor:"diffusers.MusicLDMPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.21.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded audio latents.`,name:"unet"},{anchor:"diffusers.MusicLDMPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.21.0/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/v0.21.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.21.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.21.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.MusicLDMPipeline.vocoder",description:`<strong>vocoder</strong> (<code>SpeechT5HifiGan</code>) &#x2014;
Vocoder of class <code>SpeechT5HifiGan</code>.`,name:"vocoder"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L67"}}),se=new pt({props:{name:"__call__",anchor:"diffusers.MusicLDMPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"audio_length_in_s",val:": typing.Optional[float] = None"},{name:"num_inference_steps",val:": int = 200"},{name:"guidance_scale",val:": float = 2.0"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"num_waveforms_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": typing.Optional[int] = 1"},{name:"cross_attention_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"output_type",val:": typing.Optional[str] = 'np'"}],parametersDescription:[{anchor:"diffusers.MusicLDMPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide audio generation. If not defined, you need to pass <code>prompt_embeds</code>.`,name:"prompt"},{anchor:"diffusers.MusicLDMPipeline.__call__.audio_length_in_s",description:`<strong>audio_length_in_s</strong> (<code>int</code>, <em>optional</em>, defaults to 10.24) &#x2014;
The length of the generated audio sample in seconds.`,name:"audio_length_in_s"},{anchor:"diffusers.MusicLDMPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 200) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality audio at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.MusicLDMPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 2.0) &#x2014;
A higher guidance scale value encourages the model to generate audio that is closely linked to the text
<code>prompt</code> at the expense of lower sound quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.MusicLDMPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in audio generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.MusicLDMPipeline.__call__.num_waveforms_per_prompt",description:`<strong>num_waveforms_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of waveforms to generate per prompt. If <code>num_waveforms_per_prompt &gt; 1</code>, the text encoding
model is a joint text-audio model (<code>ClapModel</code>), and the tokenizer is a
<code>[~transformers.ClapProcessor]</code>, then automatic scoring will be performed between the generated outputs
and the input text. This scoring ranks the generated waveforms based on their cosine similarity to text
input in the joint text-audio embedding space.`,name:"num_waveforms_per_prompt"},{anchor:"diffusers.MusicLDMPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/v0.21.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.MusicLDMPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[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.MusicLDMPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.MusicLDMPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.MusicLDMPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If
not provided, <code>negative_prompt_embeds</code> are generated from the <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.MusicLDMPipeline.__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/v0.21.0/en/api/pipelines/dance_diffusion#diffusers.AudioPipelineOutput">AudioPipelineOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.MusicLDMPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.MusicLDMPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function is called. If not specified, the callback is called at
every step.`,name:"callback_steps"},{anchor:"diffusers.MusicLDMPipeline.__call__.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow"><code>self.processor</code></a>.`,name:"cross_attention_kwargs"},{anchor:"diffusers.MusicLDMPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;np&quot;</code>) &#x2014;
The output format of the generated audio. Choose between <code>&quot;np&quot;</code> to return a NumPy <code>np.ndarray</code> or
<code>&quot;pt&quot;</code> to return a PyTorch <code>torch.Tensor</code> object. Set to <code>&quot;latent&quot;</code> to return the latent diffusion
model (LDM) output.`,name:"output_type"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L434",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.21.0/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:`
<p><a
  href="/docs/diffusers/v0.21.0/en/api/pipelines/dance_diffusion#diffusers.AudioPipelineOutput"
>AudioPipelineOutput</a> or <code>tuple</code></p>
`}}),W=new ln({props:{anchor:"diffusers.MusicLDMPipeline.__call__.example",$$slots:{default:[dn]},$$scope:{ctx:de}}}),ie=new pt({props:{name:"disable_vae_slicing",anchor:"diffusers.MusicLDMPipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L125"}}),le=new pt({props:{name:"enable_vae_slicing",anchor:"diffusers.MusicLDMPipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L117"}}),{c(){m=n("meta"),w=d(),h=n("h1"),g=n("a"),v=n("span"),$(f.$$.fragment),M=d(),j=n("span"),S=i("MusicLDM"),y=d(),x=n("p"),pe=i("MusicLDM was proposed in "),R=n("a"),ut=i("MusicLDM: Enhancing Novelty in Text-to-Music Generation Using Beat-Synchronous Mixup Strategies"),ft=i(` by Ke Chen, Yusong Wu, Haohe Liu, Marianna Nezhurina, Taylor Berg-Kirkpatrick, Shlomo Dubnov.
MusicLDM takes a text prompt as input and predicts the corresponding music sample.`),qe=d(),b=n("p"),mt=i("Inspired by "),Y=n("a"),ht=i("Stable Diffusion"),gt=i(" and "),O=n("a"),_t=i("AudioLDM"),vt=i(`,
MusicLDM is a text-to-music `),we=n("em"),Mt=i("latent diffusion model (LDM)"),bt=i(" that learns continuous audio representations from "),X=n("a"),yt=i("CLAP"),wt=i(`
latents.`),Je=d(),ue=n("p"),Dt=i(`MusicLDM is trained on a corpus of 466 hours of music data. Beat-synchronous data augmentation strategies are applied to
the music samples, both in the time domain and in the latent space. Using beat-synchronous data augmentation strategies
encourages the model to interpolate between the training samples, but stay within the domain of the training data. The
result is generated music that is more diverse while staying faithful to the corresponding style.`),Ve=d(),fe=n("p"),xt=i("The abstract of the paper is the following:"),ze=d(),me=n("p"),De=n("em"),Lt=i("In this paper, we present MusicLDM, a state-of-the-art text-to-music model that adapts Stable Diffusion and AudioLDM architectures to the music domain. We achieve this by retraining the contrastive language-audio pretraining model (CLAP) and the Hifi-GAN vocoder, as components of MusicLDM, on a collection of music data samples. Then, we leverage a beat tracking model and propose two different mixup strategies for data augmentation: beat-synchronous audio mixup and beat-synchronous latent mixup, to encourage the model to generate music more diverse while still staying faithful to the corresponding style."),Fe=d(),q=n("p"),Tt=i("This pipeline was contributed by "),K=n("a"),Et=i("sanchit-gandhi"),$t=i("."),We=d(),N=n("h2"),J=n("a"),xe=n("span"),$(Q.$$.fragment),kt=d(),Le=n("span"),Pt=i("Tips"),Ze=d(),he=n("p"),At=i("When constructing a prompt, keep in mind:"),He=d(),V=n("ul"),Te=n("li"),Ut=i("Descriptive prompt inputs work best; use adjectives to describe the sound (for example, \u201Chigh quality\u201D or \u201Cclear\u201D) and make the prompt context specific where possible (e.g. \u201Cmelodic techno with a fast beat and synths\u201D works better than \u201Ctechno\u201D)."),Ct=d(),ee=n("li"),jt=i("Using a "),Ee=n("em"),St=i("negative prompt"),Nt=i(" can significantly improve the quality of the generated audio. Try using a negative prompt of \u201Clow quality, average quality\u201D."),Re=d(),ge=n("p"),It=i("During inference:"),Ye=d(),L=n("ul"),I=n("li"),Bt=i("The "),$e=n("em"),Gt=i("quality"),qt=i(" of the generated audio sample can be controlled by the "),ke=n("code"),Jt=i("num_inference_steps"),Vt=i(" argument; higher steps give higher quality audio at the expense of slower inference."),zt=d(),te=n("li"),Ft=i("Multiple waveforms can be generated in one go: set "),Pe=n("code"),Wt=i("num_waveforms_per_prompt"),Zt=i(" to a value greater than 1 to enable. Automatic scoring will be performed between the generated waveforms and prompt text, and the audios ranked from best to worst accordingly."),Ht=d(),B=n("li"),Rt=i("The "),Ae=n("em"),Yt=i("length"),Ot=i(" of the generated audio sample can be controlled by varying the "),Ue=n("code"),Xt=i("audio_length_in_s"),Kt=i(" argument."),Oe=d(),$(z.$$.fragment),Xe=d(),G=n("h2"),F=n("a"),Ce=n("span"),$(oe.$$.fragment),Qt=d(),je=n("span"),eo=i("MusicLDMPipeline"),Ke=d(),_=n("div"),$(ne.$$.fragment),to=d(),Se=n("p"),oo=i("Pipeline for text-to-audio generation using MusicLDM."),no=d(),ae=n("p"),ao=i("This model inherits from "),_e=n("a"),so=i("DiffusionPipeline"),io=i(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),ro=d(),T=n("div"),$(se.$$.fragment),lo=d(),Ne=n("p"),co=i("The call function to the pipeline for generation."),po=d(),$(W.$$.fragment),uo=d(),Z=n("div"),$(ie.$$.fragment),fo=d(),re=n("p"),mo=i("Disable sliced VAE decoding. If "),Ie=n("code"),ho=i("enable_vae_slicing"),go=i(` was previously enabled, this method will go back to
computing decoding in one step.`),_o=d(),H=n("div"),$(le.$$.fragment),vo=d(),Be=n("p"),Mo=i(`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),this.h()},l(e){const l=on('[data-svelte="svelte-1phssyn"]',document.head);m=a(l,"META",{name:!0,content:!0}),l.forEach(o),w=p(e),h=a(e,"H1",{class:!0});var ce=s(h);g=a(ce,"A",{id:!0,class:!0,href:!0});var Ge=s(g);v=a(Ge,"SPAN",{});var yo=s(v);k(f.$$.fragment,yo),yo.forEach(o),Ge.forEach(o),M=p(ce),j=a(ce,"SPAN",{});var wo=s(j);S=r(wo,"MusicLDM"),wo.forEach(o),ce.forEach(o),y=p(e),x=a(e,"P",{});var et=s(x);pe=r(et,"MusicLDM was proposed in "),R=a(et,"A",{href:!0,rel:!0});var Do=s(R);ut=r(Do,"MusicLDM: Enhancing Novelty in Text-to-Music Generation Using Beat-Synchronous Mixup Strategies"),Do.forEach(o),ft=r(et,` by Ke Chen, Yusong Wu, Haohe Liu, Marianna Nezhurina, Taylor Berg-Kirkpatrick, Shlomo Dubnov.
MusicLDM takes a text prompt as input and predicts the corresponding music sample.`),et.forEach(o),qe=p(e),b=a(e,"P",{});var E=s(b);mt=r(E,"Inspired by "),Y=a(E,"A",{href:!0,rel:!0});var xo=s(Y);ht=r(xo,"Stable Diffusion"),xo.forEach(o),gt=r(E," and "),O=a(E,"A",{href:!0,rel:!0});var Lo=s(O);_t=r(Lo,"AudioLDM"),Lo.forEach(o),vt=r(E,`,
MusicLDM is a text-to-music `),we=a(E,"EM",{});var To=s(we);Mt=r(To,"latent diffusion model (LDM)"),To.forEach(o),bt=r(E," that learns continuous audio representations from "),X=a(E,"A",{href:!0,rel:!0});var Eo=s(X);yt=r(Eo,"CLAP"),Eo.forEach(o),wt=r(E,`
latents.`),E.forEach(o),Je=p(e),ue=a(e,"P",{});var $o=s(ue);Dt=r($o,`MusicLDM is trained on a corpus of 466 hours of music data. Beat-synchronous data augmentation strategies are applied to
the music samples, both in the time domain and in the latent space. Using beat-synchronous data augmentation strategies
encourages the model to interpolate between the training samples, but stay within the domain of the training data. The
result is generated music that is more diverse while staying faithful to the corresponding style.`),$o.forEach(o),Ve=p(e),fe=a(e,"P",{});var ko=s(fe);xt=r(ko,"The abstract of the paper is the following:"),ko.forEach(o),ze=p(e),me=a(e,"P",{});var Po=s(me);De=a(Po,"EM",{});var Ao=s(De);Lt=r(Ao,"In this paper, we present MusicLDM, a state-of-the-art text-to-music model that adapts Stable Diffusion and AudioLDM architectures to the music domain. We achieve this by retraining the contrastive language-audio pretraining model (CLAP) and the Hifi-GAN vocoder, as components of MusicLDM, on a collection of music data samples. Then, we leverage a beat tracking model and propose two different mixup strategies for data augmentation: beat-synchronous audio mixup and beat-synchronous latent mixup, to encourage the model to generate music more diverse while still staying faithful to the corresponding style."),Ao.forEach(o),Po.forEach(o),Fe=p(e),q=a(e,"P",{});var tt=s(q);Tt=r(tt,"This pipeline was contributed by "),K=a(tt,"A",{href:!0,rel:!0});var Uo=s(K);Et=r(Uo,"sanchit-gandhi"),Uo.forEach(o),$t=r(tt,"."),tt.forEach(o),We=p(e),N=a(e,"H2",{class:!0});var ot=s(N);J=a(ot,"A",{id:!0,class:!0,href:!0});var Co=s(J);xe=a(Co,"SPAN",{});var jo=s(xe);k(Q.$$.fragment,jo),jo.forEach(o),Co.forEach(o),kt=p(ot),Le=a(ot,"SPAN",{});var So=s(Le);Pt=r(So,"Tips"),So.forEach(o),ot.forEach(o),Ze=p(e),he=a(e,"P",{});var No=s(he);At=r(No,"When constructing a prompt, keep in mind:"),No.forEach(o),He=p(e),V=a(e,"UL",{});var nt=s(V);Te=a(nt,"LI",{});var Io=s(Te);Ut=r(Io,"Descriptive prompt inputs work best; use adjectives to describe the sound (for example, \u201Chigh quality\u201D or \u201Cclear\u201D) and make the prompt context specific where possible (e.g. \u201Cmelodic techno with a fast beat and synths\u201D works better than \u201Ctechno\u201D)."),Io.forEach(o),Ct=p(nt),ee=a(nt,"LI",{});var at=s(ee);jt=r(at,"Using a "),Ee=a(at,"EM",{});var Bo=s(Ee);St=r(Bo,"negative prompt"),Bo.forEach(o),Nt=r(at," can significantly improve the quality of the generated audio. Try using a negative prompt of \u201Clow quality, average quality\u201D."),at.forEach(o),nt.forEach(o),Re=p(e),ge=a(e,"P",{});var Go=s(ge);It=r(Go,"During inference:"),Go.forEach(o),Ye=p(e),L=a(e,"UL",{});var ve=s(L);I=a(ve,"LI",{});var Me=s(I);Bt=r(Me,"The "),$e=a(Me,"EM",{});var qo=s($e);Gt=r(qo,"quality"),qo.forEach(o),qt=r(Me," of the generated audio sample can be controlled by the "),ke=a(Me,"CODE",{});var Jo=s(ke);Jt=r(Jo,"num_inference_steps"),Jo.forEach(o),Vt=r(Me," argument; higher steps give higher quality audio at the expense of slower inference."),Me.forEach(o),zt=p(ve),te=a(ve,"LI",{});var st=s(te);Ft=r(st,"Multiple waveforms can be generated in one go: set "),Pe=a(st,"CODE",{});var Vo=s(Pe);Wt=r(Vo,"num_waveforms_per_prompt"),Vo.forEach(o),Zt=r(st," to a value greater than 1 to enable. Automatic scoring will be performed between the generated waveforms and prompt text, and the audios ranked from best to worst accordingly."),st.forEach(o),Ht=p(ve),B=a(ve,"LI",{});var be=s(B);Rt=r(be,"The "),Ae=a(be,"EM",{});var zo=s(Ae);Yt=r(zo,"length"),zo.forEach(o),Ot=r(be," of the generated audio sample can be controlled by varying the "),Ue=a(be,"CODE",{});var Fo=s(Ue);Xt=r(Fo,"audio_length_in_s"),Fo.forEach(o),Kt=r(be," argument."),be.forEach(o),ve.forEach(o),Oe=p(e),k(z.$$.fragment,e),Xe=p(e),G=a(e,"H2",{class:!0});var it=s(G);F=a(it,"A",{id:!0,class:!0,href:!0});var Wo=s(F);Ce=a(Wo,"SPAN",{});var Zo=s(Ce);k(oe.$$.fragment,Zo),Zo.forEach(o),Wo.forEach(o),Qt=p(it),je=a(it,"SPAN",{});var Ho=s(je);eo=r(Ho,"MusicLDMPipeline"),Ho.forEach(o),it.forEach(o),Ke=p(e),_=a(e,"DIV",{class:!0});var D=s(_);k(ne.$$.fragment,D),to=p(D),Se=a(D,"P",{});var Ro=s(Se);oo=r(Ro,"Pipeline for text-to-audio generation using MusicLDM."),Ro.forEach(o),no=p(D),ae=a(D,"P",{});var rt=s(ae);ao=r(rt,"This model inherits from "),_e=a(rt,"A",{href:!0});var Yo=s(_e);so=r(Yo,"DiffusionPipeline"),Yo.forEach(o),io=r(rt,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),rt.forEach(o),ro=p(D),T=a(D,"DIV",{class:!0});var ye=s(T);k(se.$$.fragment,ye),lo=p(ye),Ne=a(ye,"P",{});var Oo=s(Ne);co=r(Oo,"The call function to the pipeline for generation."),Oo.forEach(o),po=p(ye),k(W.$$.fragment,ye),ye.forEach(o),uo=p(D),Z=a(D,"DIV",{class:!0});var lt=s(Z);k(ie.$$.fragment,lt),fo=p(lt),re=a(lt,"P",{});var ct=s(re);mo=r(ct,"Disable sliced VAE decoding. If "),Ie=a(ct,"CODE",{});var Xo=s(Ie);ho=r(Xo,"enable_vae_slicing"),Xo.forEach(o),go=r(ct,` was previously enabled, this method will go back to
computing decoding in one step.`),ct.forEach(o),lt.forEach(o),_o=p(D),H=a(D,"DIV",{class:!0});var dt=s(H);k(le.$$.fragment,dt),vo=p(dt),Be=a(dt,"P",{});var Ko=s(Be);Mo=r(Ko,`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),Ko.forEach(o),dt.forEach(o),D.forEach(o),this.h()},h(){u(m,"name","hf:doc:metadata"),u(m,"content",JSON.stringify(un)),u(g,"id","musicldm"),u(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(g,"href","#musicldm"),u(h,"class","relative group"),u(R,"href","https://huggingface.co/papers/2308.01546"),u(R,"rel","nofollow"),u(Y,"href","https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/overview"),u(Y,"rel","nofollow"),u(O,"href","https://huggingface.co/docs/diffusers/api/pipelines/audioldm/overview"),u(O,"rel","nofollow"),u(X,"href","https://huggingface.co/docs/transformers/main/model_doc/clap"),u(X,"rel","nofollow"),u(K,"href","https://huggingface.co/sanchit-gandhi"),u(K,"rel","nofollow"),u(J,"id","tips"),u(J,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(J,"href","#tips"),u(N,"class","relative group"),u(F,"id","diffusers.MusicLDMPipeline"),u(F,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(F,"href","#diffusers.MusicLDMPipeline"),u(G,"class","relative group"),u(_e,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(_,"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,l){t(document.head,m),c(e,w,l),c(e,h,l),t(h,g),t(g,v),P(f,v,null),t(h,M),t(h,j),t(j,S),c(e,y,l),c(e,x,l),t(x,pe),t(x,R),t(R,ut),t(x,ft),c(e,qe,l),c(e,b,l),t(b,mt),t(b,Y),t(Y,ht),t(b,gt),t(b,O),t(O,_t),t(b,vt),t(b,we),t(we,Mt),t(b,bt),t(b,X),t(X,yt),t(b,wt),c(e,Je,l),c(e,ue,l),t(ue,Dt),c(e,Ve,l),c(e,fe,l),t(fe,xt),c(e,ze,l),c(e,me,l),t(me,De),t(De,Lt),c(e,Fe,l),c(e,q,l),t(q,Tt),t(q,K),t(K,Et),t(q,$t),c(e,We,l),c(e,N,l),t(N,J),t(J,xe),P(Q,xe,null),t(N,kt),t(N,Le),t(Le,Pt),c(e,Ze,l),c(e,he,l),t(he,At),c(e,He,l),c(e,V,l),t(V,Te),t(Te,Ut),t(V,Ct),t(V,ee),t(ee,jt),t(ee,Ee),t(Ee,St),t(ee,Nt),c(e,Re,l),c(e,ge,l),t(ge,It),c(e,Ye,l),c(e,L,l),t(L,I),t(I,Bt),t(I,$e),t($e,Gt),t(I,qt),t(I,ke),t(ke,Jt),t(I,Vt),t(L,zt),t(L,te),t(te,Ft),t(te,Pe),t(Pe,Wt),t(te,Zt),t(L,Ht),t(L,B),t(B,Rt),t(B,Ae),t(Ae,Yt),t(B,Ot),t(B,Ue),t(Ue,Xt),t(B,Kt),c(e,Oe,l),P(z,e,l),c(e,Xe,l),c(e,G,l),t(G,F),t(F,Ce),P(oe,Ce,null),t(G,Qt),t(G,je),t(je,eo),c(e,Ke,l),c(e,_,l),P(ne,_,null),t(_,to),t(_,Se),t(Se,oo),t(_,no),t(_,ae),t(ae,ao),t(ae,_e),t(_e,so),t(ae,io),t(_,ro),t(_,T),P(se,T,null),t(T,lo),t(T,Ne),t(Ne,co),t(T,po),P(W,T,null),t(_,uo),t(_,Z),P(ie,Z,null),t(Z,fo),t(Z,re),t(re,mo),t(re,Ie),t(Ie,ho),t(re,go),t(_,_o),t(_,H),P(le,H,null),t(H,vo),t(H,Be),t(Be,Mo),Qe=!0},p(e,[l]){const ce={};l&2&&(ce.$$scope={dirty:l,ctx:e}),z.$set(ce);const Ge={};l&2&&(Ge.$$scope={dirty:l,ctx:e}),W.$set(Ge)},i(e){Qe||(A(f.$$.fragment,e),A(Q.$$.fragment,e),A(z.$$.fragment,e),A(oe.$$.fragment,e),A(ne.$$.fragment,e),A(se.$$.fragment,e),A(W.$$.fragment,e),A(ie.$$.fragment,e),A(le.$$.fragment,e),Qe=!0)},o(e){U(f.$$.fragment,e),U(Q.$$.fragment,e),U(z.$$.fragment,e),U(oe.$$.fragment,e),U(ne.$$.fragment,e),U(se.$$.fragment,e),U(W.$$.fragment,e),U(ie.$$.fragment,e),U(le.$$.fragment,e),Qe=!1},d(e){o(m),e&&o(w),e&&o(h),C(f),e&&o(y),e&&o(x),e&&o(qe),e&&o(b),e&&o(Je),e&&o(ue),e&&o(Ve),e&&o(fe),e&&o(ze),e&&o(me),e&&o(Fe),e&&o(q),e&&o(We),e&&o(N),C(Q),e&&o(Ze),e&&o(he),e&&o(He),e&&o(V),e&&o(Re),e&&o(ge),e&&o(Ye),e&&o(L),e&&o(Oe),C(z,e),e&&o(Xe),e&&o(G),C(oe),e&&o(Ke),e&&o(_),C(ne),C(se),C(W),C(ie),C(le)}}}const un={local:"musicldm",sections:[{local:"tips",title:"Tips"},{local:"diffusers.MusicLDMPipeline",title:"MusicLDMPipeline"}],title:"MusicLDM"};function fn(de){return nn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class bn extends Qo{constructor(m){super();en(this,m,fn,pn,tn,{})}}export{bn as default,un as metadata};
