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