import{s as El,o as Ql,n as Hl}from"../chunks/scheduler.25b97de1.js";import{S as Yl,i as xl,g as o,s as a,r as p,A as Sl,h as i,f as l,c as n,j as zl,u as m,x as r,k as Nl,y as ql,a as s,v as c,d,t as u,w as M}from"../chunks/index.d9030fc9.js";import{T as Fl}from"../chunks/Tip.baa67368.js";import{C as f}from"../chunks/CodeBlock.e6cd0d95.js";import{H as g,E as Al}from"../chunks/EditOnGithub.91d95064.js";function Ll(Ge){let y,j="You can safely ignore a warning such as:",J,b,w;return b=new f({props:{code:"U29tZSUyMHdlaWdodHMlMjBvZiUyMFdhdjJWZWMyRm9yQ1RDJTIwd2VyZSUyMG5vdCUyMGluaXRpYWxpemVkJTIwZnJvbSUyMHRoZSUyMG1vZGVsJTIwY2hlY2twb2ludCUyMGF0JTIwZmFjZWJvb2slMkZtbXMtMWItYWxsJTIwYW5kJTIwYXJlJTIwbmV3bHklMjBpbml0aWFsaXplZCUyMGJlY2F1c2UlMjB0aGUlMjBzaGFwZXMlMjBkaWQlMjBub3QlMjBtYXRjaCUzQSUwQS0lMjBsbV9oZWFkLmJpYXMlM0ElMjBmb3VuZCUyMHNoYXBlJTIwdG9yY2guU2l6ZSglNUIxNTQlNUQpJTIwaW4lMjB0aGUlMjBjaGVja3BvaW50JTIwYW5kJTIwdG9yY2guU2l6ZSglNUIzMTQlNUQpJTIwaW4lMjB0aGUlMjBtb2RlbCUyMGluc3RhbnRpYXRlZCUwQS0lMjBsbV9oZWFkLndlaWdodCUzQSUyMGZvdW5kJTIwc2hhcGUlMjB0b3JjaC5TaXplKCU1QjE1NCUyQyUyMDEyODAlNUQpJTIwaW4lMjB0aGUlMjBjaGVja3BvaW50JTIwYW5kJTIwdG9yY2guU2l6ZSglNUIzMTQlMkMlMjAxMjgwJTVEKSUyMGluJTIwdGhlJTIwbW9kZWwlMjBpbnN0YW50aWF0ZWQlMEFZb3UlMjBzaG91bGQlMjBwcm9iYWJseSUyMFRSQUlOJTIwdGhpcyUyMG1vZGVsJTIwb24lMjBhJTIwZG93bi1zdHJlYW0lMjB0YXNrJTIwdG8lMjBiZSUyMGFibGUlMjB0byUyMHVzZSUyMGl0JTIwZm9yJTIwcHJlZGljdGlvbnMlMjBhbmQlMjBpbmZlcmVuY2Uu",highlighted:`Some weights of Wav2Vec2ForCTC were not initialized from the model checkpoint at facebook/mms-1b-all and are newly initialized because the shapes did not match:
- lm_head.bias: found shape torch.Size([154]) in the checkpoint and torch.Size([314]) in the model instantiated
- lm_head.weight: found shape torch.Size([154, 1280]) in the checkpoint and torch.Size([314, 1280]) in the model instantiated
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.`,wrap:!1}}),{c(){y=o("p"),y.textContent=j,J=a(),p(b.$$.fragment)},l(h){y=i(h,"P",{"data-svelte-h":!0}),r(y)!=="svelte-17yglm5"&&(y.textContent=j),J=n(h),m(b.$$.fragment,h)},m(h,T){s(h,y,T),s(h,J,T),c(b,h,T),w=!0},p:Hl,i(h){w||(d(b.$$.fragment,h),w=!0)},o(h){u(b.$$.fragment,h),w=!1},d(h){h&&(l(y),l(J)),M(b,h)}}}function Pl(Ge){let y,j=`The MMS for ASR architecture is based on the Wav2Vec2 model, refer to <a href="wav2vec2">Wav2Vec2’s documentation page</a> for further
details on how to finetune with models for various downstream tasks.`,J,b,w='MMS-TTS uses the same model architecture as VITS, refer to <a href="vits">VITS’s documentation page</a> for API reference.';return{c(){y=o("p"),y.innerHTML=j,J=a(),b=o("p"),b.innerHTML=w},l(h){y=i(h,"P",{"data-svelte-h":!0}),r(y)!=="svelte-ez75p4"&&(y.innerHTML=j),J=n(h),b=i(h,"P",{"data-svelte-h":!0}),r(b)!=="svelte-102khel"&&(b.innerHTML=w)},m(h,T){s(h,y,T),s(h,J,T),s(h,b,T)},p:Hl,d(h){h&&(l(y),l(J),l(b))}}}function Kl(Ge){let y,j,J,b,w,h,T,Ne,Z,el=`The MMS model was proposed in <a href="https://arxiv.org/abs/2305.13516" rel="nofollow">Scaling Speech Technology to 1,000+ Languages</a>
by Vineel Pratap, Andros Tjandra, Bowen Shi, Paden Tomasello, Arun Babu, Sayani Kundu, Ali Elkahky, Zhaoheng Ni, Apoorv Vyas, Maryam Fazel-Zarandi, Alexei Baevski, Yossi Adi, Xiaohui Zhang, Wei-Ning Hsu, Alexis Conneau, Michael Auli`,Fe,v,tl="The abstract from the paper is the following:",He,k,ll=`<em>Expanding the language coverage of speech technology has the potential to improve access to information for many more people.
However, current speech technology is restricted to about one hundred languages which is a small fraction of the over 7,000
languages spoken around the world.
The Massively Multilingual Speech (MMS) project increases the number of supported languages by 10-40x, depending on the task.
The main ingredients are a new dataset based on readings of publicly available religious texts and effectively leveraging
self-supervised learning. We built pre-trained wav2vec 2.0 models covering 1,406 languages,
a single multilingual automatic speech recognition model for 1,107 languages, speech synthesis models
for the same number of languages, as well as a language identification model for 4,017 languages.
Experiments show that our multilingual speech recognition model more than halves the word error rate of
Whisper on 54 languages of the FLEURS benchmark while being trained on a small fraction of the labeled data.</em>`,Ee,I,sl='Here are the different models open sourced in the MMS project. The models and code are originally released <a href="https://github.com/facebookresearch/fairseq/tree/main/examples/mms" rel="nofollow">here</a>. We have add them to the <code>transformers</code> framework, making them easier to use.',Qe,$,Ye,C,al='The ASR model checkpoints  can be found here : <a href="https://huggingface.co/facebook/mms-1b-fl102" rel="nofollow">mms-1b-fl102</a>, <a href="https://huggingface.co/facebook/mms-1b-l1107" rel="nofollow">mms-1b-l1107</a>, <a href="https://huggingface.co/facebook/mms-1b-all" rel="nofollow">mms-1b-all</a>. For best accuracy, use the <code>mms-1b-all</code> model.',xe,R,nl="Tips:",Se,X,ol=`<li>All ASR models accept a float array corresponding to the raw waveform of the speech signal. The raw waveform should be pre-processed with <a href="/docs/transformers/pr_31098/en/model_doc/wav2vec2#transformers.Wav2Vec2FeatureExtractor">Wav2Vec2FeatureExtractor</a>.</li> <li>The models were trained using connectionist temporal classification (CTC) so the model output has to be decoded using
<a href="/docs/transformers/pr_31098/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer">Wav2Vec2CTCTokenizer</a>.</li> <li>You can load different language adapter weights for different languages via <a href="/docs/transformers/pr_31098/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC.load_adapter">load_adapter()</a>. Language adapters only consists of roughly 2 million parameters
and can therefore be efficiently loaded on the fly when needed.</li>`,qe,B,Ae,V,il=`By default MMS loads adapter weights for English. If you want to load adapter weights of another language
make sure to specify <code>target_lang=&lt;your-chosen-target-lang&gt;</code> as well as <code>&quot;ignore_mismatched_sizes=True</code>.
The <code>ignore_mismatched_sizes=True</code> keyword has to be passed to allow the language model head to be resized according
to the vocabulary of the specified language.
Similarly, the processor should be loaded with the same target language`,Le,_,Pe,U,Ke,G,rl="If you want to use the ASR pipeline, you can load your chosen target language as such:",De,z,Oe,N,et,F,pl=`Next, let’s look at how we can run MMS in inference and change adapter layers after having called <code>~PretrainedModel.from_pretrained</code>
First, we load audio data in different languages using the <a href="https://github.com/huggingface/datasets" rel="nofollow">Datasets</a>.`,tt,H,lt,E,ml="Next, we load the model and processor",st,Q,at,Y,cl=`Now we process the audio data, pass the processed audio data to the model and transcribe the model output,
just like we usually do for <a href="/docs/transformers/pr_31098/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC">Wav2Vec2ForCTC</a>.`,nt,x,ot,S,dl=`We can now keep the same model in memory and simply switch out the language adapters by
calling the convenient <a href="/docs/transformers/pr_31098/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC.load_adapter">load_adapter()</a> function for the model and <a href="/docs/transformers/pr_31098/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.set_target_lang">set_target_lang()</a> for the tokenizer.
We pass the target language as an input - <code>&quot;fra&quot;</code> for French.`,it,q,rt,A,ul="In the same way the language can be switched out for all other supported languages. Please have a look at:",pt,L,mt,P,Ml="to see all supported languages.",ct,K,hl='To further improve performance from ASR models, language model decoding can be used. See the documentation <a href="https://huggingface.co/facebook/mms-1b-all" rel="nofollow">here</a> for further details.',dt,D,ut,O,yl=`MMS-TTS uses the same model architecture as VITS, which was added to 🤗 Transformers in v4.33. MMS trains a separate
model checkpoint for each of the 1100+ languages in the project. All available checkpoints can be found on the Hugging
Face Hub: <a href="https://huggingface.co/models?sort=trending&amp;search=facebook%2Fmms-tts" rel="nofollow">facebook/mms-tts</a>, and the inference
documentation under <a href="https://huggingface.co/docs/transformers/main/en/model_doc/vits" rel="nofollow">VITS</a>.`,Mt,ee,ht,te,fl="To use the MMS model, first update to the latest version of the Transformers library:",yt,le,ft,se,bl=`Since the flow-based model in VITS is non-deterministic, it is good practice to set a seed to ensure reproducibility of
the outputs.`,bt,ae,Jl=`<li>For languages with a Roman alphabet, such as English or French, the tokenizer can be used directly to
pre-process the text inputs. The following code example runs a forward pass using the MMS-TTS English checkpoint:</li>`,Jt,ne,wt,oe,wl="The resulting waveform can be saved as a <code>.wav</code> file:",Tt,ie,jt,re,Tl="Or displayed in a Jupyter Notebook / Google Colab:",gt,pe,Ut,me,jl=`For certain languages with non-Roman alphabets, such as Arabic, Mandarin or Hindi, the <a href="https://github.com/isi-nlp/uroman" rel="nofollow"><code>uroman</code></a>
perl package is required to pre-process the text inputs to the Roman alphabet.`,Wt,ce,gl=`You can check whether you require the <code>uroman</code> package for your language by inspecting the <code>is_uroman</code> attribute of
the pre-trained <code>tokenizer</code>:`,Zt,de,vt,ue,Ul=`If required, you should apply the uroman package to your text inputs <strong>prior</strong> to passing them to the <code>VitsTokenizer</code>,
since currently the tokenizer does not support performing the pre-processing itself.`,kt,Me,Wl="To do this, first clone the uroman repository to your local machine and set the bash variable <code>UROMAN</code> to the local path:",It,he,$t,ye,Zl=`You can then pre-process the text input using the following code snippet. You can either rely on using the bash variable
<code>UROMAN</code> to point to the uroman repository, or you can pass the uroman directory as an argument to the <code>uromaize</code> function:`,Ct,fe,Rt,be,vl="<strong>Tips:</strong>",Xt,Je,kl="<li>The MMS-TTS checkpoints are trained on lower-cased, un-punctuated text. By default, the <code>VitsTokenizer</code> <em>normalizes</em> the inputs by removing any casing and punctuation, to avoid passing out-of-vocabulary characters to the model. Hence, the model is agnostic to casing and punctuation, so these should be avoided in the text prompt. You can disable normalisation by setting <code>normalize=False</code> in the call to the tokenizer, but this will lead to un-expected behaviour and is discouraged.</li> <li>The speaking rate can be varied by setting the attribute <code>model.speaking_rate</code> to a chosen value. Likewise, the randomness of the noise is controlled by <code>model.noise_scale</code>:</li>",Bt,we,Vt,Te,_t,je,Il='Different LID models are available based on the number of languages they can recognize - <a href="https://huggingface.co/facebook/mms-lid-126" rel="nofollow">126</a>, <a href="https://huggingface.co/facebook/mms-lid-256" rel="nofollow">256</a>, <a href="https://huggingface.co/facebook/mms-lid-512" rel="nofollow">512</a>, <a href="https://huggingface.co/facebook/mms-lid-1024" rel="nofollow">1024</a>, <a href="https://huggingface.co/facebook/mms-lid-2048" rel="nofollow">2048</a>, <a href="https://huggingface.co/facebook/mms-lid-4017" rel="nofollow">4017</a>.',Gt,ge,zt,Ue,$l="First, we install transformers and some other libraries",Nt,We,Ft,Ze,Cl="Next, we load a couple of audio samples via <code>datasets</code>. Make sure that the audio data is sampled to 16000 kHz.",Ht,ve,Et,ke,Rl="Next, we load the model and processor",Qt,Ie,Yt,$e,Xl='Now we process the audio data, pass the processed audio data to the model to classify it into a language, just like we usually do for Wav2Vec2 audio classification models such as <a href="https://huggingface.co/harshit345/xlsr-wav2vec-speech-emotion-recognition" rel="nofollow">ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition</a>',xt,Ce,St,Re,Bl="To see all the supported languages of a checkpoint, you can print out the language ids as follows:",qt,Xe,At,Be,Lt,Ve,Vl=`Pretrained models are available for two different sizes - <a href="https://huggingface.co/facebook/mms-300m" rel="nofollow">300M</a> ,
<a href="https://huggingface.co/facebook/mms-1b" rel="nofollow">1Bil</a>.`,Pt,W,Kt,_e,Dt,ze,Ot;return w=new g({props:{title:"MMS",local:"mms",headingTag:"h1"}}),T=new g({props:{title:"Overview",local:"overview",headingTag:"h2"}}),$=new g({props:{title:"Automatic Speech Recognition (ASR)",local:"automatic-speech-recognition-asr",headingTag:"h3"}}),B=new g({props:{title:"Loading",local:"loading",headingTag:"h4"}}),_=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyRm9yQ1RDJTJDJTIwQXV0b1Byb2Nlc3NvciUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyZmFjZWJvb2slMkZtbXMtMWItYWxsJTIyJTBBdGFyZ2V0X2xhbmclMjAlM0QlMjAlMjJmcmElMjIlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMHRhcmdldF9sYW5nJTNEdGFyZ2V0X2xhbmcpJTBBbW9kZWwlMjAlM0QlMjBXYXYyVmVjMkZvckNUQy5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB0YXJnZXRfbGFuZyUzRHRhcmdldF9sYW5nJTJDJTIwaWdub3JlX21pc21hdGNoZWRfc2l6ZXMlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2ForCTC, AutoProcessor

model_id = <span class="hljs-string">&quot;facebook/mms-1b-all&quot;</span>
target_lang = <span class="hljs-string">&quot;fra&quot;</span>

processor = AutoProcessor.from_pretrained(model_id, target_lang=target_lang)
model = Wav2Vec2ForCTC.from_pretrained(model_id, target_lang=target_lang, ignore_mismatched_sizes=<span class="hljs-literal">True</span>)`,wrap:!1}}),U=new Fl({props:{$$slots:{default:[Ll]},$$scope:{ctx:Ge}}}),z=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJmYWNlYm9vayUyRm1tcy0xYi1hbGwlMjIlMEF0YXJnZXRfbGFuZyUyMCUzRCUyMCUyMmZyYSUyMiUwQSUwQXBpcGUlMjAlM0QlMjBwaXBlbGluZShtb2RlbCUzRG1vZGVsX2lkJTJDJTIwbW9kZWxfa3dhcmdzJTNEJTdCJTIydGFyZ2V0X2xhbmclMjIlM0ElMjAlMjJmcmElMjIlMkMlMjAlMjJpZ25vcmVfbWlzbWF0Y2hlZF9zaXplcyUyMiUzQSUyMFRydWUlN0Qp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

model_id = <span class="hljs-string">&quot;facebook/mms-1b-all&quot;</span>
target_lang = <span class="hljs-string">&quot;fra&quot;</span>

pipe = pipeline(model=model_id, model_kwargs={<span class="hljs-string">&quot;target_lang&quot;</span>: <span class="hljs-string">&quot;fra&quot;</span>, <span class="hljs-string">&quot;ignore_mismatched_sizes&quot;</span>: <span class="hljs-literal">True</span>})`,wrap:!1}}),N=new g({props:{title:"Inference",local:"inference",headingTag:"h4"}}),H=new f({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEElMjMlMjBFbmdsaXNoJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIybW96aWxsYS1mb3VuZGF0aW9uJTJGY29tbW9uX3ZvaWNlXzEzXzAlMjIlMkMlMjAlMjJlbiUyMiUyQyUyMHNwbGl0JTNEJTIydGVzdCUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUpJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBzdHJlYW1fZGF0YS5jYXN0X2NvbHVtbiglMjJhdWRpbyUyMiUyQyUyMEF1ZGlvKHNhbXBsaW5nX3JhdGUlM0QxNjAwMCkpJTBBZW5fc2FtcGxlJTIwJTNEJTIwbmV4dChpdGVyKHN0cmVhbV9kYXRhKSklNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVEJTBBJTBBJTIzJTIwRnJlbmNoJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIybW96aWxsYS1mb3VuZGF0aW9uJTJGY29tbW9uX3ZvaWNlXzEzXzAlMjIlMkMlMjAlMjJmciUyMiUyQyUyMHNwbGl0JTNEJTIydGVzdCUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUpJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBzdHJlYW1fZGF0YS5jYXN0X2NvbHVtbiglMjJhdWRpbyUyMiUyQyUyMEF1ZGlvKHNhbXBsaW5nX3JhdGUlM0QxNjAwMCkpJTBBZnJfc2FtcGxlJTIwJTNEJTIwbmV4dChpdGVyKHN0cmVhbV9kYXRhKSklNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVE",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-comment"># English</span>
stream_data = load_dataset(<span class="hljs-string">&quot;mozilla-foundation/common_voice_13_0&quot;</span>, <span class="hljs-string">&quot;en&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>, streaming=<span class="hljs-literal">True</span>)
stream_data = stream_data.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))
en_sample = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(stream_data))[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>]

<span class="hljs-comment"># French</span>
stream_data = load_dataset(<span class="hljs-string">&quot;mozilla-foundation/common_voice_13_0&quot;</span>, <span class="hljs-string">&quot;fr&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>, streaming=<span class="hljs-literal">True</span>)
stream_data = stream_data.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))
fr_sample = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(stream_data))[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>]`,wrap:!1}}),Q=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyRm9yQ1RDJTJDJTIwQXV0b1Byb2Nlc3NvciUwQWltcG9ydCUyMHRvcmNoJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJmYWNlYm9vayUyRm1tcy0xYi1hbGwlMjIlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFtb2RlbCUyMCUzRCUyMFdhdjJWZWMyRm9yQ1RDLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2ForCTC, AutoProcessor
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;facebook/mms-1b-all&quot;</span>

processor = AutoProcessor.from_pretrained(model_id)
model = Wav2Vec2ForCTC.from_pretrained(model_id)`,wrap:!1}}),x=new f({props:{code:"aW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGVuX3NhbXBsZSUyQyUyMHNhbXBsaW5nX3JhdGUlM0QxNl8wMDAlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQWlkcyUyMCUzRCUyMHRvcmNoLmFyZ21heChvdXRwdXRzJTJDJTIwZGltJTNELTEpJTVCMCU1RCUwQXRyYW5zY3JpcHRpb24lMjAlM0QlMjBwcm9jZXNzb3IuZGVjb2RlKGlkcyklMEElMjMlMjAnam9lJTIwa2V0b24lMjBkaXNhcHByb3ZlZCUyMG9mJTIwZmlsbXMlMjBhbmQlMjBidXN0ZXIlMjBhbHNvJTIwaGFkJTIwcmVzZXJ2YXRpb25zJTIwYWJvdXQlMjB0aGUlMjBtZWRpYSc=",highlighted:`inputs = processor(en_sample, sampling_rate=<span class="hljs-number">16_000</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = model(**inputs).logits

ids = torch.argmax(outputs, dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]
transcription = processor.decode(ids)
<span class="hljs-comment"># &#x27;joe keton disapproved of films and buster also had reservations about the media&#x27;</span>`,wrap:!1}}),q=new f({props:{code:"cHJvY2Vzc29yLnRva2VuaXplci5zZXRfdGFyZ2V0X2xhbmcoJTIyZnJhJTIyKSUwQW1vZGVsLmxvYWRfYWRhcHRlciglMjJmcmElMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGZyX3NhbXBsZSUyQyUyMHNhbXBsaW5nX3JhdGUlM0QxNl8wMDAlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQWlkcyUyMCUzRCUyMHRvcmNoLmFyZ21heChvdXRwdXRzJTJDJTIwZGltJTNELTEpJTVCMCU1RCUwQXRyYW5zY3JpcHRpb24lMjAlM0QlMjBwcm9jZXNzb3IuZGVjb2RlKGlkcyklMEElMjMlMjAlMjJjZSUyMGRlcm5pZXIlMjBlc3QlMjB2b2wlQzMlQTklMjB0b3V0JTIwYXUlMjBsb25nJTIwZGUlMjBsJ2hpc3RvaXJlJTIwcm9tYWluZSUyMg==",highlighted:`processor.tokenizer.set_target_lang(<span class="hljs-string">&quot;fra&quot;</span>)
model.load_adapter(<span class="hljs-string">&quot;fra&quot;</span>)

inputs = processor(fr_sample, sampling_rate=<span class="hljs-number">16_000</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = model(**inputs).logits

ids = torch.argmax(outputs, dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]
transcription = processor.decode(ids)
<span class="hljs-comment"># &quot;ce dernier est volé tout au long de l&#x27;histoire romaine&quot;</span>`,wrap:!1}}),L=new f({props:{code:"cHJvY2Vzc29yLnRva2VuaXplci52b2NhYi5rZXlzKCk=",highlighted:"processor.tokenizer.vocab.keys()",wrap:!1}}),D=new g({props:{title:"Speech Synthesis (TTS)",local:"speech-synthesis-tts",headingTag:"h3"}}),ee=new g({props:{title:"Inference",local:"inference",headingTag:"h4"}}),le=new f({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHRyYW5zZm9ybWVycyUyMGFjY2VsZXJhdGU=",highlighted:"pip install --upgrade transformers accelerate",wrap:!1}}),ne=new f({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVml0c1Rva2VuaXplciUyQyUyMFZpdHNNb2RlbCUyQyUyMHNldF9zZWVkJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwVml0c1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtbXMtdHRzLWVuZyUyMiklMEFtb2RlbCUyMCUzRCUyMFZpdHNNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtbXMtdHRzLWVuZyUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUzRCUyMkhlbGxvJTIwLSUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEFzZXRfc2VlZCg1NTUpJTIwJTIwJTIzJTIwbWFrZSUyMGRldGVybWluaXN0aWMlMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQXdhdmVmb3JtJTIwJTNEJTIwb3V0cHV0cy53YXZlZm9ybSU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VitsTokenizer, VitsModel, set_seed

tokenizer = VitsTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/mms-tts-eng&quot;</span>)
model = VitsModel.from_pretrained(<span class="hljs-string">&quot;facebook/mms-tts-eng&quot;</span>)

inputs = tokenizer(text=<span class="hljs-string">&quot;Hello - my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

set_seed(<span class="hljs-number">555</span>)  <span class="hljs-comment"># make deterministic</span>

<span class="hljs-keyword">with</span> torch.no_grad():
   outputs = model(**inputs)

waveform = outputs.waveform[<span class="hljs-number">0</span>]`,wrap:!1}}),ie=new f({props:{code:"aW1wb3J0JTIwc2NpcHklMEElMEFzY2lweS5pby53YXZmaWxlLndyaXRlKCUyMnN5bnRoZXNpemVkX3NwZWVjaC53YXYlMjIlMkMlMjByYXRlJTNEbW9kZWwuY29uZmlnLnNhbXBsaW5nX3JhdGUlMkMlMjBkYXRhJTNEd2F2ZWZvcm0p",highlighted:`<span class="hljs-keyword">import</span> scipy

scipy.io.wavfile.write(<span class="hljs-string">&quot;synthesized_speech.wav&quot;</span>, rate=model.config.sampling_rate, data=waveform)`,wrap:!1}}),pe=new f({props:{code:"ZnJvbSUyMElQeXRob24uZGlzcGxheSUyMGltcG9ydCUyMEF1ZGlvJTBBJTBBQXVkaW8od2F2ZWZvcm0lMkMlMjByYXRlJTNEbW9kZWwuY29uZmlnLnNhbXBsaW5nX3JhdGUp",highlighted:`<span class="hljs-keyword">from</span> IPython.display <span class="hljs-keyword">import</span> Audio

Audio(waveform, rate=model.config.sampling_rate)`,wrap:!1}}),de=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpdHNUb2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBWaXRzVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRm1tcy10dHMtZW5nJTIyKSUwQXByaW50KHRva2VuaXplci5pc191cm9tYW4p",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VitsTokenizer

tokenizer = VitsTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/mms-tts-eng&quot;</span>)
<span class="hljs-built_in">print</span>(tokenizer.is_uroman)`,wrap:!1}}),he=new f({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZpc2ktbmxwJTJGdXJvbWFuLmdpdCUwQWNkJTIwdXJvbWFuJTBBZXhwb3J0JTIwVVJPTUFOJTNEJTI0KHB3ZCk=",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/isi-nlp/uroman.git
<span class="hljs-built_in">cd</span> uroman
<span class="hljs-built_in">export</span> UROMAN=$(<span class="hljs-built_in">pwd</span>)`,wrap:!1}}),fe=new f({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVml0c1Rva2VuaXplciUyQyUyMFZpdHNNb2RlbCUyQyUyMHNldF9zZWVkJTBBaW1wb3J0JTIwb3MlMEFpbXBvcnQlMjBzdWJwcm9jZXNzJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwVml0c1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtbXMtdHRzLWtvciUyMiklMEFtb2RlbCUyMCUzRCUyMFZpdHNNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtbXMtdHRzLWtvciUyMiklMEElMEFkZWYlMjB1cm9tYW5pemUoaW5wdXRfc3RyaW5nJTJDJTIwdXJvbWFuX3BhdGgpJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyQ29udmVydCUyMG5vbi1Sb21hbiUyMHN0cmluZ3MlMjB0byUyMFJvbWFuJTIwdXNpbmclMjB0aGUlMjAlNjB1cm9tYW4lNjAlMjBwZXJsJTIwcGFja2FnZS4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBzY3JpcHRfcGF0aCUyMCUzRCUyMG9zLnBhdGguam9pbih1cm9tYW5fcGF0aCUyQyUyMCUyMmJpbiUyMiUyQyUyMCUyMnVyb21hbi5wbCUyMiklMEElMEElMjAlMjAlMjAlMjBjb21tYW5kJTIwJTNEJTIwJTVCJTIycGVybCUyMiUyQyUyMHNjcmlwdF9wYXRoJTVEJTBBJTBBJTIwJTIwJTIwJTIwcHJvY2VzcyUyMCUzRCUyMHN1YnByb2Nlc3MuUG9wZW4oY29tbWFuZCUyQyUyMHN0ZGluJTNEc3VicHJvY2Vzcy5QSVBFJTJDJTIwc3Rkb3V0JTNEc3VicHJvY2Vzcy5QSVBFJTJDJTIwc3RkZXJyJTNEc3VicHJvY2Vzcy5QSVBFKSUwQSUyMCUyMCUyMCUyMCUyMyUyMEV4ZWN1dGUlMjB0aGUlMjBwZXJsJTIwY29tbWFuZCUwQSUyMCUyMCUyMCUyMHN0ZG91dCUyQyUyMHN0ZGVyciUyMCUzRCUyMHByb2Nlc3MuY29tbXVuaWNhdGUoaW5wdXQlM0RpbnB1dF9zdHJpbmcuZW5jb2RlKCkpJTBBJTBBJTIwJTIwJTIwJTIwaWYlMjBwcm9jZXNzLnJldHVybmNvZGUlMjAhJTNEJTIwMCUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJhaXNlJTIwVmFsdWVFcnJvcihmJTIyRXJyb3IlMjAlN0Jwcm9jZXNzLnJldHVybmNvZGUlN0QlM0ElMjAlN0JzdGRlcnIuZGVjb2RlKCklN0QlMjIpJTBBJTBBJTIwJTIwJTIwJTIwJTIzJTIwUmV0dXJuJTIwdGhlJTIwb3V0cHV0JTIwYXMlMjBhJTIwc3RyaW5nJTIwYW5kJTIwc2tpcCUyMHRoZSUyMG5ldy1saW5lJTIwY2hhcmFjdGVyJTIwYXQlMjB0aGUlMjBlbmQlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBzdGRvdXQuZGVjb2RlKCklNUIlM0EtMSU1RCUwQSUwQXRleHQlMjAlM0QlMjAlMjIlRUMlOUQlQjQlRUIlQjQlOTAlMjAlRUIlQUMlQjQlRUMlOEElQTglMjAlRUMlOUQlQkMlRUMlOUQlQjQlRUMlOTUlQkMlMjIlMEF1cm9tYWl6ZWRfdGV4dCUyMCUzRCUyMHVyb21hbml6ZSh0ZXh0JTJDJTIwdXJvbWFuX3BhdGglM0Rvcy5lbnZpcm9uJTVCJTIyVVJPTUFOJTIyJTVEKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcih0ZXh0JTNEdXJvbWFpemVkX3RleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXNldF9zZWVkKDU1NSklMjAlMjAlMjMlMjBtYWtlJTIwZGV0ZXJtaW5pc3RpYyUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEKSUwQSUwQXdhdmVmb3JtJTIwJTNEJTIwb3V0cHV0cy53YXZlZm9ybSU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VitsTokenizer, VitsModel, set_seed
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> subprocess

tokenizer = VitsTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/mms-tts-kor&quot;</span>)
model = VitsModel.from_pretrained(<span class="hljs-string">&quot;facebook/mms-tts-kor&quot;</span>)

<span class="hljs-keyword">def</span> <span class="hljs-title function_">uromanize</span>(<span class="hljs-params">input_string, uroman_path</span>):
    <span class="hljs-string">&quot;&quot;&quot;Convert non-Roman strings to Roman using the \`uroman\` perl package.&quot;&quot;&quot;</span>
    script_path = os.path.join(uroman_path, <span class="hljs-string">&quot;bin&quot;</span>, <span class="hljs-string">&quot;uroman.pl&quot;</span>)

    command = [<span class="hljs-string">&quot;perl&quot;</span>, script_path]

    process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    <span class="hljs-comment"># Execute the perl command</span>
    stdout, stderr = process.communicate(<span class="hljs-built_in">input</span>=input_string.encode())

    <span class="hljs-keyword">if</span> process.returncode != <span class="hljs-number">0</span>:
        <span class="hljs-keyword">raise</span> ValueError(<span class="hljs-string">f&quot;Error <span class="hljs-subst">{process.returncode}</span>: <span class="hljs-subst">{stderr.decode()}</span>&quot;</span>)

    <span class="hljs-comment"># Return the output as a string and skip the new-line character at the end</span>
    <span class="hljs-keyword">return</span> stdout.decode()[:-<span class="hljs-number">1</span>]

text = <span class="hljs-string">&quot;이봐 무슨 일이야&quot;</span>
uromaized_text = uromanize(text, uroman_path=os.environ[<span class="hljs-string">&quot;UROMAN&quot;</span>])

inputs = tokenizer(text=uromaized_text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

set_seed(<span class="hljs-number">555</span>)  <span class="hljs-comment"># make deterministic</span>
<span class="hljs-keyword">with</span> torch.no_grad():
   outputs = model(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])

waveform = outputs.waveform[<span class="hljs-number">0</span>]`,wrap:!1}}),we=new f({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVml0c1Rva2VuaXplciUyQyUyMFZpdHNNb2RlbCUyQyUyMHNldF9zZWVkJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwVml0c1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtbXMtdHRzLWVuZyUyMiklMEFtb2RlbCUyMCUzRCUyMFZpdHNNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZtbXMtdHRzLWVuZyUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUzRCUyMkhlbGxvJTIwLSUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElMjMlMjBtYWtlJTIwZGV0ZXJtaW5pc3RpYyUwQXNldF9zZWVkKDU1NSklMjAlMjAlMEElMEElMjMlMjBtYWtlJTIwc3BlZWNoJTIwZmFzdGVyJTIwYW5kJTIwbW9yZSUyMG5vaXN5JTBBbW9kZWwuc3BlYWtpbmdfcmF0ZSUyMCUzRCUyMDEuNSUwQW1vZGVsLm5vaXNlX3NjYWxlJTIwJTNEJTIwMC44JTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VitsTokenizer, VitsModel, set_seed

tokenizer = VitsTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/mms-tts-eng&quot;</span>)
model = VitsModel.from_pretrained(<span class="hljs-string">&quot;facebook/mms-tts-eng&quot;</span>)

inputs = tokenizer(text=<span class="hljs-string">&quot;Hello - my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-comment"># make deterministic</span>
set_seed(<span class="hljs-number">555</span>)  

<span class="hljs-comment"># make speech faster and more noisy</span>
model.speaking_rate = <span class="hljs-number">1.5</span>
model.noise_scale = <span class="hljs-number">0.8</span>

<span class="hljs-keyword">with</span> torch.no_grad():
   outputs = model(**inputs)`,wrap:!1}}),Te=new g({props:{title:"Language Identification (LID)",local:"language-identification-lid",headingTag:"h3"}}),ge=new g({props:{title:"Inference",local:"inference",headingTag:"h4"}}),We=new f({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRvcmNoJTIwYWNjZWxlcmF0ZSUyMGRhdGFzZXRzJTVCYXVkaW8lNUQlMEFwaXAlMjBpbnN0YWxsJTIwLS11cGdyYWRlJTIwdHJhbnNmb3JtZXJz",highlighted:`pip install torch accelerate datasets[audio]
pip install --upgrade transformers`,wrap:!1}}),ve=new f({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEElMjMlMjBFbmdsaXNoJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIybW96aWxsYS1mb3VuZGF0aW9uJTJGY29tbW9uX3ZvaWNlXzEzXzAlMjIlMkMlMjAlMjJlbiUyMiUyQyUyMHNwbGl0JTNEJTIydGVzdCUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUpJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBzdHJlYW1fZGF0YS5jYXN0X2NvbHVtbiglMjJhdWRpbyUyMiUyQyUyMEF1ZGlvKHNhbXBsaW5nX3JhdGUlM0QxNjAwMCkpJTBBZW5fc2FtcGxlJTIwJTNEJTIwbmV4dChpdGVyKHN0cmVhbV9kYXRhKSklNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVEJTBBJTBBJTIzJTIwQXJhYmljJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIybW96aWxsYS1mb3VuZGF0aW9uJTJGY29tbW9uX3ZvaWNlXzEzXzAlMjIlMkMlMjAlMjJhciUyMiUyQyUyMHNwbGl0JTNEJTIydGVzdCUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUpJTBBc3RyZWFtX2RhdGElMjAlM0QlMjBzdHJlYW1fZGF0YS5jYXN0X2NvbHVtbiglMjJhdWRpbyUyMiUyQyUyMEF1ZGlvKHNhbXBsaW5nX3JhdGUlM0QxNjAwMCkpJTBBYXJfc2FtcGxlJTIwJTNEJTIwbmV4dChpdGVyKHN0cmVhbV9kYXRhKSklNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVE",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-comment"># English</span>
stream_data = load_dataset(<span class="hljs-string">&quot;mozilla-foundation/common_voice_13_0&quot;</span>, <span class="hljs-string">&quot;en&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>, streaming=<span class="hljs-literal">True</span>)
stream_data = stream_data.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))
en_sample = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(stream_data))[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>]

<span class="hljs-comment"># Arabic</span>
stream_data = load_dataset(<span class="hljs-string">&quot;mozilla-foundation/common_voice_13_0&quot;</span>, <span class="hljs-string">&quot;ar&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>, streaming=<span class="hljs-literal">True</span>)
stream_data = stream_data.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))
ar_sample = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(stream_data))[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>]`,wrap:!1}}),Ie=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFdhdjJWZWMyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUyQyUyMEF1dG9GZWF0dXJlRXh0cmFjdG9yJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMmZhY2Vib29rJTJGbW1zLWxpZC0xMjYlMjIlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvRmVhdHVyZUV4dHJhY3Rvci5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQpJTBBbW9kZWwlMjAlM0QlMjBXYXYyVmVjMkZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Wav2Vec2ForSequenceClassification, AutoFeatureExtractor
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;facebook/mms-lid-126&quot;</span>

processor = AutoFeatureExtractor.from_pretrained(model_id)
model = Wav2Vec2ForSequenceClassification.from_pretrained(model_id)`,wrap:!1}}),Ce=new f({props:{code:"JTIzJTIwRW5nbGlzaCUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3Nvcihlbl9zYW1wbGUlMkMlMjBzYW1wbGluZ19yYXRlJTNEMTZfMDAwJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb2dpdHMlMEElMEFsYW5nX2lkJTIwJTNEJTIwdG9yY2guYXJnbWF4KG91dHB1dHMlMkMlMjBkaW0lM0QtMSklNUIwJTVELml0ZW0oKSUwQWRldGVjdGVkX2xhbmclMjAlM0QlMjBtb2RlbC5jb25maWcuaWQybGFiZWwlNUJsYW5nX2lkJTVEJTBBJTIzJTIwJ2VuZyclMEElMEElMjMlMjBBcmFiaWMlMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoYXJfc2FtcGxlJTJDJTIwc2FtcGxpbmdfcmF0ZSUzRDE2XzAwMCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBbGFuZ19pZCUyMCUzRCUyMHRvcmNoLmFyZ21heChvdXRwdXRzJTJDJTIwZGltJTNELTEpJTVCMCU1RC5pdGVtKCklMEFkZXRlY3RlZF9sYW5nJTIwJTNEJTIwbW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCbGFuZ19pZCU1RCUwQSUyMyUyMCdhcmEn",highlighted:`<span class="hljs-comment"># English</span>
inputs = processor(en_sample, sampling_rate=<span class="hljs-number">16_000</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = model(**inputs).logits

lang_id = torch.argmax(outputs, dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>].item()
detected_lang = model.config.id2label[lang_id]
<span class="hljs-comment"># &#x27;eng&#x27;</span>

<span class="hljs-comment"># Arabic</span>
inputs = processor(ar_sample, sampling_rate=<span class="hljs-number">16_000</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = model(**inputs).logits

lang_id = torch.argmax(outputs, dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>].item()
detected_lang = model.config.id2label[lang_id]
<span class="hljs-comment"># &#x27;ara&#x27;</span>`,wrap:!1}}),Xe=new f({props:{code:"cHJvY2Vzc29yLmlkMmxhYmVsLnZhbHVlcygp",highlighted:"processor.id2label.values()",wrap:!1}}),Be=new g({props:{title:"Audio Pretrained Models",local:"audio-pretrained-models",headingTag:"h3"}}),W=new Fl({props:{$$slots:{default:[Pl]},$$scope:{ctx:Ge}}}),_e=new Al({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/mms.md"}}),{c(){y=o("meta"),j=a(),J=o("p"),b=a(),p(w.$$.fragment),h=a(),p(T.$$.fragment),Ne=a(),Z=o("p"),Z.innerHTML=el,Fe=a(),v=o("p"),v.textContent=tl,He=a(),k=o("p"),k.innerHTML=ll,Ee=a(),I=o("p"),I.innerHTML=sl,Qe=a(),p($.$$.fragment),Ye=a(),C=o("p"),C.innerHTML=al,xe=a(),R=o("p"),R.textContent=nl,Se=a(),X=o("ul"),X.innerHTML=ol,qe=a(),p(B.$$.fragment),Ae=a(),V=o("p"),V.innerHTML=il,Le=a(),p(_.$$.fragment),Pe=a(),p(U.$$.fragment),Ke=a(),G=o("p"),G.textContent=rl,De=a(),p(z.$$.fragment),Oe=a(),p(N.$$.fragment),et=a(),F=o("p"),F.innerHTML=pl,tt=a(),p(H.$$.fragment),lt=a(),E=o("p"),E.textContent=ml,st=a(),p(Q.$$.fragment),at=a(),Y=o("p"),Y.innerHTML=cl,nt=a(),p(x.$$.fragment),ot=a(),S=o("p"),S.innerHTML=dl,it=a(),p(q.$$.fragment),rt=a(),A=o("p"),A.textContent=ul,pt=a(),p(L.$$.fragment),mt=a(),P=o("p"),P.textContent=Ml,ct=a(),K=o("p"),K.innerHTML=hl,dt=a(),p(D.$$.fragment),ut=a(),O=o("p"),O.innerHTML=yl,Mt=a(),p(ee.$$.fragment),ht=a(),te=o("p"),te.textContent=fl,yt=a(),p(le.$$.fragment),ft=a(),se=o("p"),se.textContent=bl,bt=a(),ae=o("ul"),ae.innerHTML=Jl,Jt=a(),p(ne.$$.fragment),wt=a(),oe=o("p"),oe.innerHTML=wl,Tt=a(),p(ie.$$.fragment),jt=a(),re=o("p"),re.textContent=Tl,gt=a(),p(pe.$$.fragment),Ut=a(),me=o("p"),me.innerHTML=jl,Wt=a(),ce=o("p"),ce.innerHTML=gl,Zt=a(),p(de.$$.fragment),vt=a(),ue=o("p"),ue.innerHTML=Ul,kt=a(),Me=o("p"),Me.innerHTML=Wl,It=a(),p(he.$$.fragment),$t=a(),ye=o("p"),ye.innerHTML=Zl,Ct=a(),p(fe.$$.fragment),Rt=a(),be=o("p"),be.innerHTML=vl,Xt=a(),Je=o("ul"),Je.innerHTML=kl,Bt=a(),p(we.$$.fragment),Vt=a(),p(Te.$$.fragment),_t=a(),je=o("p"),je.innerHTML=Il,Gt=a(),p(ge.$$.fragment),zt=a(),Ue=o("p"),Ue.textContent=$l,Nt=a(),p(We.$$.fragment),Ft=a(),Ze=o("p"),Ze.innerHTML=Cl,Ht=a(),p(ve.$$.fragment),Et=a(),ke=o("p"),ke.textContent=Rl,Qt=a(),p(Ie.$$.fragment),Yt=a(),$e=o("p"),$e.innerHTML=Xl,xt=a(),p(Ce.$$.fragment),St=a(),Re=o("p"),Re.textContent=Bl,qt=a(),p(Xe.$$.fragment),At=a(),p(Be.$$.fragment),Lt=a(),Ve=o("p"),Ve.innerHTML=Vl,Pt=a(),p(W.$$.fragment),Kt=a(),p(_e.$$.fragment),Dt=a(),ze=o("p"),this.h()},l(e){const t=Sl("svelte-u9bgzb",document.head);y=i(t,"META",{name:!0,content:!0}),t.forEach(l),j=n(e),J=i(e,"P",{}),zl(J).forEach(l),b=n(e),m(w.$$.fragment,e),h=n(e),m(T.$$.fragment,e),Ne=n(e),Z=i(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-1lu69tn"&&(Z.innerHTML=el),Fe=n(e),v=i(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-vfdo9a"&&(v.textContent=tl),He=n(e),k=i(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-omjokx"&&(k.innerHTML=ll),Ee=n(e),I=i(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-139x4qi"&&(I.innerHTML=sl),Qe=n(e),m($.$$.fragment,e),Ye=n(e),C=i(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-1ganmax"&&(C.innerHTML=al),xe=n(e),R=i(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-axv494"&&(R.textContent=nl),Se=n(e),X=i(e,"UL",{"data-svelte-h":!0}),r(X)!=="svelte-uegmli"&&(X.innerHTML=ol),qe=n(e),m(B.$$.fragment,e),Ae=n(e),V=i(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-yw6zrr"&&(V.innerHTML=il),Le=n(e),m(_.$$.fragment,e),Pe=n(e),m(U.$$.fragment,e),Ke=n(e),G=i(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-vujju9"&&(G.textContent=rl),De=n(e),m(z.$$.fragment,e),Oe=n(e),m(N.$$.fragment,e),et=n(e),F=i(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-883u4f"&&(F.innerHTML=pl),tt=n(e),m(H.$$.fragment,e),lt=n(e),E=i(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-11gbe5o"&&(E.textContent=ml),st=n(e),m(Q.$$.fragment,e),at=n(e),Y=i(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-1qlg9yi"&&(Y.innerHTML=cl),nt=n(e),m(x.$$.fragment,e),ot=n(e),S=i(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-nswwqv"&&(S.innerHTML=dl),it=n(e),m(q.$$.fragment,e),rt=n(e),A=i(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1okcee"&&(A.textContent=ul),pt=n(e),m(L.$$.fragment,e),mt=n(e),P=i(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-ftdh8u"&&(P.textContent=Ml),ct=n(e),K=i(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-19swadf"&&(K.innerHTML=hl),dt=n(e),m(D.$$.fragment,e),ut=n(e),O=i(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1c7flxd"&&(O.innerHTML=yl),Mt=n(e),m(ee.$$.fragment,e),ht=n(e),te=i(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-1e3j2ci"&&(te.textContent=fl),yt=n(e),m(le.$$.fragment,e),ft=n(e),se=i(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-1fyd5jc"&&(se.textContent=bl),bt=n(e),ae=i(e,"UL",{"data-svelte-h":!0}),r(ae)!=="svelte-llt2bz"&&(ae.innerHTML=Jl),Jt=n(e),m(ne.$$.fragment,e),wt=n(e),oe=i(e,"P",{"data-svelte-h":!0}),r(oe)!=="svelte-1wosc4r"&&(oe.innerHTML=wl),Tt=n(e),m(ie.$$.fragment,e),jt=n(e),re=i(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-1es17w7"&&(re.textContent=Tl),gt=n(e),m(pe.$$.fragment,e),Ut=n(e),me=i(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-wf3m3a"&&(me.innerHTML=jl),Wt=n(e),ce=i(e,"P",{"data-svelte-h":!0}),r(ce)!=="svelte-19haabz"&&(ce.innerHTML=gl),Zt=n(e),m(de.$$.fragment,e),vt=n(e),ue=i(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1cubh3b"&&(ue.innerHTML=Ul),kt=n(e),Me=i(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-14ycm1z"&&(Me.innerHTML=Wl),It=n(e),m(he.$$.fragment,e),$t=n(e),ye=i(e,"P",{"data-svelte-h":!0}),r(ye)!=="svelte-d0ppi5"&&(ye.innerHTML=Zl),Ct=n(e),m(fe.$$.fragment,e),Rt=n(e),be=i(e,"P",{"data-svelte-h":!0}),r(be)!=="svelte-z7vo8h"&&(be.innerHTML=vl),Xt=n(e),Je=i(e,"UL",{"data-svelte-h":!0}),r(Je)!=="svelte-qq0pco"&&(Je.innerHTML=kl),Bt=n(e),m(we.$$.fragment,e),Vt=n(e),m(Te.$$.fragment,e),_t=n(e),je=i(e,"P",{"data-svelte-h":!0}),r(je)!=="svelte-1d4axu2"&&(je.innerHTML=Il),Gt=n(e),m(ge.$$.fragment,e),zt=n(e),Ue=i(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-1h8fqaf"&&(Ue.textContent=$l),Nt=n(e),m(We.$$.fragment,e),Ft=n(e),Ze=i(e,"P",{"data-svelte-h":!0}),r(Ze)!=="svelte-biwzt4"&&(Ze.innerHTML=Cl),Ht=n(e),m(ve.$$.fragment,e),Et=n(e),ke=i(e,"P",{"data-svelte-h":!0}),r(ke)!=="svelte-11gbe5o"&&(ke.textContent=Rl),Qt=n(e),m(Ie.$$.fragment,e),Yt=n(e),$e=i(e,"P",{"data-svelte-h":!0}),r($e)!=="svelte-1tsaj8l"&&($e.innerHTML=Xl),xt=n(e),m(Ce.$$.fragment,e),St=n(e),Re=i(e,"P",{"data-svelte-h":!0}),r(Re)!=="svelte-p73t64"&&(Re.textContent=Bl),qt=n(e),m(Xe.$$.fragment,e),At=n(e),m(Be.$$.fragment,e),Lt=n(e),Ve=i(e,"P",{"data-svelte-h":!0}),r(Ve)!=="svelte-1asto85"&&(Ve.innerHTML=Vl),Pt=n(e),m(W.$$.fragment,e),Kt=n(e),m(_e.$$.fragment,e),Dt=n(e),ze=i(e,"P",{}),zl(ze).forEach(l),this.h()},h(){Nl(y,"name","hf:doc:metadata"),Nl(y,"content",Dl)},m(e,t){ql(document.head,y),s(e,j,t),s(e,J,t),s(e,b,t),c(w,e,t),s(e,h,t),c(T,e,t),s(e,Ne,t),s(e,Z,t),s(e,Fe,t),s(e,v,t),s(e,He,t),s(e,k,t),s(e,Ee,t),s(e,I,t),s(e,Qe,t),c($,e,t),s(e,Ye,t),s(e,C,t),s(e,xe,t),s(e,R,t),s(e,Se,t),s(e,X,t),s(e,qe,t),c(B,e,t),s(e,Ae,t),s(e,V,t),s(e,Le,t),c(_,e,t),s(e,Pe,t),c(U,e,t),s(e,Ke,t),s(e,G,t),s(e,De,t),c(z,e,t),s(e,Oe,t),c(N,e,t),s(e,et,t),s(e,F,t),s(e,tt,t),c(H,e,t),s(e,lt,t),s(e,E,t),s(e,st,t),c(Q,e,t),s(e,at,t),s(e,Y,t),s(e,nt,t),c(x,e,t),s(e,ot,t),s(e,S,t),s(e,it,t),c(q,e,t),s(e,rt,t),s(e,A,t),s(e,pt,t),c(L,e,t),s(e,mt,t),s(e,P,t),s(e,ct,t),s(e,K,t),s(e,dt,t),c(D,e,t),s(e,ut,t),s(e,O,t),s(e,Mt,t),c(ee,e,t),s(e,ht,t),s(e,te,t),s(e,yt,t),c(le,e,t),s(e,ft,t),s(e,se,t),s(e,bt,t),s(e,ae,t),s(e,Jt,t),c(ne,e,t),s(e,wt,t),s(e,oe,t),s(e,Tt,t),c(ie,e,t),s(e,jt,t),s(e,re,t),s(e,gt,t),c(pe,e,t),s(e,Ut,t),s(e,me,t),s(e,Wt,t),s(e,ce,t),s(e,Zt,t),c(de,e,t),s(e,vt,t),s(e,ue,t),s(e,kt,t),s(e,Me,t),s(e,It,t),c(he,e,t),s(e,$t,t),s(e,ye,t),s(e,Ct,t),c(fe,e,t),s(e,Rt,t),s(e,be,t),s(e,Xt,t),s(e,Je,t),s(e,Bt,t),c(we,e,t),s(e,Vt,t),c(Te,e,t),s(e,_t,t),s(e,je,t),s(e,Gt,t),c(ge,e,t),s(e,zt,t),s(e,Ue,t),s(e,Nt,t),c(We,e,t),s(e,Ft,t),s(e,Ze,t),s(e,Ht,t),c(ve,e,t),s(e,Et,t),s(e,ke,t),s(e,Qt,t),c(Ie,e,t),s(e,Yt,t),s(e,$e,t),s(e,xt,t),c(Ce,e,t),s(e,St,t),s(e,Re,t),s(e,qt,t),c(Xe,e,t),s(e,At,t),c(Be,e,t),s(e,Lt,t),s(e,Ve,t),s(e,Pt,t),c(W,e,t),s(e,Kt,t),c(_e,e,t),s(e,Dt,t),s(e,ze,t),Ot=!0},p(e,[t]){const _l={};t&2&&(_l.$$scope={dirty:t,ctx:e}),U.$set(_l);const Gl={};t&2&&(Gl.$$scope={dirty:t,ctx:e}),W.$set(Gl)},i(e){Ot||(d(w.$$.fragment,e),d(T.$$.fragment,e),d($.$$.fragment,e),d(B.$$.fragment,e),d(_.$$.fragment,e),d(U.$$.fragment,e),d(z.$$.fragment,e),d(N.$$.fragment,e),d(H.$$.fragment,e),d(Q.$$.fragment,e),d(x.$$.fragment,e),d(q.$$.fragment,e),d(L.$$.fragment,e),d(D.$$.fragment,e),d(ee.$$.fragment,e),d(le.$$.fragment,e),d(ne.$$.fragment,e),d(ie.$$.fragment,e),d(pe.$$.fragment,e),d(de.$$.fragment,e),d(he.$$.fragment,e),d(fe.$$.fragment,e),d(we.$$.fragment,e),d(Te.$$.fragment,e),d(ge.$$.fragment,e),d(We.$$.fragment,e),d(ve.$$.fragment,e),d(Ie.$$.fragment,e),d(Ce.$$.fragment,e),d(Xe.$$.fragment,e),d(Be.$$.fragment,e),d(W.$$.fragment,e),d(_e.$$.fragment,e),Ot=!0)},o(e){u(w.$$.fragment,e),u(T.$$.fragment,e),u($.$$.fragment,e),u(B.$$.fragment,e),u(_.$$.fragment,e),u(U.$$.fragment,e),u(z.$$.fragment,e),u(N.$$.fragment,e),u(H.$$.fragment,e),u(Q.$$.fragment,e),u(x.$$.fragment,e),u(q.$$.fragment,e),u(L.$$.fragment,e),u(D.$$.fragment,e),u(ee.$$.fragment,e),u(le.$$.fragment,e),u(ne.$$.fragment,e),u(ie.$$.fragment,e),u(pe.$$.fragment,e),u(de.$$.fragment,e),u(he.$$.fragment,e),u(fe.$$.fragment,e),u(we.$$.fragment,e),u(Te.$$.fragment,e),u(ge.$$.fragment,e),u(We.$$.fragment,e),u(ve.$$.fragment,e),u(Ie.$$.fragment,e),u(Ce.$$.fragment,e),u(Xe.$$.fragment,e),u(Be.$$.fragment,e),u(W.$$.fragment,e),u(_e.$$.fragment,e),Ot=!1},d(e){e&&(l(j),l(J),l(b),l(h),l(Ne),l(Z),l(Fe),l(v),l(He),l(k),l(Ee),l(I),l(Qe),l(Ye),l(C),l(xe),l(R),l(Se),l(X),l(qe),l(Ae),l(V),l(Le),l(Pe),l(Ke),l(G),l(De),l(Oe),l(et),l(F),l(tt),l(lt),l(E),l(st),l(at),l(Y),l(nt),l(ot),l(S),l(it),l(rt),l(A),l(pt),l(mt),l(P),l(ct),l(K),l(dt),l(ut),l(O),l(Mt),l(ht),l(te),l(yt),l(ft),l(se),l(bt),l(ae),l(Jt),l(wt),l(oe),l(Tt),l(jt),l(re),l(gt),l(Ut),l(me),l(Wt),l(ce),l(Zt),l(vt),l(ue),l(kt),l(Me),l(It),l($t),l(ye),l(Ct),l(Rt),l(be),l(Xt),l(Je),l(Bt),l(Vt),l(_t),l(je),l(Gt),l(zt),l(Ue),l(Nt),l(Ft),l(Ze),l(Ht),l(Et),l(ke),l(Qt),l(Yt),l($e),l(xt),l(St),l(Re),l(qt),l(At),l(Lt),l(Ve),l(Pt),l(Kt),l(Dt),l(ze)),l(y),M(w,e),M(T,e),M($,e),M(B,e),M(_,e),M(U,e),M(z,e),M(N,e),M(H,e),M(Q,e),M(x,e),M(q,e),M(L,e),M(D,e),M(ee,e),M(le,e),M(ne,e),M(ie,e),M(pe,e),M(de,e),M(he,e),M(fe,e),M(we,e),M(Te,e),M(ge,e),M(We,e),M(ve,e),M(Ie,e),M(Ce,e),M(Xe,e),M(Be,e),M(W,e),M(_e,e)}}}const Dl='{"title":"MMS","local":"mms","sections":[{"title":"Overview","local":"overview","sections":[{"title":"Automatic Speech Recognition (ASR)","local":"automatic-speech-recognition-asr","sections":[{"title":"Loading","local":"loading","sections":[],"depth":4},{"title":"Inference","local":"inference","sections":[],"depth":4}],"depth":3},{"title":"Speech Synthesis (TTS)","local":"speech-synthesis-tts","sections":[{"title":"Inference","local":"inference","sections":[],"depth":4}],"depth":3},{"title":"Language Identification (LID)","local":"language-identification-lid","sections":[{"title":"Inference","local":"inference","sections":[],"depth":4}],"depth":3},{"title":"Audio Pretrained Models","local":"audio-pretrained-models","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ol(Ge){return Ql(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ns extends Yl{constructor(y){super(),xl(this,y,Ol,Kl,El,{})}}export{ns as component};
