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 C,B as U,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,S;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"),S=i(`
section to learn how to efficiently load the same components into multiple pipelines.`),this.h()},l(j){m=a(j,"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),S=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(j,y){c(j,m,y),t(m,w),t(m,h),t(h,g),t(m,v),t(m,f),t(f,M),t(m,S)},d(j){j&&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){C(g.$$.fragment,f),v=!1},d(f){f&&o(m),f&&o(h),U(g,f)}}}function pn(de){let m,w,h,g,v,f,M,S,j,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,Tt,Fe,q,Et,K,Lt,$t,We,N,J,xe,Q,kt,Te,Pt,Ze,he,At,He,V,Ee,Ct,Ut,ee,St,Le,jt,Nt,Re,ge,It,Ye,T,I,Gt,$e,Bt,qt,ke,Jt,Vt,zt,te,Ft,Pe,Wt,Zt,Ht,G,Rt,Ae,Yt,Ot,Ce,Xt,Kt,Oe,z,Xe,B,F,Ue,oe,Qt,Se,eo,Ke,_,ne,to,je,oo,no,ae,ao,_e,so,io,ro,E,se,lo,Ne,co,po,W,uo,Z,ie,fo,re,mo,Ie,ho,go,_o,H,le,vo,Ge,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/main/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> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clap#transformers.ClapModel" rel="nofollow">ClapModel</a>) &#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 <a href="https://huggingface.co/docs/transformers/main/en/model_doc/roberta#transformers.RobertaTokenizer" rel="nofollow">RobertaTokenizer</a> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.MusicLDMPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clap#transformers.ClapFeatureExtractor" rel="nofollow">ClapFeatureExtractor</a>) &#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/main/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/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/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.MusicLDMPipeline.vocoder",description:`<strong>vocoder</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/speecht5#transformers.SpeechT5HifiGan" rel="nofollow">SpeechT5HifiGan</a>) &#x2014;
Vocoder of class <code>SpeechT5HifiGan</code>.`,name:"vocoder"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L60"}}),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 (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clap#transformers.ClapModel" rel="nofollow">ClapModel</a>), 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/main/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/main/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/main/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L393",returnDescription:`
<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:`
<p><a
  href="/docs/diffusers/main/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/main/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L118"}}),le=new pt({props:{name:"enable_vae_slicing",anchor:"diffusers.MusicLDMPipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/musicldm/pipeline_musicldm.py#L110"}}),{c(){m=n("meta"),w=d(),h=n("h1"),g=n("a"),v=n("span"),$(f.$$.fragment),M=d(),S=n("span"),j=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"),Tt=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"),Et=i("This pipeline was contributed by "),K=n("a"),Lt=i("sanchit-gandhi"),$t=i("."),We=d(),N=n("h2"),J=n("a"),xe=n("span"),$(Q.$$.fragment),kt=d(),Te=n("span"),Pt=i("Tips"),Ze=d(),he=n("p"),At=i("When constructing a prompt, keep in mind:"),He=d(),V=n("ul"),Ee=n("li"),Ct=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)."),Ut=d(),ee=n("li"),St=i("Using a "),Le=n("em"),jt=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(),T=n("ul"),I=n("li"),Gt=i("The "),$e=n("em"),Bt=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(),G=n("li"),Rt=i("The "),Ae=n("em"),Yt=i("length"),Ot=i(" of the generated audio sample can be controlled by varying the "),Ce=n("code"),Xt=i("audio_length_in_s"),Kt=i(" argument."),Oe=d(),$(z.$$.fragment),Xe=d(),B=n("h2"),F=n("a"),Ue=n("span"),$(oe.$$.fragment),Qt=d(),Se=n("span"),eo=i("MusicLDMPipeline"),Ke=d(),_=n("div"),$(ne.$$.fragment),to=d(),je=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(),E=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(),Ge=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 Be=s(g);v=a(Be,"SPAN",{});var yo=s(v);k(f.$$.fragment,yo),yo.forEach(o),Be.forEach(o),M=p(ce),S=a(ce,"SPAN",{});var wo=s(S);j=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 L=s(b);mt=r(L,"Inspired by "),Y=a(L,"A",{href:!0,rel:!0});var xo=s(Y);ht=r(xo,"Stable Diffusion"),xo.forEach(o),gt=r(L," and "),O=a(L,"A",{href:!0,rel:!0});var To=s(O);_t=r(To,"AudioLDM"),To.forEach(o),vt=r(L,`,
MusicLDM is a text-to-music `),we=a(L,"EM",{});var Eo=s(we);Mt=r(Eo,"latent diffusion model (LDM)"),Eo.forEach(o),bt=r(L," that learns continuous audio representations from "),X=a(L,"A",{href:!0,rel:!0});var Lo=s(X);yt=r(Lo,"CLAP"),Lo.forEach(o),wt=r(L,`
latents.`),L.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);Tt=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);Et=r(tt,"This pipeline was contributed by "),K=a(tt,"A",{href:!0,rel:!0});var Co=s(K);Lt=r(Co,"sanchit-gandhi"),Co.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 Uo=s(J);xe=a(Uo,"SPAN",{});var So=s(xe);k(Q.$$.fragment,So),So.forEach(o),Uo.forEach(o),kt=p(ot),Te=a(ot,"SPAN",{});var jo=s(Te);Pt=r(jo,"Tips"),jo.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);Ee=a(nt,"LI",{});var Io=s(Ee);Ct=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),Ut=p(nt),ee=a(nt,"LI",{});var at=s(ee);St=r(at,"Using a "),Le=a(at,"EM",{});var Go=s(Le);jt=r(Go,"negative prompt"),Go.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 Bo=s(ge);It=r(Bo,"During inference:"),Bo.forEach(o),Ye=p(e),T=a(e,"UL",{});var ve=s(T);I=a(ve,"LI",{});var Me=s(I);Gt=r(Me,"The "),$e=a(Me,"EM",{});var qo=s($e);Bt=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),G=a(ve,"LI",{});var be=s(G);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 "),Ce=a(be,"CODE",{});var Fo=s(Ce);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),B=a(e,"H2",{class:!0});var it=s(B);F=a(it,"A",{id:!0,class:!0,href:!0});var Wo=s(F);Ue=a(Wo,"SPAN",{});var Zo=s(Ue);k(oe.$$.fragment,Zo),Zo.forEach(o),Wo.forEach(o),Qt=p(it),Se=a(it,"SPAN",{});var Ho=s(Se);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),je=a(D,"P",{});var Ro=s(je);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),E=a(D,"DIV",{class:!0});var ye=s(E);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),Ge=a(dt,"P",{});var Ko=s(Ge);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(B,"class","relative group"),u(_e,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(E,"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,S),t(S,j),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,Tt),c(e,Fe,l),c(e,q,l),t(q,Et),t(q,K),t(K,Lt),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,Te),t(Te,Pt),c(e,Ze,l),c(e,he,l),t(he,At),c(e,He,l),c(e,V,l),t(V,Ee),t(Ee,Ct),t(V,Ut),t(V,ee),t(ee,St),t(ee,Le),t(Le,jt),t(ee,Nt),c(e,Re,l),c(e,ge,l),t(ge,It),c(e,Ye,l),c(e,T,l),t(T,I),t(I,Gt),t(I,$e),t($e,Bt),t(I,qt),t(I,ke),t(ke,Jt),t(I,Vt),t(T,zt),t(T,te),t(te,Ft),t(te,Pe),t(Pe,Wt),t(te,Zt),t(T,Ht),t(T,G),t(G,Rt),t(G,Ae),t(Ae,Yt),t(G,Ot),t(G,Ce),t(Ce,Xt),t(G,Kt),c(e,Oe,l),P(z,e,l),c(e,Xe,l),c(e,B,l),t(B,F),t(F,Ue),P(oe,Ue,null),t(B,Qt),t(B,Se),t(Se,eo),c(e,Ke,l),c(e,_,l),P(ne,_,null),t(_,to),t(_,je),t(je,oo),t(_,no),t(_,ae),t(ae,ao),t(ae,_e),t(_e,so),t(ae,io),t(_,ro),t(_,E),P(se,E,null),t(E,lo),t(E,Ne),t(Ne,co),t(E,po),P(W,E,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,Ge),t(Ge,Mo),Qe=!0},p(e,[l]){const ce={};l&2&&(ce.$$scope={dirty:l,ctx:e}),z.$set(ce);const Be={};l&2&&(Be.$$scope={dirty:l,ctx:e}),W.$set(Be)},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){C(f.$$.fragment,e),C(Q.$$.fragment,e),C(z.$$.fragment,e),C(oe.$$.fragment,e),C(ne.$$.fragment,e),C(se.$$.fragment,e),C(W.$$.fragment,e),C(ie.$$.fragment,e),C(le.$$.fragment,e),Qe=!1},d(e){o(m),e&&o(w),e&&o(h),U(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),U(Q),e&&o(Ze),e&&o(he),e&&o(He),e&&o(V),e&&o(Re),e&&o(ge),e&&o(Ye),e&&o(T),e&&o(Oe),U(z,e),e&&o(Xe),e&&o(B),U(oe),e&&o(Ke),e&&o(_),U(ne),U(se),U(W),U(ie),U(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};
