import{S as lr,i as tr,s as sr,e as o,k as c,w as m,t,M as or,c as r,d as a,m as d,a as n,x as f,h as s,b as h,G as l,g as p,y,q as M,o as g,B as w,v as rr,L as nr}from"../../chunks/vendor-hf-doc-builder.js";import{T as ir}from"../../chunks/Tip-hf-doc-builder.js";import{I as Q}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as k}from"../../chunks/CodeBlock-hf-doc-builder.js";function hr(Na){let v,Y,j,J,Z;return J=new k({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.`}}),{c(){v=o("p"),Y=t("You can safely ignore a warning such as:"),j=c(),m(J.$$.fragment)},l(u){v=r(u,"P",{});var $=n(v);Y=s($,"You can safely ignore a warning such as:"),$.forEach(a),j=d(u),f(J.$$.fragment,u)},m(u,$){p(u,v,$),l(v,Y),p(u,j,$),y(J,u,$),Z=!0},p:nr,i(u){Z||(M(J.$$.fragment,u),Z=!0)},o(u){g(J.$$.fragment,u),Z=!1},d(u){u&&a(v),u&&a(j),w(J,u)}}}function pr(Na){let v,Y,j,J,Z,u,$,ma,Ql,Ca,G,x,fa,ie,Yl,ya,xl,Fa,H,Hl,he,ql,Pl,Sa,Pe,Ll,za,Le,Ma,Dl,Qa,R,Kl,pe,Ol,et,ga,at,lt,Ya,A,q,wa,ce,tt,ba,st,xa,T,ot,de,rt,nt,ue,it,ht,me,pt,ct,va,dt,ut,Ha,De,mt,qa,B,fe,ft,Ke,yt,Mt,gt,ye,wt,Oe,bt,vt,Jt,Me,jt,ea,Tt,_t,Pa,V,P,Ja,ge,Ut,ja,Et,La,U,Wt,Ta,kt,Zt,_a,$t,Rt,Ua,Bt,Xt,Da,we,Ka,L,Oa,aa,It,el,be,al,N,D,Ea,ve,Gt,Wa,At,ll,X,Vt,ka,Nt,Ct,Je,Ft,St,tl,je,sl,la,zt,ol,Te,rl,K,Qt,ta,Yt,xt,nl,_e,il,E,Ht,sa,qt,Pt,oa,Lt,Dt,Za,Kt,Ot,hl,Ue,pl,ra,es,cl,Ee,dl,na,as,ul,O,ls,We,ts,ss,ml,C,ee,$a,ke,os,Ra,rs,fl,ae,ns,Ze,is,hs,yl,F,le,Ba,$e,ps,Xa,cs,Ml,b,ds,Re,us,ms,Be,fs,ys,Xe,Ms,gs,Ie,ws,bs,Ge,vs,Js,Ae,js,Ts,gl,S,te,Ia,Ve,_s,Ga,Us,wl,Ne,bl,ia,Es,vl,Ce,Jl,Fe,Ws,Se,ks,jl,ze,Tl,ha,Zs,_l,Qe,Ul,z,se,Aa,Ye,$s,Va,Rs,El,W,Bs,xe,Xs,Is,He,Gs,As,pa,Vs,Ns,Wl;return u=new Q({}),ie=new Q({}),ce=new Q({}),ge=new Q({}),we=new k({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>)`}}),L=new ir({props:{$$slots:{default:[hr]},$$scope:{ctx:Na}}}),be=new k({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>})`}}),ve=new Q({}),je=new k({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>]`}}),Te=new k({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)`}}),_e=new k({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>`}}),Ue=new k({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\xE9 tout au long de l&#x27;histoire romaine&quot;</span>`}}),Ee=new k({props:{code:"cHJvY2Vzc29yLnRva2VuaXplci52b2NhYi5rZXlzKCk=",highlighted:"processor.tokenizer.vocab.keys()"}}),ke=new Q({}),$e=new Q({}),Ve=new Q({}),Ne=new k({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>]`}}),Ce=new k({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)`}}),ze=new k({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>`}}),Qe=new k({props:{code:"cHJvY2Vzc29yLmlkMmxhYmVsLnZhbHVlcygp",highlighted:"processor.id2label.values()"}}),Ye=new Q({}),{c(){v=o("meta"),Y=c(),j=o("h1"),J=o("a"),Z=o("span"),m(u.$$.fragment),$=c(),ma=o("span"),Ql=t("MMS"),Ca=c(),G=o("h2"),x=o("a"),fa=o("span"),m(ie.$$.fragment),Yl=c(),ya=o("span"),xl=t("Overview"),Fa=c(),H=o("p"),Hl=t("The MMS model was proposed in "),he=o("a"),ql=t("Scaling Speech Technology to 1,000+ Languages"),Pl=t(`
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`),Sa=c(),Pe=o("p"),Ll=t("The abstract from the paper is the following:"),za=c(),Le=o("p"),Ma=o("em"),Dl=t(`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.`),Qa=c(),R=o("p"),Kl=t("Here are the different models open sourced in the MMS project. The models and code are originally released "),pe=o("a"),Ol=t("here"),et=t(". We have add them to the "),ga=o("code"),at=t("transformers"),lt=t(" framework, making them easier to use."),Ya=c(),A=o("h3"),q=o("a"),wa=o("span"),m(ce.$$.fragment),tt=c(),ba=o("span"),st=t("Automatic Speech Recognition (ASR)"),xa=c(),T=o("p"),ot=t("The ASR model checkpoints  can be found here : "),de=o("a"),rt=t("mms-1b-fl102"),nt=t(", "),ue=o("a"),it=t("mms-1b-l1107"),ht=t(", "),me=o("a"),pt=t("mms-1b-all"),ct=t(". For best accuracy, use the "),va=o("code"),dt=t("mms-1b-all"),ut=t(" model."),Ha=c(),De=o("p"),mt=t("Tips:"),qa=c(),B=o("ul"),fe=o("li"),ft=t("All ASR models accept a float array corresponding to the raw waveform of the speech signal. The raw waveform should be pre-processed with "),Ke=o("a"),yt=t("Wav2Vec2FeatureExtractor"),Mt=t("."),gt=c(),ye=o("li"),wt=t(`The models were trained using connectionist temporal classification (CTC) so the model output has to be decoded using
`),Oe=o("a"),bt=t("Wav2Vec2CTCTokenizer"),vt=t("."),Jt=c(),Me=o("li"),jt=t("You can load different language adapter weights for different languages via "),ea=o("a"),Tt=t("load_adapter()"),_t=t(`. Language adapters only consists of roughly 2 million parameters
and can therefore be efficiently loaded on the fly when needed.`),Pa=c(),V=o("h4"),P=o("a"),Ja=o("span"),m(ge.$$.fragment),Ut=c(),ja=o("span"),Et=t("Loading"),La=c(),U=o("p"),Wt=t(`By default MMS loads adapter weights for English. If you want to load adapter weights of another language
make sure to specify `),Ta=o("code"),kt=t("target_lang=<your-chosen-target-lang>"),Zt=t(" as well as "),_a=o("code"),$t=t('"ignore_mismatched_sizes=True'),Rt=t(`.
The `),Ua=o("code"),Bt=t("ignore_mismatched_sizes=True"),Xt=t(` 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`),Da=c(),m(we.$$.fragment),Ka=c(),m(L.$$.fragment),Oa=c(),aa=o("p"),It=t("If you want to use the ASR pipeline, you can load your chosen target language as such:"),el=c(),m(be.$$.fragment),al=c(),N=o("h4"),D=o("a"),Ea=o("span"),m(ve.$$.fragment),Gt=c(),Wa=o("span"),At=t("Inference"),ll=c(),X=o("p"),Vt=t("Next, let\u2019s look at how we can run MMS in inference and change adapter layers after having called "),ka=o("code"),Nt=t("~PretrainedModel.from_pretrained"),Ct=t(`
First, we load audio data in different languages using the `),Je=o("a"),Ft=t("Datasets"),St=t("."),tl=c(),m(je.$$.fragment),sl=c(),la=o("p"),zt=t("Next, we load the model and processor"),ol=c(),m(Te.$$.fragment),rl=c(),K=o("p"),Qt=t(`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 `),ta=o("a"),Yt=t("Wav2Vec2ForCTC"),xt=t("."),nl=c(),m(_e.$$.fragment),il=c(),E=o("p"),Ht=t(`We can now keep the same model in memory and simply switch out the language adapters by
calling the convenient `),sa=o("a"),qt=t("load_adapter()"),Pt=t(" function for the model and "),oa=o("a"),Lt=t("set_target_lang()"),Dt=t(` for the tokenizer.
We pass the target language as an input - `),Za=o("code"),Kt=t('"fra"'),Ot=t(" for French."),hl=c(),m(Ue.$$.fragment),pl=c(),ra=o("p"),es=t("In the same way the language can be switched out for all other supported languages. Please have a look at:"),cl=c(),m(Ee.$$.fragment),dl=c(),na=o("p"),as=t("to see all supported languages."),ul=c(),O=o("p"),ls=t("To further improve performance from ASR models, language model decoding can be used. See the documentation "),We=o("a"),ts=t("here"),ss=t(" for further details."),ml=c(),C=o("h3"),ee=o("a"),$a=o("span"),m(ke.$$.fragment),os=c(),Ra=o("span"),rs=t("Speech Synthesis (TTS)"),fl=c(),ae=o("p"),ns=t("Individual TTS models are available for each of the 1100+ languages. The models and inference documentation can be found "),Ze=o("a"),is=t("here"),hs=t("."),yl=c(),F=o("h3"),le=o("a"),Ba=o("span"),m($e.$$.fragment),ps=c(),Xa=o("span"),cs=t("Language Identification (LID)"),Ml=c(),b=o("p"),ds=t("Different LID models are available based on the number of languages they can recognize - "),Re=o("a"),us=t("126"),ms=t(", "),Be=o("a"),fs=t("256"),ys=t(", "),Xe=o("a"),Ms=t("512"),gs=t(", "),Ie=o("a"),ws=t("1024"),bs=t(", "),Ge=o("a"),vs=t("2048"),Js=t(", "),Ae=o("a"),js=t("4017"),Ts=t("."),gl=c(),S=o("h4"),te=o("a"),Ia=o("span"),m(Ve.$$.fragment),_s=c(),Ga=o("span"),Us=t("Inference"),wl=t(`

First, we install transformers and some other libraries
\`\`\`
pip install torch accelerate torchaudio datasets
pip install --upgrade transformers
\`\`\`\`
pip install torch datasets[audio]
Next, we load a couple of audio samples via \`datasets\`. Make sure that the audio data is sampled to 16000 kHz.

	`),m(Ne.$$.fragment),bl=c(),ia=o("p"),Es=t("Next, we load the model and processor"),vl=c(),m(Ce.$$.fragment),Jl=c(),Fe=o("p"),Ws=t("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 "),Se=o("a"),ks=t("ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition"),jl=c(),m(ze.$$.fragment),Tl=c(),ha=o("p"),Zs=t("To see all the supported languages of a checkpoint, you can print out the language ids as follows:"),_l=c(),m(Qe.$$.fragment),Ul=c(),z=o("h3"),se=o("a"),Aa=o("span"),m(Ye.$$.fragment),$s=c(),Va=o("span"),Rs=t("Audio Pretrained Models"),El=c(),W=o("p"),Bs=t("Pretrained models are available for two different sizes - "),xe=o("a"),Xs=t("300M"),Is=t(" , "),He=o("a"),Gs=t("1Bil"),As=t(". The architecture is based on the Wav2Vec2 model, so one can refer to "),pa=o("a"),Vs=t("Wav2Vec2\u2019s documentation page"),Ns=t(" for further details on how to finetune with models for various downstream tasks."),this.h()},l(e){const i=or('[data-svelte="svelte-1phssyn"]',document.head);v=r(i,"META",{name:!0,content:!0}),i.forEach(a),Y=d(e),j=r(e,"H1",{class:!0});var qe=n(j);J=r(qe,"A",{id:!0,class:!0,href:!0});var Fs=n(J);Z=r(Fs,"SPAN",{});var Ss=n(Z);f(u.$$.fragment,Ss),Ss.forEach(a),Fs.forEach(a),$=d(qe),ma=r(qe,"SPAN",{});var zs=n(ma);Ql=s(zs,"MMS"),zs.forEach(a),qe.forEach(a),Ca=d(e),G=r(e,"H2",{class:!0});var kl=n(G);x=r(kl,"A",{id:!0,class:!0,href:!0});var Qs=n(x);fa=r(Qs,"SPAN",{});var Ys=n(fa);f(ie.$$.fragment,Ys),Ys.forEach(a),Qs.forEach(a),Yl=d(kl),ya=r(kl,"SPAN",{});var xs=n(ya);xl=s(xs,"Overview"),xs.forEach(a),kl.forEach(a),Fa=d(e),H=r(e,"P",{});var Zl=n(H);Hl=s(Zl,"The MMS model was proposed in "),he=r(Zl,"A",{href:!0,rel:!0});var Hs=n(he);ql=s(Hs,"Scaling Speech Technology to 1,000+ Languages"),Hs.forEach(a),Pl=s(Zl,`
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`),Zl.forEach(a),Sa=d(e),Pe=r(e,"P",{});var qs=n(Pe);Ll=s(qs,"The abstract from the paper is the following:"),qs.forEach(a),za=d(e),Le=r(e,"P",{});var Ps=n(Le);Ma=r(Ps,"EM",{});var Ls=n(Ma);Dl=s(Ls,`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.`),Ls.forEach(a),Ps.forEach(a),Qa=d(e),R=r(e,"P",{});var ca=n(R);Kl=s(ca,"Here are the different models open sourced in the MMS project. The models and code are originally released "),pe=r(ca,"A",{href:!0,rel:!0});var Ds=n(pe);Ol=s(Ds,"here"),Ds.forEach(a),et=s(ca,". We have add them to the "),ga=r(ca,"CODE",{});var Ks=n(ga);at=s(Ks,"transformers"),Ks.forEach(a),lt=s(ca," framework, making them easier to use."),ca.forEach(a),Ya=d(e),A=r(e,"H3",{class:!0});var $l=n(A);q=r($l,"A",{id:!0,class:!0,href:!0});var Os=n(q);wa=r(Os,"SPAN",{});var eo=n(wa);f(ce.$$.fragment,eo),eo.forEach(a),Os.forEach(a),tt=d($l),ba=r($l,"SPAN",{});var ao=n(ba);st=s(ao,"Automatic Speech Recognition (ASR)"),ao.forEach(a),$l.forEach(a),xa=d(e),T=r(e,"P",{});var I=n(T);ot=s(I,"The ASR model checkpoints  can be found here : "),de=r(I,"A",{href:!0,rel:!0});var lo=n(de);rt=s(lo,"mms-1b-fl102"),lo.forEach(a),nt=s(I,", "),ue=r(I,"A",{href:!0,rel:!0});var to=n(ue);it=s(to,"mms-1b-l1107"),to.forEach(a),ht=s(I,", "),me=r(I,"A",{href:!0,rel:!0});var so=n(me);pt=s(so,"mms-1b-all"),so.forEach(a),ct=s(I,". For best accuracy, use the "),va=r(I,"CODE",{});var oo=n(va);dt=s(oo,"mms-1b-all"),oo.forEach(a),ut=s(I," model."),I.forEach(a),Ha=d(e),De=r(e,"P",{});var ro=n(De);mt=s(ro,"Tips:"),ro.forEach(a),qa=d(e),B=r(e,"UL",{});var da=n(B);fe=r(da,"LI",{});var Rl=n(fe);ft=s(Rl,"All ASR models accept a float array corresponding to the raw waveform of the speech signal. The raw waveform should be pre-processed with "),Ke=r(Rl,"A",{href:!0});var no=n(Ke);yt=s(no,"Wav2Vec2FeatureExtractor"),no.forEach(a),Mt=s(Rl,"."),Rl.forEach(a),gt=d(da),ye=r(da,"LI",{});var Bl=n(ye);wt=s(Bl,`The models were trained using connectionist temporal classification (CTC) so the model output has to be decoded using
`),Oe=r(Bl,"A",{href:!0});var io=n(Oe);bt=s(io,"Wav2Vec2CTCTokenizer"),io.forEach(a),vt=s(Bl,"."),Bl.forEach(a),Jt=d(da),Me=r(da,"LI",{});var Xl=n(Me);jt=s(Xl,"You can load different language adapter weights for different languages via "),ea=r(Xl,"A",{href:!0});var ho=n(ea);Tt=s(ho,"load_adapter()"),ho.forEach(a),_t=s(Xl,`. Language adapters only consists of roughly 2 million parameters
and can therefore be efficiently loaded on the fly when needed.`),Xl.forEach(a),da.forEach(a),Pa=d(e),V=r(e,"H4",{class:!0});var Il=n(V);P=r(Il,"A",{id:!0,class:!0,href:!0});var po=n(P);Ja=r(po,"SPAN",{});var co=n(Ja);f(ge.$$.fragment,co),co.forEach(a),po.forEach(a),Ut=d(Il),ja=r(Il,"SPAN",{});var uo=n(ja);Et=s(uo,"Loading"),uo.forEach(a),Il.forEach(a),La=d(e),U=r(e,"P",{});var oe=n(U);Wt=s(oe,`By default MMS loads adapter weights for English. If you want to load adapter weights of another language
make sure to specify `),Ta=r(oe,"CODE",{});var mo=n(Ta);kt=s(mo,"target_lang=<your-chosen-target-lang>"),mo.forEach(a),Zt=s(oe," as well as "),_a=r(oe,"CODE",{});var fo=n(_a);$t=s(fo,'"ignore_mismatched_sizes=True'),fo.forEach(a),Rt=s(oe,`.
The `),Ua=r(oe,"CODE",{});var yo=n(Ua);Bt=s(yo,"ignore_mismatched_sizes=True"),yo.forEach(a),Xt=s(oe,` 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`),oe.forEach(a),Da=d(e),f(we.$$.fragment,e),Ka=d(e),f(L.$$.fragment,e),Oa=d(e),aa=r(e,"P",{});var Mo=n(aa);It=s(Mo,"If you want to use the ASR pipeline, you can load your chosen target language as such:"),Mo.forEach(a),el=d(e),f(be.$$.fragment,e),al=d(e),N=r(e,"H4",{class:!0});var Gl=n(N);D=r(Gl,"A",{id:!0,class:!0,href:!0});var go=n(D);Ea=r(go,"SPAN",{});var wo=n(Ea);f(ve.$$.fragment,wo),wo.forEach(a),go.forEach(a),Gt=d(Gl),Wa=r(Gl,"SPAN",{});var bo=n(Wa);At=s(bo,"Inference"),bo.forEach(a),Gl.forEach(a),ll=d(e),X=r(e,"P",{});var ua=n(X);Vt=s(ua,"Next, let\u2019s look at how we can run MMS in inference and change adapter layers after having called "),ka=r(ua,"CODE",{});var vo=n(ka);Nt=s(vo,"~PretrainedModel.from_pretrained"),vo.forEach(a),Ct=s(ua,`
First, we load audio data in different languages using the `),Je=r(ua,"A",{href:!0,rel:!0});var Jo=n(Je);Ft=s(Jo,"Datasets"),Jo.forEach(a),St=s(ua,"."),ua.forEach(a),tl=d(e),f(je.$$.fragment,e),sl=d(e),la=r(e,"P",{});var jo=n(la);zt=s(jo,"Next, we load the model and processor"),jo.forEach(a),ol=d(e),f(Te.$$.fragment,e),rl=d(e),K=r(e,"P",{});var Al=n(K);Qt=s(Al,`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 `),ta=r(Al,"A",{href:!0});var To=n(ta);Yt=s(To,"Wav2Vec2ForCTC"),To.forEach(a),xt=s(Al,"."),Al.forEach(a),nl=d(e),f(_e.$$.fragment,e),il=d(e),E=r(e,"P",{});var re=n(E);Ht=s(re,`We can now keep the same model in memory and simply switch out the language adapters by
calling the convenient `),sa=r(re,"A",{href:!0});var _o=n(sa);qt=s(_o,"load_adapter()"),_o.forEach(a),Pt=s(re," function for the model and "),oa=r(re,"A",{href:!0});var Uo=n(oa);Lt=s(Uo,"set_target_lang()"),Uo.forEach(a),Dt=s(re,` for the tokenizer.
We pass the target language as an input - `),Za=r(re,"CODE",{});var Eo=n(Za);Kt=s(Eo,'"fra"'),Eo.forEach(a),Ot=s(re," for French."),re.forEach(a),hl=d(e),f(Ue.$$.fragment,e),pl=d(e),ra=r(e,"P",{});var Wo=n(ra);es=s(Wo,"In the same way the language can be switched out for all other supported languages. Please have a look at:"),Wo.forEach(a),cl=d(e),f(Ee.$$.fragment,e),dl=d(e),na=r(e,"P",{});var ko=n(na);as=s(ko,"to see all supported languages."),ko.forEach(a),ul=d(e),O=r(e,"P",{});var Vl=n(O);ls=s(Vl,"To further improve performance from ASR models, language model decoding can be used. See the documentation "),We=r(Vl,"A",{href:!0,rel:!0});var Zo=n(We);ts=s(Zo,"here"),Zo.forEach(a),ss=s(Vl," for further details."),Vl.forEach(a),ml=d(e),C=r(e,"H3",{class:!0});var Nl=n(C);ee=r(Nl,"A",{id:!0,class:!0,href:!0});var $o=n(ee);$a=r($o,"SPAN",{});var Ro=n($a);f(ke.$$.fragment,Ro),Ro.forEach(a),$o.forEach(a),os=d(Nl),Ra=r(Nl,"SPAN",{});var Bo=n(Ra);rs=s(Bo,"Speech Synthesis (TTS)"),Bo.forEach(a),Nl.forEach(a),fl=d(e),ae=r(e,"P",{});var Cl=n(ae);ns=s(Cl,"Individual TTS models are available for each of the 1100+ languages. The models and inference documentation can be found "),Ze=r(Cl,"A",{href:!0,rel:!0});var Xo=n(Ze);is=s(Xo,"here"),Xo.forEach(a),hs=s(Cl,"."),Cl.forEach(a),yl=d(e),F=r(e,"H3",{class:!0});var Fl=n(F);le=r(Fl,"A",{id:!0,class:!0,href:!0});var Io=n(le);Ba=r(Io,"SPAN",{});var Go=n(Ba);f($e.$$.fragment,Go),Go.forEach(a),Io.forEach(a),ps=d(Fl),Xa=r(Fl,"SPAN",{});var Ao=n(Xa);cs=s(Ao,"Language Identification (LID)"),Ao.forEach(a),Fl.forEach(a),Ml=d(e),b=r(e,"P",{});var _=n(b);ds=s(_,"Different LID models are available based on the number of languages they can recognize - "),Re=r(_,"A",{href:!0,rel:!0});var Vo=n(Re);us=s(Vo,"126"),Vo.forEach(a),ms=s(_,", "),Be=r(_,"A",{href:!0,rel:!0});var No=n(Be);fs=s(No,"256"),No.forEach(a),ys=s(_,", "),Xe=r(_,"A",{href:!0,rel:!0});var Co=n(Xe);Ms=s(Co,"512"),Co.forEach(a),gs=s(_,", "),Ie=r(_,"A",{href:!0,rel:!0});var Fo=n(Ie);ws=s(Fo,"1024"),Fo.forEach(a),bs=s(_,", "),Ge=r(_,"A",{href:!0,rel:!0});var So=n(Ge);vs=s(So,"2048"),So.forEach(a),Js=s(_,", "),Ae=r(_,"A",{href:!0,rel:!0});var zo=n(Ae);js=s(zo,"4017"),zo.forEach(a),Ts=s(_,"."),_.forEach(a),gl=d(e),S=r(e,"H4",{class:!0});var Sl=n(S);te=r(Sl,"A",{id:!0,class:!0,href:!0});var Qo=n(te);Ia=r(Qo,"SPAN",{});var Yo=n(Ia);f(Ve.$$.fragment,Yo),Yo.forEach(a),Qo.forEach(a),_s=d(Sl),Ga=r(Sl,"SPAN",{});var xo=n(Ga);Us=s(xo,"Inference"),xo.forEach(a),Sl.forEach(a),wl=s(e,`

First, we install transformers and some other libraries
\`\`\`
pip install torch accelerate torchaudio datasets
pip install --upgrade transformers
\`\`\`\`
pip install torch datasets[audio]
Next, we load a couple of audio samples via \`datasets\`. Make sure that the audio data is sampled to 16000 kHz.

	`),f(Ne.$$.fragment,e),bl=d(e),ia=r(e,"P",{});var Ho=n(ia);Es=s(Ho,"Next, we load the model and processor"),Ho.forEach(a),vl=d(e),f(Ce.$$.fragment,e),Jl=d(e),Fe=r(e,"P",{});var Cs=n(Fe);Ws=s(Cs,"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 "),Se=r(Cs,"A",{href:!0,rel:!0});var qo=n(Se);ks=s(qo,"ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition"),qo.forEach(a),Cs.forEach(a),jl=d(e),f(ze.$$.fragment,e),Tl=d(e),ha=r(e,"P",{});var Po=n(ha);Zs=s(Po,"To see all the supported languages of a checkpoint, you can print out the language ids as follows:"),Po.forEach(a),_l=d(e),f(Qe.$$.fragment,e),Ul=d(e),z=r(e,"H3",{class:!0});var zl=n(z);se=r(zl,"A",{id:!0,class:!0,href:!0});var Lo=n(se);Aa=r(Lo,"SPAN",{});var Do=n(Aa);f(Ye.$$.fragment,Do),Do.forEach(a),Lo.forEach(a),$s=d(zl),Va=r(zl,"SPAN",{});var Ko=n(Va);Rs=s(Ko,"Audio Pretrained Models"),Ko.forEach(a),zl.forEach(a),El=d(e),W=r(e,"P",{});var ne=n(W);Bs=s(ne,"Pretrained models are available for two different sizes - "),xe=r(ne,"A",{href:!0,rel:!0});var Oo=n(xe);Xs=s(Oo,"300M"),Oo.forEach(a),Is=s(ne," , "),He=r(ne,"A",{href:!0,rel:!0});var er=n(He);Gs=s(er,"1Bil"),er.forEach(a),As=s(ne,". The architecture is based on the Wav2Vec2 model, so one can refer to "),pa=r(ne,"A",{href:!0});var ar=n(pa);Vs=s(ar,"Wav2Vec2\u2019s documentation page"),ar.forEach(a),Ns=s(ne," for further details on how to finetune with models for various downstream tasks."),ne.forEach(a),this.h()},h(){h(v,"name","hf:doc:metadata"),h(v,"content",JSON.stringify(cr)),h(J,"id","mms"),h(J,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(J,"href","#mms"),h(j,"class","relative group"),h(x,"id","overview"),h(x,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(x,"href","#overview"),h(G,"class","relative group"),h(he,"href","https://arxiv.org/abs/2305.13516"),h(he,"rel","nofollow"),h(pe,"href","https://github.com/facebookresearch/fairseq/tree/main/examples/mms"),h(pe,"rel","nofollow"),h(q,"id","automatic-speech-recognition-asr"),h(q,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(q,"href","#automatic-speech-recognition-asr"),h(A,"class","relative group"),h(de,"href","https://huggingface.co/facebook/mms-1b-fl102"),h(de,"rel","nofollow"),h(ue,"href","https://huggingface.co/facebook/mms-1b-l1107"),h(ue,"rel","nofollow"),h(me,"href","https://huggingface.co/facebook/mms-1b-all"),h(me,"rel","nofollow"),h(Ke,"href","/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2FeatureExtractor"),h(Oe,"href","/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer"),h(ea,"href","/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC.load_adapter"),h(P,"id","loading"),h(P,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(P,"href","#loading"),h(V,"class","relative group"),h(D,"id","inference"),h(D,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(D,"href","#inference"),h(N,"class","relative group"),h(Je,"href","https://github.com/huggingface/datasets"),h(Je,"rel","nofollow"),h(ta,"href","/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC"),h(sa,"href","/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2ForCTC.load_adapter"),h(oa,"href","/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.set_target_lang"),h(We,"href","https://huggingface.co/facebook/mms-1b-all"),h(We,"rel","nofollow"),h(ee,"id","speech-synthesis-tts"),h(ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(ee,"href","#speech-synthesis-tts"),h(C,"class","relative group"),h(Ze,"href","https://huggingface.co/facebook/mms-tts"),h(Ze,"rel","nofollow"),h(le,"id","language-identification-lid"),h(le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(le,"href","#language-identification-lid"),h(F,"class","relative group"),h(Re,"href","https://huggingface.co/facebook/mms-lid-126"),h(Re,"rel","nofollow"),h(Be,"href","https://huggingface.co/facebook/mms-lid-256"),h(Be,"rel","nofollow"),h(Xe,"href","https://huggingface.co/facebook/mms-lid-512"),h(Xe,"rel","nofollow"),h(Ie,"href","https://huggingface.co/facebook/mms-lid-1024"),h(Ie,"rel","nofollow"),h(Ge,"href","https://huggingface.co/facebook/mms-lid-2048"),h(Ge,"rel","nofollow"),h(Ae,"href","https://huggingface.co/facebook/mms-lid-4017"),h(Ae,"rel","nofollow"),h(te,"id","inference"),h(te,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(te,"href","#inference"),h(S,"class","relative group"),h(Se,"href","https://huggingface.co/harshit345/xlsr-wav2vec-speech-emotion-recognition"),h(Se,"rel","nofollow"),h(se,"id","audio-pretrained-models"),h(se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(se,"href","#audio-pretrained-models"),h(z,"class","relative group"),h(xe,"href","https://huggingface.co/facebook/mms-300m"),h(xe,"rel","nofollow"),h(He,"href","https://huggingface.co/facebook/mms-1b"),h(He,"rel","nofollow"),h(pa,"href","wav2vec2")},m(e,i){l(document.head,v),p(e,Y,i),p(e,j,i),l(j,J),l(J,Z),y(u,Z,null),l(j,$),l(j,ma),l(ma,Ql),p(e,Ca,i),p(e,G,i),l(G,x),l(x,fa),y(ie,fa,null),l(G,Yl),l(G,ya),l(ya,xl),p(e,Fa,i),p(e,H,i),l(H,Hl),l(H,he),l(he,ql),l(H,Pl),p(e,Sa,i),p(e,Pe,i),l(Pe,Ll),p(e,za,i),p(e,Le,i),l(Le,Ma),l(Ma,Dl),p(e,Qa,i),p(e,R,i),l(R,Kl),l(R,pe),l(pe,Ol),l(R,et),l(R,ga),l(ga,at),l(R,lt),p(e,Ya,i),p(e,A,i),l(A,q),l(q,wa),y(ce,wa,null),l(A,tt),l(A,ba),l(ba,st),p(e,xa,i),p(e,T,i),l(T,ot),l(T,de),l(de,rt),l(T,nt),l(T,ue),l(ue,it),l(T,ht),l(T,me),l(me,pt),l(T,ct),l(T,va),l(va,dt),l(T,ut),p(e,Ha,i),p(e,De,i),l(De,mt),p(e,qa,i),p(e,B,i),l(B,fe),l(fe,ft),l(fe,Ke),l(Ke,yt),l(fe,Mt),l(B,gt),l(B,ye),l(ye,wt),l(ye,Oe),l(Oe,bt),l(ye,vt),l(B,Jt),l(B,Me),l(Me,jt),l(Me,ea),l(ea,Tt),l(Me,_t),p(e,Pa,i),p(e,V,i),l(V,P),l(P,Ja),y(ge,Ja,null),l(V,Ut),l(V,ja),l(ja,Et),p(e,La,i),p(e,U,i),l(U,Wt),l(U,Ta),l(Ta,kt),l(U,Zt),l(U,_a),l(_a,$t),l(U,Rt),l(U,Ua),l(Ua,Bt),l(U,Xt),p(e,Da,i),y(we,e,i),p(e,Ka,i),y(L,e,i),p(e,Oa,i),p(e,aa,i),l(aa,It),p(e,el,i),y(be,e,i),p(e,al,i),p(e,N,i),l(N,D),l(D,Ea),y(ve,Ea,null),l(N,Gt),l(N,Wa),l(Wa,At),p(e,ll,i),p(e,X,i),l(X,Vt),l(X,ka),l(ka,Nt),l(X,Ct),l(X,Je),l(Je,Ft),l(X,St),p(e,tl,i),y(je,e,i),p(e,sl,i),p(e,la,i),l(la,zt),p(e,ol,i),y(Te,e,i),p(e,rl,i),p(e,K,i),l(K,Qt),l(K,ta),l(ta,Yt),l(K,xt),p(e,nl,i),y(_e,e,i),p(e,il,i),p(e,E,i),l(E,Ht),l(E,sa),l(sa,qt),l(E,Pt),l(E,oa),l(oa,Lt),l(E,Dt),l(E,Za),l(Za,Kt),l(E,Ot),p(e,hl,i),y(Ue,e,i),p(e,pl,i),p(e,ra,i),l(ra,es),p(e,cl,i),y(Ee,e,i),p(e,dl,i),p(e,na,i),l(na,as),p(e,ul,i),p(e,O,i),l(O,ls),l(O,We),l(We,ts),l(O,ss),p(e,ml,i),p(e,C,i),l(C,ee),l(ee,$a),y(ke,$a,null),l(C,os),l(C,Ra),l(Ra,rs),p(e,fl,i),p(e,ae,i),l(ae,ns),l(ae,Ze),l(Ze,is),l(ae,hs),p(e,yl,i),p(e,F,i),l(F,le),l(le,Ba),y($e,Ba,null),l(F,ps),l(F,Xa),l(Xa,cs),p(e,Ml,i),p(e,b,i),l(b,ds),l(b,Re),l(Re,us),l(b,ms),l(b,Be),l(Be,fs),l(b,ys),l(b,Xe),l(Xe,Ms),l(b,gs),l(b,Ie),l(Ie,ws),l(b,bs),l(b,Ge),l(Ge,vs),l(b,Js),l(b,Ae),l(Ae,js),l(b,Ts),p(e,gl,i),p(e,S,i),l(S,te),l(te,Ia),y(Ve,Ia,null),l(S,_s),l(S,Ga),l(Ga,Us),p(e,wl,i),y(Ne,e,i),p(e,bl,i),p(e,ia,i),l(ia,Es),p(e,vl,i),y(Ce,e,i),p(e,Jl,i),p(e,Fe,i),l(Fe,Ws),l(Fe,Se),l(Se,ks),p(e,jl,i),y(ze,e,i),p(e,Tl,i),p(e,ha,i),l(ha,Zs),p(e,_l,i),y(Qe,e,i),p(e,Ul,i),p(e,z,i),l(z,se),l(se,Aa),y(Ye,Aa,null),l(z,$s),l(z,Va),l(Va,Rs),p(e,El,i),p(e,W,i),l(W,Bs),l(W,xe),l(xe,Xs),l(W,Is),l(W,He),l(He,Gs),l(W,As),l(W,pa),l(pa,Vs),l(W,Ns),Wl=!0},p(e,[i]){const qe={};i&2&&(qe.$$scope={dirty:i,ctx:e}),L.$set(qe)},i(e){Wl||(M(u.$$.fragment,e),M(ie.$$.fragment,e),M(ce.$$.fragment,e),M(ge.$$.fragment,e),M(we.$$.fragment,e),M(L.$$.fragment,e),M(be.$$.fragment,e),M(ve.$$.fragment,e),M(je.$$.fragment,e),M(Te.$$.fragment,e),M(_e.$$.fragment,e),M(Ue.$$.fragment,e),M(Ee.$$.fragment,e),M(ke.$$.fragment,e),M($e.$$.fragment,e),M(Ve.$$.fragment,e),M(Ne.$$.fragment,e),M(Ce.$$.fragment,e),M(ze.$$.fragment,e),M(Qe.$$.fragment,e),M(Ye.$$.fragment,e),Wl=!0)},o(e){g(u.$$.fragment,e),g(ie.$$.fragment,e),g(ce.$$.fragment,e),g(ge.$$.fragment,e),g(we.$$.fragment,e),g(L.$$.fragment,e),g(be.$$.fragment,e),g(ve.$$.fragment,e),g(je.$$.fragment,e),g(Te.$$.fragment,e),g(_e.$$.fragment,e),g(Ue.$$.fragment,e),g(Ee.$$.fragment,e),g(ke.$$.fragment,e),g($e.$$.fragment,e),g(Ve.$$.fragment,e),g(Ne.$$.fragment,e),g(Ce.$$.fragment,e),g(ze.$$.fragment,e),g(Qe.$$.fragment,e),g(Ye.$$.fragment,e),Wl=!1},d(e){a(v),e&&a(Y),e&&a(j),w(u),e&&a(Ca),e&&a(G),w(ie),e&&a(Fa),e&&a(H),e&&a(Sa),e&&a(Pe),e&&a(za),e&&a(Le),e&&a(Qa),e&&a(R),e&&a(Ya),e&&a(A),w(ce),e&&a(xa),e&&a(T),e&&a(Ha),e&&a(De),e&&a(qa),e&&a(B),e&&a(Pa),e&&a(V),w(ge),e&&a(La),e&&a(U),e&&a(Da),w(we,e),e&&a(Ka),w(L,e),e&&a(Oa),e&&a(aa),e&&a(el),w(be,e),e&&a(al),e&&a(N),w(ve),e&&a(ll),e&&a(X),e&&a(tl),w(je,e),e&&a(sl),e&&a(la),e&&a(ol),w(Te,e),e&&a(rl),e&&a(K),e&&a(nl),w(_e,e),e&&a(il),e&&a(E),e&&a(hl),w(Ue,e),e&&a(pl),e&&a(ra),e&&a(cl),w(Ee,e),e&&a(dl),e&&a(na),e&&a(ul),e&&a(O),e&&a(ml),e&&a(C),w(ke),e&&a(fl),e&&a(ae),e&&a(yl),e&&a(F),w($e),e&&a(Ml),e&&a(b),e&&a(gl),e&&a(S),w(Ve),e&&a(wl),w(Ne,e),e&&a(bl),e&&a(ia),e&&a(vl),w(Ce,e),e&&a(Jl),e&&a(Fe),e&&a(jl),w(ze,e),e&&a(Tl),e&&a(ha),e&&a(_l),w(Qe,e),e&&a(Ul),e&&a(z),w(Ye),e&&a(El),e&&a(W)}}}const cr={local:"mms",sections:[{local:"overview",sections:[{local:"automatic-speech-recognition-asr",sections:[{local:"loading",title:"Loading"},{local:"inference",title:"Inference"}],title:"Automatic Speech Recognition (ASR)"},{local:"speech-synthesis-tts",title:"Speech Synthesis (TTS)"},{local:"language-identification-lid",sections:[{local:"inference",title:"Inference"}],title:"Language Identification (LID)"},{local:"audio-pretrained-models",title:"Audio Pretrained Models"}],title:"Overview"}],title:"MMS"};function dr(Na){return rr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Mr extends lr{constructor(v){super();tr(this,v,dr,pr,sr,{})}}export{Mr as default,cr as metadata};
