import{s as Fl,o as Hl,n as Nl}from"../chunks/scheduler.9bc65507.js";import{S as Ql,i as El,g as o,s as a,r as p,A as Yl,h as i,f as l,c as n,j as _l,u as m,x as r,k as Gl,y as xl,a as s,v as c,d,t as M,w as u}from"../chunks/index.707bf1b6.js";import{T as zl}from"../chunks/Tip.c2ecdbf4.js";import{C as f}from"../chunks/CodeBlock.54a9f38d.js";import{H as g}from"../chunks/Heading.342b1fa6.js";function Sl(_e){let y,j="You can safely ignore a warning such as:",b,J,w;return J=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,b=a(),p(J.$$.fragment)},l(h){y=i(h,"P",{"data-svelte-h":!0}),r(y)!=="svelte-17yglm5"&&(y.textContent=j),b=n(h),m(J.$$.fragment,h)},m(h,T){s(h,y,T),s(h,b,T),c(J,h,T),w=!0},p:Nl,i(h){w||(d(J.$$.fragment,h),w=!0)},o(h){M(J.$$.fragment,h),w=!1},d(h){h&&(l(y),l(b)),u(J,h)}}}function ql(_e){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.`,b,J,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,b=a(),J=o("p"),J.innerHTML=w},l(h){y=i(h,"P",{"data-svelte-h":!0}),r(y)!=="svelte-ez75p4"&&(y.innerHTML=j),b=n(h),J=i(h,"P",{"data-svelte-h":!0}),r(J)!=="svelte-102khel"&&(J.innerHTML=w)},m(h,T){s(h,y,T),s(h,b,T),s(h,J,T)},p:Nl,d(h){h&&(l(y),l(b),l(J))}}}function Al(_e){let y,j,b,J,w,h,T,ze,Z,Dt=`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`,Ne,v,Ot="The abstract from the paper is the following:",Fe,k,el=`<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>`,He,I,tl='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,C,Ee,R,ll='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.',Ye,$,sl="Tips:",xe,X,al=`<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/v4.37.1/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/v4.37.1/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/v4.37.1/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>`,Se,B,qe,V,nl=`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`,Ae,_,Le,U,Pe,G,ol="If you want to use the ASR pipeline, you can load your chosen target language as such:",Ke,z,De,N,Oe,F,il=`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>.`,et,H,tt,Q,rl="Next, we load the model and processor",lt,E,st,Y,pl=`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/v4.37.1/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC">Wav2Vec2ForCTC</a>.`,at,x,nt,S,ml=`We can now keep the same model in memory and simply switch out the language adapters by
calling the convenient <a href="/docs/transformers/v4.37.1/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC.load_adapter">load_adapter()</a> function for the model and <a href="/docs/transformers/v4.37.1/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.`,ot,q,it,A,cl="In the same way the language can be switched out for all other supported languages. Please have a look at:",rt,L,pt,P,dl="to see all supported languages.",mt,K,Ml='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.',ct,D,dt,O,ul=`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,ut,te,hl="To use the MMS model, first update to the latest version of the Transformers library:",ht,le,yt,se,yl=`Since the flow-based model in VITS is non-deterministic, it is good practice to set a seed to ensure reproducibility of
the outputs.`,ft,ae,fl=`<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,bt,oe,Jl="The resulting waveform can be saved as a <code>.wav</code> file:",wt,ie,Tt,re,bl="Or displayed in a Jupyter Notebook / Google Colab:",jt,pe,gt,me,wl=`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.`,Ut,ce,Tl=`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>:`,Wt,de,Zt,Me,jl=`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.`,vt,ue,gl="To do this, first clone the uroman repository to your local machine and set the bash variable <code>UROMAN</code> to the local path:",kt,he,It,ye,Ul=`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,Je,Wl="<strong>Tips:</strong>",$t,be,Zl="<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>noramlize=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>",Xt,we,Bt,Te,Vt,je,vl='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>.',_t,ge,Gt,Ue,kl="First, we install transformers and some other libraries",zt,We,Nt,Ze,Il="Next, we load a couple of audio samples via <code>datasets</code>. Make sure that the audio data is sampled to 16000 kHz.",Ft,ve,Ht,ke,Cl="Next, we load the model and processor",Qt,Ie,Et,Ce,Rl='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>',Yt,Re,xt,$e,$l="To see all the supported languages of a checkpoint, you can print out the language ids as follows:",St,Xe,qt,Be,At,Ve,Xl=`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>.`,Lt,W,Pt,Ge,Kt;return w=new g({props:{title:"MMS",local:"mms",headingTag:"h1"}}),T=new g({props:{title:"Overview",local:"overview",headingTag:"h2"}}),C=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 zl({props:{$$slots:{default:[Sl]},$$scope:{ctx:_e}}}),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}}),E=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}}),Re=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 zl({props:{$$slots:{default:[ql]},$$scope:{ctx:_e}}}),{c(){y=o("meta"),j=a(),b=o("p"),J=a(),p(w.$$.fragment),h=a(),p(T.$$.fragment),ze=a(),Z=o("p"),Z.innerHTML=Dt,Ne=a(),v=o("p"),v.textContent=Ot,Fe=a(),k=o("p"),k.innerHTML=el,He=a(),I=o("p"),I.innerHTML=tl,Qe=a(),p(C.$$.fragment),Ee=a(),R=o("p"),R.innerHTML=ll,Ye=a(),$=o("p"),$.textContent=sl,xe=a(),X=o("ul"),X.innerHTML=al,Se=a(),p(B.$$.fragment),qe=a(),V=o("p"),V.innerHTML=nl,Ae=a(),p(_.$$.fragment),Le=a(),p(U.$$.fragment),Pe=a(),G=o("p"),G.textContent=ol,Ke=a(),p(z.$$.fragment),De=a(),p(N.$$.fragment),Oe=a(),F=o("p"),F.innerHTML=il,et=a(),p(H.$$.fragment),tt=a(),Q=o("p"),Q.textContent=rl,lt=a(),p(E.$$.fragment),st=a(),Y=o("p"),Y.innerHTML=pl,at=a(),p(x.$$.fragment),nt=a(),S=o("p"),S.innerHTML=ml,ot=a(),p(q.$$.fragment),it=a(),A=o("p"),A.textContent=cl,rt=a(),p(L.$$.fragment),pt=a(),P=o("p"),P.textContent=dl,mt=a(),K=o("p"),K.innerHTML=Ml,ct=a(),p(D.$$.fragment),dt=a(),O=o("p"),O.innerHTML=ul,Mt=a(),p(ee.$$.fragment),ut=a(),te=o("p"),te.textContent=hl,ht=a(),p(le.$$.fragment),yt=a(),se=o("p"),se.textContent=yl,ft=a(),ae=o("ul"),ae.innerHTML=fl,Jt=a(),p(ne.$$.fragment),bt=a(),oe=o("p"),oe.innerHTML=Jl,wt=a(),p(ie.$$.fragment),Tt=a(),re=o("p"),re.textContent=bl,jt=a(),p(pe.$$.fragment),gt=a(),me=o("p"),me.innerHTML=wl,Ut=a(),ce=o("p"),ce.innerHTML=Tl,Wt=a(),p(de.$$.fragment),Zt=a(),Me=o("p"),Me.innerHTML=jl,vt=a(),ue=o("p"),ue.innerHTML=gl,kt=a(),p(he.$$.fragment),It=a(),ye=o("p"),ye.innerHTML=Ul,Ct=a(),p(fe.$$.fragment),Rt=a(),Je=o("p"),Je.innerHTML=Wl,$t=a(),be=o("ul"),be.innerHTML=Zl,Xt=a(),p(we.$$.fragment),Bt=a(),p(Te.$$.fragment),Vt=a(),je=o("p"),je.innerHTML=vl,_t=a(),p(ge.$$.fragment),Gt=a(),Ue=o("p"),Ue.textContent=kl,zt=a(),p(We.$$.fragment),Nt=a(),Ze=o("p"),Ze.innerHTML=Il,Ft=a(),p(ve.$$.fragment),Ht=a(),ke=o("p"),ke.textContent=Cl,Qt=a(),p(Ie.$$.fragment),Et=a(),Ce=o("p"),Ce.innerHTML=Rl,Yt=a(),p(Re.$$.fragment),xt=a(),$e=o("p"),$e.textContent=$l,St=a(),p(Xe.$$.fragment),qt=a(),p(Be.$$.fragment),At=a(),Ve=o("p"),Ve.innerHTML=Xl,Lt=a(),p(W.$$.fragment),Pt=a(),Ge=o("p"),this.h()},l(e){const t=Yl("svelte-u9bgzb",document.head);y=i(t,"META",{name:!0,content:!0}),t.forEach(l),j=n(e),b=i(e,"P",{}),_l(b).forEach(l),J=n(e),m(w.$$.fragment,e),h=n(e),m(T.$$.fragment,e),ze=n(e),Z=i(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-1lu69tn"&&(Z.innerHTML=Dt),Ne=n(e),v=i(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-vfdo9a"&&(v.textContent=Ot),Fe=n(e),k=i(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-omjokx"&&(k.innerHTML=el),He=n(e),I=i(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-139x4qi"&&(I.innerHTML=tl),Qe=n(e),m(C.$$.fragment,e),Ee=n(e),R=i(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-1ganmax"&&(R.innerHTML=ll),Ye=n(e),$=i(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-axv494"&&($.textContent=sl),xe=n(e),X=i(e,"UL",{"data-svelte-h":!0}),r(X)!=="svelte-863x2z"&&(X.innerHTML=al),Se=n(e),m(B.$$.fragment,e),qe=n(e),V=i(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-yw6zrr"&&(V.innerHTML=nl),Ae=n(e),m(_.$$.fragment,e),Le=n(e),m(U.$$.fragment,e),Pe=n(e),G=i(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-vujju9"&&(G.textContent=ol),Ke=n(e),m(z.$$.fragment,e),De=n(e),m(N.$$.fragment,e),Oe=n(e),F=i(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-883u4f"&&(F.innerHTML=il),et=n(e),m(H.$$.fragment,e),tt=n(e),Q=i(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-11gbe5o"&&(Q.textContent=rl),lt=n(e),m(E.$$.fragment,e),st=n(e),Y=i(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-qotwyx"&&(Y.innerHTML=pl),at=n(e),m(x.$$.fragment,e),nt=n(e),S=i(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-24qy6l"&&(S.innerHTML=ml),ot=n(e),m(q.$$.fragment,e),it=n(e),A=i(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1okcee"&&(A.textContent=cl),rt=n(e),m(L.$$.fragment,e),pt=n(e),P=i(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-ftdh8u"&&(P.textContent=dl),mt=n(e),K=i(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-19swadf"&&(K.innerHTML=Ml),ct=n(e),m(D.$$.fragment,e),dt=n(e),O=i(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1c7flxd"&&(O.innerHTML=ul),Mt=n(e),m(ee.$$.fragment,e),ut=n(e),te=i(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-1e3j2ci"&&(te.textContent=hl),ht=n(e),m(le.$$.fragment,e),yt=n(e),se=i(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-1fyd5jc"&&(se.textContent=yl),ft=n(e),ae=i(e,"UL",{"data-svelte-h":!0}),r(ae)!=="svelte-llt2bz"&&(ae.innerHTML=fl),Jt=n(e),m(ne.$$.fragment,e),bt=n(e),oe=i(e,"P",{"data-svelte-h":!0}),r(oe)!=="svelte-1wosc4r"&&(oe.innerHTML=Jl),wt=n(e),m(ie.$$.fragment,e),Tt=n(e),re=i(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-1es17w7"&&(re.textContent=bl),jt=n(e),m(pe.$$.fragment,e),gt=n(e),me=i(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-wf3m3a"&&(me.innerHTML=wl),Ut=n(e),ce=i(e,"P",{"data-svelte-h":!0}),r(ce)!=="svelte-19haabz"&&(ce.innerHTML=Tl),Wt=n(e),m(de.$$.fragment,e),Zt=n(e),Me=i(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-1cubh3b"&&(Me.innerHTML=jl),vt=n(e),ue=i(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-14ycm1z"&&(ue.innerHTML=gl),kt=n(e),m(he.$$.fragment,e),It=n(e),ye=i(e,"P",{"data-svelte-h":!0}),r(ye)!=="svelte-d0ppi5"&&(ye.innerHTML=Ul),Ct=n(e),m(fe.$$.fragment,e),Rt=n(e),Je=i(e,"P",{"data-svelte-h":!0}),r(Je)!=="svelte-z7vo8h"&&(Je.innerHTML=Wl),$t=n(e),be=i(e,"UL",{"data-svelte-h":!0}),r(be)!=="svelte-1rftsk8"&&(be.innerHTML=Zl),Xt=n(e),m(we.$$.fragment,e),Bt=n(e),m(Te.$$.fragment,e),Vt=n(e),je=i(e,"P",{"data-svelte-h":!0}),r(je)!=="svelte-1d4axu2"&&(je.innerHTML=vl),_t=n(e),m(ge.$$.fragment,e),Gt=n(e),Ue=i(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-1h8fqaf"&&(Ue.textContent=kl),zt=n(e),m(We.$$.fragment,e),Nt=n(e),Ze=i(e,"P",{"data-svelte-h":!0}),r(Ze)!=="svelte-biwzt4"&&(Ze.innerHTML=Il),Ft=n(e),m(ve.$$.fragment,e),Ht=n(e),ke=i(e,"P",{"data-svelte-h":!0}),r(ke)!=="svelte-11gbe5o"&&(ke.textContent=Cl),Qt=n(e),m(Ie.$$.fragment,e),Et=n(e),Ce=i(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-1tsaj8l"&&(Ce.innerHTML=Rl),Yt=n(e),m(Re.$$.fragment,e),xt=n(e),$e=i(e,"P",{"data-svelte-h":!0}),r($e)!=="svelte-p73t64"&&($e.textContent=$l),St=n(e),m(Xe.$$.fragment,e),qt=n(e),m(Be.$$.fragment,e),At=n(e),Ve=i(e,"P",{"data-svelte-h":!0}),r(Ve)!=="svelte-1asto85"&&(Ve.innerHTML=Xl),Lt=n(e),m(W.$$.fragment,e),Pt=n(e),Ge=i(e,"P",{}),_l(Ge).forEach(l),this.h()},h(){Gl(y,"name","hf:doc:metadata"),Gl(y,"content",Ll)},m(e,t){xl(document.head,y),s(e,j,t),s(e,b,t),s(e,J,t),c(w,e,t),s(e,h,t),c(T,e,t),s(e,ze,t),s(e,Z,t),s(e,Ne,t),s(e,v,t),s(e,Fe,t),s(e,k,t),s(e,He,t),s(e,I,t),s(e,Qe,t),c(C,e,t),s(e,Ee,t),s(e,R,t),s(e,Ye,t),s(e,$,t),s(e,xe,t),s(e,X,t),s(e,Se,t),c(B,e,t),s(e,qe,t),s(e,V,t),s(e,Ae,t),c(_,e,t),s(e,Le,t),c(U,e,t),s(e,Pe,t),s(e,G,t),s(e,Ke,t),c(z,e,t),s(e,De,t),c(N,e,t),s(e,Oe,t),s(e,F,t),s(e,et,t),c(H,e,t),s(e,tt,t),s(e,Q,t),s(e,lt,t),c(E,e,t),s(e,st,t),s(e,Y,t),s(e,at,t),c(x,e,t),s(e,nt,t),s(e,S,t),s(e,ot,t),c(q,e,t),s(e,it,t),s(e,A,t),s(e,rt,t),c(L,e,t),s(e,pt,t),s(e,P,t),s(e,mt,t),s(e,K,t),s(e,ct,t),c(D,e,t),s(e,dt,t),s(e,O,t),s(e,Mt,t),c(ee,e,t),s(e,ut,t),s(e,te,t),s(e,ht,t),c(le,e,t),s(e,yt,t),s(e,se,t),s(e,ft,t),s(e,ae,t),s(e,Jt,t),c(ne,e,t),s(e,bt,t),s(e,oe,t),s(e,wt,t),c(ie,e,t),s(e,Tt,t),s(e,re,t),s(e,jt,t),c(pe,e,t),s(e,gt,t),s(e,me,t),s(e,Ut,t),s(e,ce,t),s(e,Wt,t),c(de,e,t),s(e,Zt,t),s(e,Me,t),s(e,vt,t),s(e,ue,t),s(e,kt,t),c(he,e,t),s(e,It,t),s(e,ye,t),s(e,Ct,t),c(fe,e,t),s(e,Rt,t),s(e,Je,t),s(e,$t,t),s(e,be,t),s(e,Xt,t),c(we,e,t),s(e,Bt,t),c(Te,e,t),s(e,Vt,t),s(e,je,t),s(e,_t,t),c(ge,e,t),s(e,Gt,t),s(e,Ue,t),s(e,zt,t),c(We,e,t),s(e,Nt,t),s(e,Ze,t),s(e,Ft,t),c(ve,e,t),s(e,Ht,t),s(e,ke,t),s(e,Qt,t),c(Ie,e,t),s(e,Et,t),s(e,Ce,t),s(e,Yt,t),c(Re,e,t),s(e,xt,t),s(e,$e,t),s(e,St,t),c(Xe,e,t),s(e,qt,t),c(Be,e,t),s(e,At,t),s(e,Ve,t),s(e,Lt,t),c(W,e,t),s(e,Pt,t),s(e,Ge,t),Kt=!0},p(e,[t]){const Bl={};t&2&&(Bl.$$scope={dirty:t,ctx:e}),U.$set(Bl);const Vl={};t&2&&(Vl.$$scope={dirty:t,ctx:e}),W.$set(Vl)},i(e){Kt||(d(w.$$.fragment,e),d(T.$$.fragment,e),d(C.$$.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(E.$$.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(Re.$$.fragment,e),d(Xe.$$.fragment,e),d(Be.$$.fragment,e),d(W.$$.fragment,e),Kt=!0)},o(e){M(w.$$.fragment,e),M(T.$$.fragment,e),M(C.$$.fragment,e),M(B.$$.fragment,e),M(_.$$.fragment,e),M(U.$$.fragment,e),M(z.$$.fragment,e),M(N.$$.fragment,e),M(H.$$.fragment,e),M(E.$$.fragment,e),M(x.$$.fragment,e),M(q.$$.fragment,e),M(L.$$.fragment,e),M(D.$$.fragment,e),M(ee.$$.fragment,e),M(le.$$.fragment,e),M(ne.$$.fragment,e),M(ie.$$.fragment,e),M(pe.$$.fragment,e),M(de.$$.fragment,e),M(he.$$.fragment,e),M(fe.$$.fragment,e),M(we.$$.fragment,e),M(Te.$$.fragment,e),M(ge.$$.fragment,e),M(We.$$.fragment,e),M(ve.$$.fragment,e),M(Ie.$$.fragment,e),M(Re.$$.fragment,e),M(Xe.$$.fragment,e),M(Be.$$.fragment,e),M(W.$$.fragment,e),Kt=!1},d(e){e&&(l(j),l(b),l(J),l(h),l(ze),l(Z),l(Ne),l(v),l(Fe),l(k),l(He),l(I),l(Qe),l(Ee),l(R),l(Ye),l($),l(xe),l(X),l(Se),l(qe),l(V),l(Ae),l(Le),l(Pe),l(G),l(Ke),l(De),l(Oe),l(F),l(et),l(tt),l(Q),l(lt),l(st),l(Y),l(at),l(nt),l(S),l(ot),l(it),l(A),l(rt),l(pt),l(P),l(mt),l(K),l(ct),l(dt),l(O),l(Mt),l(ut),l(te),l(ht),l(yt),l(se),l(ft),l(ae),l(Jt),l(bt),l(oe),l(wt),l(Tt),l(re),l(jt),l(gt),l(me),l(Ut),l(ce),l(Wt),l(Zt),l(Me),l(vt),l(ue),l(kt),l(It),l(ye),l(Ct),l(Rt),l(Je),l($t),l(be),l(Xt),l(Bt),l(Vt),l(je),l(_t),l(Gt),l(Ue),l(zt),l(Nt),l(Ze),l(Ft),l(Ht),l(ke),l(Qt),l(Et),l(Ce),l(Yt),l(xt),l($e),l(St),l(qt),l(At),l(Ve),l(Lt),l(Pt),l(Ge)),l(y),u(w,e),u(T,e),u(C,e),u(B,e),u(_,e),u(U,e),u(z,e),u(N,e),u(H,e),u(E,e),u(x,e),u(q,e),u(L,e),u(D,e),u(ee,e),u(le,e),u(ne,e),u(ie,e),u(pe,e),u(de,e),u(he,e),u(fe,e),u(we,e),u(Te,e),u(ge,e),u(We,e),u(ve,e),u(Ie,e),u(Re,e),u(Xe,e),u(Be,e),u(W,e)}}}const Ll='{"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 Pl(_e){return Hl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ls extends Ql{constructor(y){super(),El(this,y,Pl,Al,Fl,{})}}export{ls as component};
