import{S as Ur,i as Nr,s as Hr,e as r,k as u,w as v,t as a,M as Yr,c as o,d as t,m as h,a as p,x as j,h as n,b as f,G as s,g as i,y as b,q as y,o as w,B as k,v as Vr,L as Gr}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ya}from"../../chunks/Tip-hf-doc-builder.js";import{Y as Br}from"../../chunks/Youtube-hf-doc-builder.js";import{I as ot}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as O}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as zr,M as Mr}from"../../chunks/Markdown-hf-doc-builder.js";function Jr(z){let c,$,m,g,x;return{c(){c=r("p"),$=a("See the automatic speech recognition "),m=r("a"),g=a("task page"),x=a(" for more information about its associated models, datasets, and metrics."),this.h()},l(E){c=o(E,"P",{});var q=p(c);$=n(q,"See the automatic speech recognition "),m=o(q,"A",{href:!0,rel:!0});var P=p(m);g=n(P,"task page"),P.forEach(t),x=n(q," for more information about its associated models, datasets, and metrics."),q.forEach(t),this.h()},h(){f(m,"href","https://huggingface.co/tasks/automatic-speech-recognition"),f(m,"rel","nofollow")},m(E,q){i(E,c,q),s(c,$),s(c,m),s(m,g),s(c,x)},d(E){E&&t(c)}}}function Kr(z){let c,$,m,g,x,E,q,P;return{c(){c=r("p"),$=a("If you aren\u2019t familiar with finetuning a model with the "),m=r("a"),g=a("Trainer"),x=a(", take a look at the basic tutorial "),E=r("a"),q=a("here"),P=a("!"),this.h()},l(C){c=o(C,"P",{});var A=p(c);$=n(A,"If you aren\u2019t familiar with finetuning a model with the "),m=o(A,"A",{href:!0});var I=p(m);g=n(I,"Trainer"),I.forEach(t),x=n(A,", take a look at the basic tutorial "),E=o(A,"A",{href:!0});var D=p(E);q=n(D,"here"),D.forEach(t),P=n(A,"!"),A.forEach(t),this.h()},h(){f(m,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer"),f(E,"href","../training#train-with-pytorch-trainer")},m(C,A){i(C,c,A),s(c,$),s(c,m),s(m,g),s(c,x),s(c,E),s(E,q),s(c,P)},d(C){C&&t(c)}}}function Qr(z){let c,$,m,g,x,E,q,P,C,A,I,D,Y,W,te,N,M,R,U,L,he,V,H,ae,_,S,$e,ve,F,je,me,ne,X,be,ye,Le,de,we,ke,us,Fe,K,ze,G,le,Pe,re,fe,Ee,oe,Me,Q,hs,_e,Ue,ge,Ce;return c=new Ya({props:{$$slots:{default:[Kr]},$$scope:{ctx:z}}}),D=new O({props:{code:`from transformers import AutoModelForCTC, TrainingArguments, Trainer

model = AutoModelForCTC.from_pretrained(
    "facebook/wav2vec2-base",
    ctc_loss_reduction="mean",
    pad_token_id=processor.tokenizer.pad_token_id,
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCTC, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCTC.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/wav2vec2-base&quot;</span>,
<span class="hljs-meta">... </span>    ctc_loss_reduction=<span class="hljs-string">&quot;mean&quot;</span>,
<span class="hljs-meta">... </span>    pad_token_id=processor.tokenizer.pad_token_id,
<span class="hljs-meta">... </span>)`}}),fe=new O({props:{code:`training_args = TrainingArguments(
    output_dir="my_awesome_asr_mind_model",
    per_device_train_batch_size=8,
    gradient_accumulation_steps=2,
    learning_rate=1e-5,
    warmup_steps=500,
    max_steps=2000,
    gradient_checkpointing=True,
    fp16=True,
    group_by_length=True,
    evaluation_strategy="steps",
    per_device_eval_batch_size=8,
    save_steps=1000,
    eval_steps=1000,
    logging_steps=25,
    load_best_model_at_end=True,
    metric_for_best_model="wer",
    greater_is_better=False,
    push_to_hub=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=encoded_minds["train"],
    eval_dataset=encoded_minds["test"],
    tokenizer=processor.feature_extractor,
    data_collator=data_collator,
    compute_metrics=compute_metrics,
)

trainer.train()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_asr_mind_model&quot;</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    gradient_accumulation_steps=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">1e-5</span>,
<span class="hljs-meta">... </span>    warmup_steps=<span class="hljs-number">500</span>,
<span class="hljs-meta">... </span>    max_steps=<span class="hljs-number">2000</span>,
<span class="hljs-meta">... </span>    gradient_checkpointing=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    fp16=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    group_by_length=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;steps&quot;</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    save_steps=<span class="hljs-number">1000</span>,
<span class="hljs-meta">... </span>    eval_steps=<span class="hljs-number">1000</span>,
<span class="hljs-meta">... </span>    logging_steps=<span class="hljs-number">25</span>,
<span class="hljs-meta">... </span>    load_best_model_at_end=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    metric_for_best_model=<span class="hljs-string">&quot;wer&quot;</span>,
<span class="hljs-meta">... </span>    greater_is_better=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    push_to_hub=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=encoded_minds[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=encoded_minds[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=processor.feature_extractor,
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),ge=new O({props:{code:"trainer.push_to_hub()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){v(c.$$.fragment),$=u(),m=r("p"),g=a("You\u2019re ready to start training your model now! Load Wav2Vec2 with "),x=r("a"),E=a("AutoModelForCTC"),q=a(". Specify the reduction to apply with the "),P=r("code"),C=a("ctc_loss_reduction"),A=a(" parameter. It is often better to use the average instead of the default summation:"),I=u(),v(D.$$.fragment),Y=u(),W=r("p"),te=a("At this point, only three steps remain:"),N=u(),M=r("ol"),R=r("li"),U=a("Define your training hyperparameters in "),L=r("a"),he=a("TrainingArguments"),V=a(". The only required parameter is "),H=r("code"),ae=a("output_dir"),_=a(" which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),S=r("code"),$e=a("push_to_hub=True"),ve=a(" (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),F=r("a"),je=a("Trainer"),me=a(" will evaluate the WER and save the training checkpoint."),ne=u(),X=r("li"),be=a("Pass the training arguments to "),ye=r("a"),Le=a("Trainer"),de=a(" along with the model, dataset, tokenizer, data collator, and "),we=r("code"),ke=a("compute_metrics"),us=a(" function."),Fe=u(),K=r("li"),ze=a("Call "),G=r("a"),le=a("train()"),Pe=a(" to finetune your model."),re=u(),v(fe.$$.fragment),Ee=u(),oe=r("p"),Me=a("Once training is completed, share your model to the Hub with the "),Q=r("a"),hs=a("push_to_hub()"),_e=a(" method so everyone can use your model:"),Ue=u(),v(ge.$$.fragment),this.h()},l(d){j(c.$$.fragment,d),$=h(d),m=o(d,"P",{});var T=p(m);g=n(T,"You\u2019re ready to start training your model now! Load Wav2Vec2 with "),x=o(T,"A",{href:!0});var B=p(x);E=n(B,"AutoModelForCTC"),B.forEach(t),q=n(T,". Specify the reduction to apply with the "),P=o(T,"CODE",{});var Hs=p(P);C=n(Hs,"ctc_loss_reduction"),Hs.forEach(t),A=n(T," parameter. It is often better to use the average instead of the default summation:"),T.forEach(t),I=h(d),j(D.$$.fragment,d),Y=h(d),W=o(d,"P",{});var Ne=p(W);te=n(Ne,"At this point, only three steps remain:"),Ne.forEach(t),N=h(d),M=o(d,"OL",{});var xe=p(M);R=o(xe,"LI",{});var Z=p(R);U=n(Z,"Define your training hyperparameters in "),L=o(Z,"A",{href:!0});var He=p(L);he=n(He,"TrainingArguments"),He.forEach(t),V=n(Z,". The only required parameter is "),H=o(Z,"CODE",{});var Ys=p(H);ae=n(Ys,"output_dir"),Ys.forEach(t),_=n(Z," which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),S=o(Z,"CODE",{});var Vs=p(S);$e=n(Vs,"push_to_hub=True"),Vs.forEach(t),ve=n(Z," (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),F=o(Z,"A",{href:!0});var ms=p(F);je=n(ms,"Trainer"),ms.forEach(t),me=n(Z," will evaluate the WER and save the training checkpoint."),Z.forEach(t),ne=h(xe),X=o(xe,"LI",{});var ee=p(X);be=n(ee,"Pass the training arguments to "),ye=o(ee,"A",{href:!0});var ds=p(ye);Le=n(ds,"Trainer"),ds.forEach(t),de=n(ee," along with the model, dataset, tokenizer, data collator, and "),we=o(ee,"CODE",{});var De=p(we);ke=n(De,"compute_metrics"),De.forEach(t),us=n(ee," function."),ee.forEach(t),Fe=h(xe),K=o(xe,"LI",{});var Ye=p(K);ze=n(Ye,"Call "),G=o(Ye,"A",{href:!0});var fs=p(G);le=n(fs,"train()"),fs.forEach(t),Pe=n(Ye," to finetune your model."),Ye.forEach(t),xe.forEach(t),re=h(d),j(fe.$$.fragment,d),Ee=h(d),oe=o(d,"P",{});var pe=p(oe);Me=n(pe,"Once training is completed, share your model to the Hub with the "),Q=o(pe,"A",{href:!0});var _s=p(Q);hs=n(_s,"push_to_hub()"),_s.forEach(t),_e=n(pe," method so everyone can use your model:"),pe.forEach(t),Ue=h(d),j(ge.$$.fragment,d),this.h()},h(){f(x,"href","/docs/transformers/v4.25.1/en/model_doc/auto#transformers.AutoModelForCTC"),f(L,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.TrainingArguments"),f(F,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer"),f(ye,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer"),f(G,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer.train"),f(Q,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer.push_to_hub")},m(d,T){b(c,d,T),i(d,$,T),i(d,m,T),s(m,g),s(m,x),s(x,E),s(m,q),s(m,P),s(P,C),s(m,A),i(d,I,T),b(D,d,T),i(d,Y,T),i(d,W,T),s(W,te),i(d,N,T),i(d,M,T),s(M,R),s(R,U),s(R,L),s(L,he),s(R,V),s(R,H),s(H,ae),s(R,_),s(R,S),s(S,$e),s(R,ve),s(R,F),s(F,je),s(R,me),s(M,ne),s(M,X),s(X,be),s(X,ye),s(ye,Le),s(X,de),s(X,we),s(we,ke),s(X,us),s(M,Fe),s(M,K),s(K,ze),s(K,G),s(G,le),s(K,Pe),i(d,re,T),b(fe,d,T),i(d,Ee,T),i(d,oe,T),s(oe,Me),s(oe,Q),s(Q,hs),s(oe,_e),i(d,Ue,T),b(ge,d,T),Ce=!0},p(d,T){const B={};T&2&&(B.$$scope={dirty:T,ctx:d}),c.$set(B)},i(d){Ce||(y(c.$$.fragment,d),y(D.$$.fragment,d),y(fe.$$.fragment,d),y(ge.$$.fragment,d),Ce=!0)},o(d){w(c.$$.fragment,d),w(D.$$.fragment,d),w(fe.$$.fragment,d),w(ge.$$.fragment,d),Ce=!1},d(d){k(c,d),d&&t($),d&&t(m),d&&t(I),k(D,d),d&&t(Y),d&&t(W),d&&t(N),d&&t(M),d&&t(re),k(fe,d),d&&t(Ee),d&&t(oe),d&&t(Ue),k(ge,d)}}}function Xr(z){let c,$;return c=new Mr({props:{$$slots:{default:[Qr]},$$scope:{ctx:z}}}),{c(){v(c.$$.fragment)},l(m){j(c.$$.fragment,m)},m(m,g){b(c,m,g),$=!0},p(m,g){const x={};g&2&&(x.$$scope={dirty:g,ctx:m}),c.$set(x)},i(m){$||(y(c.$$.fragment,m),$=!0)},o(m){w(c.$$.fragment,m),$=!1},d(m){k(c,m)}}}function Zr(z){let c,$,m,g,x,E,q,P;return{c(){c=r("p"),$=a("For a more in-depth example of how to finetune a model for automatic speech recognition, take a look at this blog "),m=r("a"),g=a("post"),x=a(" for English ASR and this "),E=r("a"),q=a("post"),P=a(" for multilingual ASR."),this.h()},l(C){c=o(C,"P",{});var A=p(c);$=n(A,"For a more in-depth example of how to finetune a model for automatic speech recognition, take a look at this blog "),m=o(A,"A",{href:!0,rel:!0});var I=p(m);g=n(I,"post"),I.forEach(t),x=n(A," for English ASR and this "),E=o(A,"A",{href:!0,rel:!0});var D=p(E);q=n(D,"post"),D.forEach(t),P=n(A," for multilingual ASR."),A.forEach(t),this.h()},h(){f(m,"href","https://huggingface.co/blog/fine-tune-wav2vec2-english"),f(m,"rel","nofollow"),f(E,"href","https://huggingface.co/blog/fine-tune-xlsr-wav2vec2"),f(E,"rel","nofollow")},m(C,A){i(C,c,A),s(c,$),s(c,m),s(m,g),s(c,x),s(c,E),s(E,q),s(c,P)},d(C){C&&t(c)}}}function eo(z){let c,$;return{c(){c=r("p"),$=a("The transcription is decent, but it could be better! Try finetuning your model on more examples to get even better results!")},l(m){c=o(m,"P",{});var g=p(c);$=n(g,"The transcription is decent, but it could be better! Try finetuning your model on more examples to get even better results!"),g.forEach(t)},m(m,g){i(m,c,g),s(c,$)},d(m){m&&t(c)}}}function so(z){let c,$,m,g,x,E,q,P,C,A,I,D,Y,W,te,N,M,R,U,L,he,V,H,ae;return q=new O({props:{code:`from transformers import AutoProcessor

processor = AutoProcessor.from_pretrained("stevhliu/my_awesome_asr_mind_model")
inputs = processor(dataset[0]["audio"]["array"], sampling_rate=sampling_rate, return_tensors="pt")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_asr_mind_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>], sampling_rate=sampling_rate, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`}}),D=new O({props:{code:`from transformers import AutoModelForCTC

model = AutoModelForCTC.from_pretrained("stevhliu/my_awesome_asr_mind_model")
with torch.no_grad():
    logits = model(**inputs).logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCTC

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCTC.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_asr_mind_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits`}}),H=new O({props:{code:`import torch

predicted_ids = torch.argmax(logits, dim=-1)
transcription = processor.batch_decode(predicted_ids)
transcription`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_ids = torch.argmax(logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcription = processor.batch_decode(predicted_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcription
[<span class="hljs-string">&#x27;I WOUL LIKE O SET UP JOINT ACOUNT WTH Y PARTNER&#x27;</span>]`}}),{c(){c=r("p"),$=a("Load a processor to preprocess the audio file and transcription and return the "),m=r("code"),g=a("input"),x=a(" as PyTorch tensors:"),E=u(),v(q.$$.fragment),P=u(),C=r("p"),A=a("Pass your inputs to the model and return the logits:"),I=u(),v(D.$$.fragment),Y=u(),W=r("p"),te=a("Get the predicted "),N=r("code"),M=a("input_ids"),R=a(" with the highest probability, and use the processor to decode the predicted "),U=r("code"),L=a("input_ids"),he=a(" back into text:"),V=u(),v(H.$$.fragment)},l(_){c=o(_,"P",{});var S=p(c);$=n(S,"Load a processor to preprocess the audio file and transcription and return the "),m=o(S,"CODE",{});var $e=p(m);g=n($e,"input"),$e.forEach(t),x=n(S," as PyTorch tensors:"),S.forEach(t),E=h(_),j(q.$$.fragment,_),P=h(_),C=o(_,"P",{});var ve=p(C);A=n(ve,"Pass your inputs to the model and return the logits:"),ve.forEach(t),I=h(_),j(D.$$.fragment,_),Y=h(_),W=o(_,"P",{});var F=p(W);te=n(F,"Get the predicted "),N=o(F,"CODE",{});var je=p(N);M=n(je,"input_ids"),je.forEach(t),R=n(F," with the highest probability, and use the processor to decode the predicted "),U=o(F,"CODE",{});var me=p(U);L=n(me,"input_ids"),me.forEach(t),he=n(F," back into text:"),F.forEach(t),V=h(_),j(H.$$.fragment,_)},m(_,S){i(_,c,S),s(c,$),s(c,m),s(m,g),s(c,x),i(_,E,S),b(q,_,S),i(_,P,S),i(_,C,S),s(C,A),i(_,I,S),b(D,_,S),i(_,Y,S),i(_,W,S),s(W,te),s(W,N),s(N,M),s(W,R),s(W,U),s(U,L),s(W,he),i(_,V,S),b(H,_,S),ae=!0},p:Gr,i(_){ae||(y(q.$$.fragment,_),y(D.$$.fragment,_),y(H.$$.fragment,_),ae=!0)},o(_){w(q.$$.fragment,_),w(D.$$.fragment,_),w(H.$$.fragment,_),ae=!1},d(_){_&&t(c),_&&t(E),k(q,_),_&&t(P),_&&t(C),_&&t(I),k(D,_),_&&t(Y),_&&t(W),_&&t(V),k(H,_)}}}function to(z){let c,$;return c=new Mr({props:{$$slots:{default:[so]},$$scope:{ctx:z}}}),{c(){v(c.$$.fragment)},l(m){j(c.$$.fragment,m)},m(m,g){b(c,m,g),$=!0},p(m,g){const x={};g&2&&(x.$$scope={dirty:g,ctx:m}),c.$set(x)},i(m){$||(y(c.$$.fragment,m),$=!0)},o(m){w(c.$$.fragment,m),$=!1},d(m){k(c,m)}}}function ao(z){let c,$,m,g,x,E,q,P,C,A,I,D,Y,W,te,N,M,R,U,L,he,V,H,ae,_,S,$e,ve,F,je,me,ne,X,be,ye,Le,de,we,ke,us,Fe,K,ze,G,le,Pe,re,fe,Ee,oe,Me,Q,hs,_e,Ue,ge,Ce,d,T,B,Hs,Ne,xe,Z,He,Ys,Vs,ms,ee,ds,De,Ye,fs,pe,_s,J,Va,pt,Ga,Ba,it,Ja,Ka,ct,Qa,Xa,ut,Za,en,gs,sn,tn,Ut,$s,Nt,Gs,an,Ht,vs,Yt,Bs,nn,Vt,Ve,Ge,ht,ln,rn,mt,on,pn,cn,Js,dt,un,hn,Gt,Se,Be,ft,js,mn,_t,dn,Bt,Ks,fn,Jt,bs,Kt,Je,_n,ys,gn,$n,Qt,ws,Xt,Ke,vn,gt,jn,bn,Zt,ks,ea,Qs,yn,sa,Qe,Es,wn,$t,kn,En,xn,Oe,qn,vt,An,Tn,jt,Pn,Cn,ta,xs,aa,se,Dn,qs,Sn,On,bt,In,Rn,yt,Wn,Ln,As,Fn,zn,na,Ts,la,ie,Mn,Xs,Un,Nn,wt,Hn,Yn,kt,Vn,Gn,ra,qe,Bn,Et,Jn,Kn,xt,Qn,Xn,oa,Ps,pa,Xe,Zn,qt,el,sl,ia,Cs,ca,Ie,Ze,At,Ds,tl,Tt,al,ua,ce,nl,Ss,ll,rl,Os,ol,pl,Is,il,cl,ha,Rs,ma,es,ul,Ws,hl,ml,da,Ls,fa,ss,dl,Pt,fl,_l,_a,Re,ts,Ct,Fs,gl,Dt,$l,ga,as,$a,ns,va,We,ls,St,zs,vl,Ot,jl,ja,Zs,bl,ba,et,yl,ya,Ms,wa,Ae,wl,st,kl,El,It,xl,ql,ka,Us,Ea,rs,xa,os,Al,Rt,Tl,Pl,qa,ps,Aa;return E=new ot({}),I=new Br({props:{id:"TksaY_FDgnk"}}),ne=new Ya({props:{$$slots:{default:[Jr]},$$scope:{ctx:z}}}),de=new O({props:{code:"pip install transformers datasets evaluate jiwer",highlighted:"pip install transformers datasets evaluate jiwer"}}),K=new O({props:{code:`from huggingface_hub import notebook_login

notebook_login()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`}}),re=new ot({}),d=new O({props:{code:`from datasets import load_dataset, Audio

minds = load_dataset("PolyAI/minds14", name="en-US", split="train[:100]")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>minds = load_dataset(<span class="hljs-string">&quot;PolyAI/minds14&quot;</span>, name=<span class="hljs-string">&quot;en-US&quot;</span>, split=<span class="hljs-string">&quot;train[:100]&quot;</span>)`}}),ee=new O({props:{code:"minds = minds.train_test_split(test_size=0.2)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>minds = minds.train_test_split(test_size=<span class="hljs-number">0.2</span>)'}}),pe=new O({props:{code:"minds",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>minds
DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;path&#x27;</span>, <span class="hljs-string">&#x27;audio&#x27;</span>, <span class="hljs-string">&#x27;transcription&#x27;</span>, <span class="hljs-string">&#x27;english_transcription&#x27;</span>, <span class="hljs-string">&#x27;intent_class&#x27;</span>, <span class="hljs-string">&#x27;lang_id&#x27;</span>],
        num_rows: <span class="hljs-number">16</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;path&#x27;</span>, <span class="hljs-string">&#x27;audio&#x27;</span>, <span class="hljs-string">&#x27;transcription&#x27;</span>, <span class="hljs-string">&#x27;english_transcription&#x27;</span>, <span class="hljs-string">&#x27;intent_class&#x27;</span>, <span class="hljs-string">&#x27;lang_id&#x27;</span>],
        num_rows: <span class="hljs-number">4</span>
    })
})`}}),$s=new O({props:{code:'minds = minds.remove_columns(["english_transcription", "intent_class", "lang_id"])',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>minds = minds.remove_columns([<span class="hljs-string">&quot;english_transcription&quot;</span>, <span class="hljs-string">&quot;intent_class&quot;</span>, <span class="hljs-string">&quot;lang_id&quot;</span>])'}}),vs=new O({props:{code:'minds["train"][0]',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>minds[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;audio&#x27;</span>: {<span class="hljs-string">&#x27;array&#x27;</span>: array([-<span class="hljs-number">0.00024414</span>,  <span class="hljs-number">0.</span>        ,  <span class="hljs-number">0.</span>        , ...,  <span class="hljs-number">0.00024414</span>,
          <span class="hljs-number">0.00024414</span>,  <span class="hljs-number">0.00024414</span>], dtype=float32),
  <span class="hljs-string">&#x27;path&#x27;</span>: <span class="hljs-string">&#x27;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-US~APP_ERROR/602ba9e2963e11ccd901cd4f.wav&#x27;</span>,
  <span class="hljs-string">&#x27;sampling_rate&#x27;</span>: <span class="hljs-number">8000</span>},
 <span class="hljs-string">&#x27;path&#x27;</span>: <span class="hljs-string">&#x27;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-US~APP_ERROR/602ba9e2963e11ccd901cd4f.wav&#x27;</span>,
 <span class="hljs-string">&#x27;transcription&#x27;</span>: <span class="hljs-string">&quot;hi I&#x27;m trying to use the banking app on my phone and currently my checking and savings account balance is not refreshing&quot;</span>}`}}),js=new ot({}),bs=new O({props:{code:`from transformers import AutoProcessor

processor = AutoProcessor.from_pretrained("facebook/wav2vec2-base")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/wav2vec2-base&quot;</span>)`}}),ws=new O({props:{code:`minds = minds.cast_column("audio", Audio(sampling_rate=16_000))
minds["train"][0]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>minds = minds.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16_000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>minds[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;audio&#x27;</span>: {<span class="hljs-string">&#x27;array&#x27;</span>: array([-<span class="hljs-number">2.38064706e-04</span>, -<span class="hljs-number">1.58618059e-04</span>, -<span class="hljs-number">5.43987835e-06</span>, ...,
          <span class="hljs-number">2.78103951e-04</span>,  <span class="hljs-number">2.38446111e-04</span>,  <span class="hljs-number">1.18740834e-04</span>], dtype=float32),
  <span class="hljs-string">&#x27;path&#x27;</span>: <span class="hljs-string">&#x27;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-US~APP_ERROR/602ba9e2963e11ccd901cd4f.wav&#x27;</span>,
  <span class="hljs-string">&#x27;sampling_rate&#x27;</span>: <span class="hljs-number">16000</span>},
 <span class="hljs-string">&#x27;path&#x27;</span>: <span class="hljs-string">&#x27;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-US~APP_ERROR/602ba9e2963e11ccd901cd4f.wav&#x27;</span>,
 <span class="hljs-string">&#x27;transcription&#x27;</span>: <span class="hljs-string">&quot;hi I&#x27;m trying to use the banking app on my phone and currently my checking and savings account balance is not refreshing&quot;</span>}`}}),ks=new O({props:{code:`def uppercase(example):
    return {"transcription": example["transcription"].upper()}


minds = minds.map(uppercase)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">uppercase</span>(<span class="hljs-params">example</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;transcription&quot;</span>: example[<span class="hljs-string">&quot;transcription&quot;</span>].upper()}


<span class="hljs-meta">&gt;&gt;&gt; </span>minds = minds.<span class="hljs-built_in">map</span>(uppercase)`}}),xs=new O({props:{code:`def prepare_dataset(batch):
    audio = batch["audio"]
    batch = processor(audio["array"], sampling_rate=audio["sampling_rate"], text=batch["transcription"])
    batch["input_length"] = len(batch["input_values"][0])
    return batch`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">prepare_dataset</span>(<span class="hljs-params">batch</span>):
<span class="hljs-meta">... </span>    audio = batch[<span class="hljs-string">&quot;audio&quot;</span>]
<span class="hljs-meta">... </span>    batch = processor(audio[<span class="hljs-string">&quot;array&quot;</span>], sampling_rate=audio[<span class="hljs-string">&quot;sampling_rate&quot;</span>], text=batch[<span class="hljs-string">&quot;transcription&quot;</span>])
<span class="hljs-meta">... </span>    batch[<span class="hljs-string">&quot;input_length&quot;</span>] = <span class="hljs-built_in">len</span>(batch[<span class="hljs-string">&quot;input_values&quot;</span>][<span class="hljs-number">0</span>])
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> batch`}}),Ts=new O({props:{code:'encoded_minds = minds.map(prepare_dataset, remove_columns=minds.column_names["train"], num_proc=4)',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_minds = minds.<span class="hljs-built_in">map</span>(prepare_dataset, remove_columns=minds.column_names[<span class="hljs-string">&quot;train&quot;</span>], num_proc=<span class="hljs-number">4</span>)'}}),Ps=new O({props:{code:`import torch

from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Union


@dataclass
class DataCollatorCTCWithPadding:

    processor: AutoProcessor
    padding: Union[bool, str] = "longest"

    def __call__(self, features: List[Dict[str, Union[List[int], torch.Tensor]]]) -> Dict[str, torch.Tensor]:
        # split inputs and labels since they have to be of different lengths and need
        # different padding methods
        input_features = [{"input_values": feature["input_values"][0]} for feature in features]
        label_features = [{"input_ids": feature["labels"]} for feature in features]

        batch = self.processor.pad(input_features, padding=self.padding, return_tensors="pt")

        labels_batch = self.processor.pad(labels=label_features, padding=self.padding, return_tensors="pt")

        # replace padding with -100 to ignore loss correctly
        labels = labels_batch["input_ids"].masked_fill(labels_batch.attention_mask.ne(1), -100)

        batch["labels"] = labels

        return batch`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass, field
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Any</span>, <span class="hljs-type">Dict</span>, <span class="hljs-type">List</span>, <span class="hljs-type">Optional</span>, <span class="hljs-type">Union</span>


<span class="hljs-meta">&gt;&gt;&gt; </span>@dataclass
<span class="hljs-meta">... </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">DataCollatorCTCWithPadding</span>:

<span class="hljs-meta">... </span>    processor: AutoProcessor
<span class="hljs-meta">... </span>    padding: <span class="hljs-type">Union</span>[<span class="hljs-built_in">bool</span>, <span class="hljs-built_in">str</span>] = <span class="hljs-string">&quot;longest&quot;</span>

<span class="hljs-meta">... </span>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, features: <span class="hljs-type">List</span>[<span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, <span class="hljs-type">Union</span>[<span class="hljs-type">List</span>[<span class="hljs-built_in">int</span>], torch.Tensor]]]</span>) -&gt; <span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, torch.Tensor]:
<span class="hljs-meta">... </span>        <span class="hljs-comment"># split inputs and labels since they have to be of different lengths and need</span>
<span class="hljs-meta">... </span>        <span class="hljs-comment"># different padding methods</span>
<span class="hljs-meta">... </span>        input_features = [{<span class="hljs-string">&quot;input_values&quot;</span>: feature[<span class="hljs-string">&quot;input_values&quot;</span>][<span class="hljs-number">0</span>]} <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
<span class="hljs-meta">... </span>        label_features = [{<span class="hljs-string">&quot;input_ids&quot;</span>: feature[<span class="hljs-string">&quot;labels&quot;</span>]} <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]

<span class="hljs-meta">... </span>        batch = self.processor.pad(input_features, padding=self.padding, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">... </span>        labels_batch = self.processor.pad(labels=label_features, padding=self.padding, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">... </span>        <span class="hljs-comment"># replace padding with -100 to ignore loss correctly</span>
<span class="hljs-meta">... </span>        labels = labels_batch[<span class="hljs-string">&quot;input_ids&quot;</span>].masked_fill(labels_batch.attention_mask.ne(<span class="hljs-number">1</span>), -<span class="hljs-number">100</span>)

<span class="hljs-meta">... </span>        batch[<span class="hljs-string">&quot;labels&quot;</span>] = labels

<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> batch`}}),Cs=new O({props:{code:'data_collator = DataCollatorCTCWithPadding(processor=processor, padding="longest")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorCTCWithPadding(processor=processor, padding=<span class="hljs-string">&quot;longest&quot;</span>)'}}),Ds=new ot({}),Rs=new O({props:{code:`import evaluate

wer = evaluate.load("wer")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>wer = evaluate.load(<span class="hljs-string">&quot;wer&quot;</span>)`}}),Ls=new O({props:{code:`import numpy as np


def compute_metrics(pred):
    pred_logits = pred.predictions
    pred_ids = np.argmax(pred_logits, axis=-1)

    pred.label_ids[pred.label_ids == -100] = processor.tokenizer.pad_token_id

    pred_str = processor.batch_decode(pred_ids)
    label_str = processor.batch_decode(pred.label_ids, group_tokens=False)

    wer = wer.compute(predictions=pred_str, references=label_str)

    return {"wer": wer}`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">pred</span>):
<span class="hljs-meta">... </span>    pred_logits = pred.predictions
<span class="hljs-meta">... </span>    pred_ids = np.argmax(pred_logits, axis=-<span class="hljs-number">1</span>)

<span class="hljs-meta">... </span>    pred.label_ids[pred.label_ids == -<span class="hljs-number">100</span>] = processor.tokenizer.pad_token_id

<span class="hljs-meta">... </span>    pred_str = processor.batch_decode(pred_ids)
<span class="hljs-meta">... </span>    label_str = processor.batch_decode(pred.label_ids, group_tokens=<span class="hljs-literal">False</span>)

<span class="hljs-meta">... </span>    wer = wer.compute(predictions=pred_str, references=label_str)

<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;wer&quot;</span>: wer}`}}),Fs=new ot({}),as=new zr({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[Xr]},$$scope:{ctx:z}}}),ns=new Ya({props:{$$slots:{default:[Zr]},$$scope:{ctx:z}}}),zs=new ot({}),Ms=new O({props:{code:`from datasets import load_dataset, Audio

dataset = load_dataset("PolyAI/minds14", "en-US", split="train")
dataset = dataset.cast_column("audio", Audio(sampling_rate=16000))
sampling_rate = dataset.features["audio"].sampling_rate
audio_file = dataset[0]["audio"]["path"]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;PolyAI/minds14&quot;</span>, <span class="hljs-string">&quot;en-US&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>sampling_rate = dataset.features[<span class="hljs-string">&quot;audio&quot;</span>].sampling_rate
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_file = dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;path&quot;</span>]`}}),Us=new O({props:{code:`from transformers import pipeline

transcriber = pipeline("automatic-speech-recognition", model="stevhliu/my_awesome_asr_minds_model")
transcriber(audio_file)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber = pipeline(<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;stevhliu/my_awesome_asr_minds_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber(audio_file)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;I WOUD LIKE O SET UP JOINT ACOUNT WTH Y PARTNER&#x27;</span>}`}}),rs=new Ya({props:{$$slots:{default:[eo]},$$scope:{ctx:z}}}),ps=new zr({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[to]},$$scope:{ctx:z}}}),{c(){c=r("meta"),$=u(),m=r("h1"),g=r("a"),x=r("span"),v(E.$$.fragment),q=u(),P=r("span"),C=a("Automatic speech recognition"),A=u(),v(I.$$.fragment),D=u(),Y=r("p"),W=a("Automatic speech recognition (ASR) converts a speech signal to text, mapping a sequence of audio inputs to text outputs. Virtual assistants like Siri and Alexa use ASR models to help users everyday, and there are many other useful user-facing applications like live captioning and note-taking during meetings."),te=u(),N=r("p"),M=a("This guide will show you how to:"),R=u(),U=r("ol"),L=r("li"),he=a("Finetune "),V=r("a"),H=a("Wav2Vec2"),ae=a(" on the "),_=r("a"),S=a("MInDS-14"),$e=a(" dataset to transcribe audio to text."),ve=u(),F=r("li"),je=a("Use your finetuned model for inference."),me=u(),v(ne.$$.fragment),X=u(),be=r("p"),ye=a("Before you begin, make sure you have all the necessary libraries installed:"),Le=u(),v(de.$$.fragment),we=u(),ke=r("p"),us=a("We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),Fe=u(),v(K.$$.fragment),ze=u(),G=r("h2"),le=r("a"),Pe=r("span"),v(re.$$.fragment),fe=u(),Ee=r("span"),oe=a("Load MInDS-14 dataset"),Me=u(),Q=r("p"),hs=a("Start by loading a smaller subset of the "),_e=r("a"),Ue=a("MInDS-14"),ge=a(" dataset from the \u{1F917} Datasets library. This\u2019ll give you a chance to experiment and make sure everything works before spending more time training on the full dataset."),Ce=u(),v(d.$$.fragment),T=u(),B=r("p"),Hs=a("Split the dataset\u2019s "),Ne=r("code"),xe=a("train"),Z=a(" split into a train and test set with the "),He=r("code"),Ys=a("~Dataset.train_test_split"),Vs=a(" method:"),ms=u(),v(ee.$$.fragment),ds=u(),De=r("p"),Ye=a("Then take a look at the dataset:"),fs=u(),v(pe.$$.fragment),_s=u(),J=r("p"),Va=a("While the dataset contains a lot of useful information, like "),pt=r("code"),Ga=a("lang_id"),Ba=a(" and "),it=r("code"),Ja=a("english_transcription"),Ka=a(", you\u2019ll focus on the "),ct=r("code"),Qa=a("audio"),Xa=a(" and "),ut=r("code"),Za=a("transcription"),en=a(" in this guide. Remove the other columns with the "),gs=r("a"),sn=a("remove_columns"),tn=a(" method:"),Ut=u(),v($s.$$.fragment),Nt=u(),Gs=r("p"),an=a("Take a look at the example again:"),Ht=u(),v(vs.$$.fragment),Yt=u(),Bs=r("p"),nn=a("There are two fields:"),Vt=u(),Ve=r("ul"),Ge=r("li"),ht=r("code"),ln=a("audio"),rn=a(": a 1-dimensional "),mt=r("code"),on=a("array"),pn=a(" of the speech signal that must be called to load and resample the audio file."),cn=u(),Js=r("li"),dt=r("code"),un=a("transcription"),hn=a(": the target text."),Gt=u(),Se=r("h2"),Be=r("a"),ft=r("span"),v(js.$$.fragment),mn=u(),_t=r("span"),dn=a("Preprocess"),Bt=u(),Ks=r("p"),fn=a("The next step is to load a Wav2Vec2 processor to process the audio signal:"),Jt=u(),v(bs.$$.fragment),Kt=u(),Je=r("p"),_n=a("The MInDS-14 dataset has a sampling rate of 8000khz (you can find this information in its "),ys=r("a"),gn=a("dataset card"),$n=a("), which means you\u2019ll need to resample the dataset to 16000kHz to use the pretrained Wav2Vec2 model:"),Qt=u(),v(ws.$$.fragment),Xt=u(),Ke=r("p"),vn=a("As you can see in the "),gt=r("code"),jn=a("transcription"),bn=a(" above, the text contains a mix of upper and lowercase characters. The Wav2Vec2 tokenizer is only trained on uppercase characters so you\u2019ll need to make sure the text matches the tokenizer\u2019s vocabulary:"),Zt=u(),v(ks.$$.fragment),ea=u(),Qs=r("p"),yn=a("Now create a preprocessing function that:"),sa=u(),Qe=r("ol"),Es=r("li"),wn=a("Calls the "),$t=r("code"),kn=a("audio"),En=a(" column to load and resample the audio file."),xn=u(),Oe=r("li"),qn=a("Extracts the "),vt=r("code"),An=a("input_values"),Tn=a(" from the audio file and tokenize the "),jt=r("code"),Pn=a("transcription"),Cn=a(" column with the processor."),ta=u(),v(xs.$$.fragment),aa=u(),se=r("p"),Dn=a("To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),qs=r("a"),Sn=a("map"),On=a(" function. You can speed up "),bt=r("code"),In=a("map"),Rn=a(" by increasing the number of processes with the "),yt=r("code"),Wn=a("num_proc"),Ln=a(" parameter. Remove the columns you don\u2019t need with the "),As=r("a"),Fn=a("remove_columns"),zn=a(" method:"),na=u(),v(Ts.$$.fragment),la=u(),ie=r("p"),Mn=a("\u{1F917} Transformers doesn\u2019t have a data collator for ASR, so you\u2019ll need to adapt the "),Xs=r("a"),Un=a("DataCollatorWithPadding"),Nn=a(" to create a batch of examples. It\u2019ll also dynamically pad your text and labels to the length of the longest element in its batch (instead of the entire dataset) so they are a uniform length. While it is possible to pad your text in the "),wt=r("code"),Hn=a("tokenizer"),Yn=a(" function by setting "),kt=r("code"),Vn=a("padding=True"),Gn=a(", dynamic padding is more efficient."),ra=u(),qe=r("p"),Bn=a("Unlike other data collators, this specific data collator needs to apply a different padding method to "),Et=r("code"),Jn=a("input_values"),Kn=a(" and "),xt=r("code"),Qn=a("labels"),Xn=a(":"),oa=u(),v(Ps.$$.fragment),pa=u(),Xe=r("p"),Zn=a("Now instantiate your "),qt=r("code"),el=a("DataCollatorForCTCWithPadding"),sl=a(":"),ia=u(),v(Cs.$$.fragment),ca=u(),Ie=r("h2"),Ze=r("a"),At=r("span"),v(Ds.$$.fragment),tl=u(),Tt=r("span"),al=a("Evaluate"),ua=u(),ce=r("p"),nl=a("Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),Ss=r("a"),ll=a("Evaluate"),rl=a(" library. For this task, load the "),Os=r("a"),ol=a("word error rate"),pl=a(" (WER) metric (see the \u{1F917} Evaluate "),Is=r("a"),il=a("quick tour"),cl=a(" to learn more about how to load and compute a metric):"),ha=u(),v(Rs.$$.fragment),ma=u(),es=r("p"),ul=a("Then create a function that passes your predictions and labels to "),Ws=r("a"),hl=a("compute"),ml=a(" to calculate the WER:"),da=u(),v(Ls.$$.fragment),fa=u(),ss=r("p"),dl=a("Your "),Pt=r("code"),fl=a("compute_metrics"),_l=a(" function is ready to go now, and you\u2019ll return to it when you setup your training."),_a=u(),Re=r("h2"),ts=r("a"),Ct=r("span"),v(Fs.$$.fragment),gl=u(),Dt=r("span"),$l=a("Train"),ga=u(),v(as.$$.fragment),$a=u(),v(ns.$$.fragment),va=u(),We=r("h2"),ls=r("a"),St=r("span"),v(zs.$$.fragment),vl=u(),Ot=r("span"),jl=a("Inference"),ja=u(),Zs=r("p"),bl=a("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),ba=u(),et=r("p"),yl=a("Load an audio file you\u2019d like to run inference on. Remember to resample the sampling rate of the audio file to match the sampling rate of the model if you need to!"),ya=u(),v(Ms.$$.fragment),wa=u(),Ae=r("p"),wl=a("The simplest way to try out your finetuned model for inference is to use it in a "),st=r("a"),kl=a("pipeline()"),El=a(". Instantiate a "),It=r("code"),xl=a("pipeline"),ql=a(" for automatic speech recognition with your model, and pass your audio file to it:"),ka=u(),v(Us.$$.fragment),Ea=u(),v(rs.$$.fragment),xa=u(),os=r("p"),Al=a("You can also manually replicate the results of the "),Rt=r("code"),Tl=a("pipeline"),Pl=a(" if you\u2019d like:"),qa=u(),v(ps.$$.fragment),this.h()},l(e){const l=Yr('[data-svelte="svelte-1phssyn"]',document.head);c=o(l,"META",{name:!0,content:!0}),l.forEach(t),$=h(e),m=o(e,"H1",{class:!0});var Ns=p(m);g=o(Ns,"A",{id:!0,class:!0,href:!0});var Wt=p(g);x=o(Wt,"SPAN",{});var Lt=p(x);j(E.$$.fragment,Lt),Lt.forEach(t),Wt.forEach(t),q=h(Ns),P=o(Ns,"SPAN",{});var Ft=p(P);C=n(Ft,"Automatic speech recognition"),Ft.forEach(t),Ns.forEach(t),A=h(e),j(I.$$.fragment,e),D=h(e),Y=o(e,"P",{});var zt=p(Y);W=n(zt,"Automatic speech recognition (ASR) converts a speech signal to text, mapping a sequence of audio inputs to text outputs. Virtual assistants like Siri and Alexa use ASR models to help users everyday, and there are many other useful user-facing applications like live captioning and note-taking during meetings."),zt.forEach(t),te=h(e),N=o(e,"P",{});var Dl=p(N);M=n(Dl,"This guide will show you how to:"),Dl.forEach(t),R=h(e),U=o(e,"OL",{});var Ta=p(U);L=o(Ta,"LI",{});var tt=p(L);he=n(tt,"Finetune "),V=o(tt,"A",{href:!0,rel:!0});var Sl=p(V);H=n(Sl,"Wav2Vec2"),Sl.forEach(t),ae=n(tt," on the "),_=o(tt,"A",{href:!0,rel:!0});var Ol=p(_);S=n(Ol,"MInDS-14"),Ol.forEach(t),$e=n(tt," dataset to transcribe audio to text."),tt.forEach(t),ve=h(Ta),F=o(Ta,"LI",{});var Il=p(F);je=n(Il,"Use your finetuned model for inference."),Il.forEach(t),Ta.forEach(t),me=h(e),j(ne.$$.fragment,e),X=h(e),be=o(e,"P",{});var Rl=p(be);ye=n(Rl,"Before you begin, make sure you have all the necessary libraries installed:"),Rl.forEach(t),Le=h(e),j(de.$$.fragment,e),we=h(e),ke=o(e,"P",{});var Wl=p(ke);us=n(Wl,"We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),Wl.forEach(t),Fe=h(e),j(K.$$.fragment,e),ze=h(e),G=o(e,"H2",{class:!0});var Pa=p(G);le=o(Pa,"A",{id:!0,class:!0,href:!0});var Ll=p(le);Pe=o(Ll,"SPAN",{});var Fl=p(Pe);j(re.$$.fragment,Fl),Fl.forEach(t),Ll.forEach(t),fe=h(Pa),Ee=o(Pa,"SPAN",{});var zl=p(Ee);oe=n(zl,"Load MInDS-14 dataset"),zl.forEach(t),Pa.forEach(t),Me=h(e),Q=o(e,"P",{});var Ca=p(Q);hs=n(Ca,"Start by loading a smaller subset of the "),_e=o(Ca,"A",{href:!0,rel:!0});var Ml=p(_e);Ue=n(Ml,"MInDS-14"),Ml.forEach(t),ge=n(Ca," dataset from the \u{1F917} Datasets library. This\u2019ll give you a chance to experiment and make sure everything works before spending more time training on the full dataset."),Ca.forEach(t),Ce=h(e),j(d.$$.fragment,e),T=h(e),B=o(e,"P",{});var at=p(B);Hs=n(at,"Split the dataset\u2019s "),Ne=o(at,"CODE",{});var Ul=p(Ne);xe=n(Ul,"train"),Ul.forEach(t),Z=n(at," split into a train and test set with the "),He=o(at,"CODE",{});var Nl=p(He);Ys=n(Nl,"~Dataset.train_test_split"),Nl.forEach(t),Vs=n(at," method:"),at.forEach(t),ms=h(e),j(ee.$$.fragment,e),ds=h(e),De=o(e,"P",{});var Hl=p(De);Ye=n(Hl,"Then take a look at the dataset:"),Hl.forEach(t),fs=h(e),j(pe.$$.fragment,e),_s=h(e),J=o(e,"P",{});var ue=p(J);Va=n(ue,"While the dataset contains a lot of useful information, like "),pt=o(ue,"CODE",{});var Yl=p(pt);Ga=n(Yl,"lang_id"),Yl.forEach(t),Ba=n(ue," and "),it=o(ue,"CODE",{});var Vl=p(it);Ja=n(Vl,"english_transcription"),Vl.forEach(t),Ka=n(ue,", you\u2019ll focus on the "),ct=o(ue,"CODE",{});var Gl=p(ct);Qa=n(Gl,"audio"),Gl.forEach(t),Xa=n(ue," and "),ut=o(ue,"CODE",{});var Bl=p(ut);Za=n(Bl,"transcription"),Bl.forEach(t),en=n(ue," in this guide. Remove the other columns with the "),gs=o(ue,"A",{href:!0,rel:!0});var Jl=p(gs);sn=n(Jl,"remove_columns"),Jl.forEach(t),tn=n(ue," method:"),ue.forEach(t),Ut=h(e),j($s.$$.fragment,e),Nt=h(e),Gs=o(e,"P",{});var Kl=p(Gs);an=n(Kl,"Take a look at the example again:"),Kl.forEach(t),Ht=h(e),j(vs.$$.fragment,e),Yt=h(e),Bs=o(e,"P",{});var Ql=p(Bs);nn=n(Ql,"There are two fields:"),Ql.forEach(t),Vt=h(e),Ve=o(e,"UL",{});var Da=p(Ve);Ge=o(Da,"LI",{});var Mt=p(Ge);ht=o(Mt,"CODE",{});var Xl=p(ht);ln=n(Xl,"audio"),Xl.forEach(t),rn=n(Mt,": a 1-dimensional "),mt=o(Mt,"CODE",{});var Zl=p(mt);on=n(Zl,"array"),Zl.forEach(t),pn=n(Mt," of the speech signal that must be called to load and resample the audio file."),Mt.forEach(t),cn=h(Da),Js=o(Da,"LI",{});var Cl=p(Js);dt=o(Cl,"CODE",{});var er=p(dt);un=n(er,"transcription"),er.forEach(t),hn=n(Cl,": the target text."),Cl.forEach(t),Da.forEach(t),Gt=h(e),Se=o(e,"H2",{class:!0});var Sa=p(Se);Be=o(Sa,"A",{id:!0,class:!0,href:!0});var sr=p(Be);ft=o(sr,"SPAN",{});var tr=p(ft);j(js.$$.fragment,tr),tr.forEach(t),sr.forEach(t),mn=h(Sa),_t=o(Sa,"SPAN",{});var ar=p(_t);dn=n(ar,"Preprocess"),ar.forEach(t),Sa.forEach(t),Bt=h(e),Ks=o(e,"P",{});var nr=p(Ks);fn=n(nr,"The next step is to load a Wav2Vec2 processor to process the audio signal:"),nr.forEach(t),Jt=h(e),j(bs.$$.fragment,e),Kt=h(e),Je=o(e,"P",{});var Oa=p(Je);_n=n(Oa,"The MInDS-14 dataset has a sampling rate of 8000khz (you can find this information in its "),ys=o(Oa,"A",{href:!0,rel:!0});var lr=p(ys);gn=n(lr,"dataset card"),lr.forEach(t),$n=n(Oa,"), which means you\u2019ll need to resample the dataset to 16000kHz to use the pretrained Wav2Vec2 model:"),Oa.forEach(t),Qt=h(e),j(ws.$$.fragment,e),Xt=h(e),Ke=o(e,"P",{});var Ia=p(Ke);vn=n(Ia,"As you can see in the "),gt=o(Ia,"CODE",{});var rr=p(gt);jn=n(rr,"transcription"),rr.forEach(t),bn=n(Ia," above, the text contains a mix of upper and lowercase characters. The Wav2Vec2 tokenizer is only trained on uppercase characters so you\u2019ll need to make sure the text matches the tokenizer\u2019s vocabulary:"),Ia.forEach(t),Zt=h(e),j(ks.$$.fragment,e),ea=h(e),Qs=o(e,"P",{});var or=p(Qs);yn=n(or,"Now create a preprocessing function that:"),or.forEach(t),sa=h(e),Qe=o(e,"OL",{});var Ra=p(Qe);Es=o(Ra,"LI",{});var Wa=p(Es);wn=n(Wa,"Calls the "),$t=o(Wa,"CODE",{});var pr=p($t);kn=n(pr,"audio"),pr.forEach(t),En=n(Wa," column to load and resample the audio file."),Wa.forEach(t),xn=h(Ra),Oe=o(Ra,"LI",{});var nt=p(Oe);qn=n(nt,"Extracts the "),vt=o(nt,"CODE",{});var ir=p(vt);An=n(ir,"input_values"),ir.forEach(t),Tn=n(nt," from the audio file and tokenize the "),jt=o(nt,"CODE",{});var cr=p(jt);Pn=n(cr,"transcription"),cr.forEach(t),Cn=n(nt," column with the processor."),nt.forEach(t),Ra.forEach(t),ta=h(e),j(xs.$$.fragment,e),aa=h(e),se=o(e,"P",{});var Te=p(se);Dn=n(Te,"To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),qs=o(Te,"A",{href:!0,rel:!0});var ur=p(qs);Sn=n(ur,"map"),ur.forEach(t),On=n(Te," function. You can speed up "),bt=o(Te,"CODE",{});var hr=p(bt);In=n(hr,"map"),hr.forEach(t),Rn=n(Te," by increasing the number of processes with the "),yt=o(Te,"CODE",{});var mr=p(yt);Wn=n(mr,"num_proc"),mr.forEach(t),Ln=n(Te," parameter. Remove the columns you don\u2019t need with the "),As=o(Te,"A",{href:!0,rel:!0});var dr=p(As);Fn=n(dr,"remove_columns"),dr.forEach(t),zn=n(Te," method:"),Te.forEach(t),na=h(e),j(Ts.$$.fragment,e),la=h(e),ie=o(e,"P",{});var is=p(ie);Mn=n(is,"\u{1F917} Transformers doesn\u2019t have a data collator for ASR, so you\u2019ll need to adapt the "),Xs=o(is,"A",{href:!0});var fr=p(Xs);Un=n(fr,"DataCollatorWithPadding"),fr.forEach(t),Nn=n(is," to create a batch of examples. It\u2019ll also dynamically pad your text and labels to the length of the longest element in its batch (instead of the entire dataset) so they are a uniform length. While it is possible to pad your text in the "),wt=o(is,"CODE",{});var _r=p(wt);Hn=n(_r,"tokenizer"),_r.forEach(t),Yn=n(is," function by setting "),kt=o(is,"CODE",{});var gr=p(kt);Vn=n(gr,"padding=True"),gr.forEach(t),Gn=n(is,", dynamic padding is more efficient."),is.forEach(t),ra=h(e),qe=o(e,"P",{});var lt=p(qe);Bn=n(lt,"Unlike other data collators, this specific data collator needs to apply a different padding method to "),Et=o(lt,"CODE",{});var $r=p(Et);Jn=n($r,"input_values"),$r.forEach(t),Kn=n(lt," and "),xt=o(lt,"CODE",{});var vr=p(xt);Qn=n(vr,"labels"),vr.forEach(t),Xn=n(lt,":"),lt.forEach(t),oa=h(e),j(Ps.$$.fragment,e),pa=h(e),Xe=o(e,"P",{});var La=p(Xe);Zn=n(La,"Now instantiate your "),qt=o(La,"CODE",{});var jr=p(qt);el=n(jr,"DataCollatorForCTCWithPadding"),jr.forEach(t),sl=n(La,":"),La.forEach(t),ia=h(e),j(Cs.$$.fragment,e),ca=h(e),Ie=o(e,"H2",{class:!0});var Fa=p(Ie);Ze=o(Fa,"A",{id:!0,class:!0,href:!0});var br=p(Ze);At=o(br,"SPAN",{});var yr=p(At);j(Ds.$$.fragment,yr),yr.forEach(t),br.forEach(t),tl=h(Fa),Tt=o(Fa,"SPAN",{});var wr=p(Tt);al=n(wr,"Evaluate"),wr.forEach(t),Fa.forEach(t),ua=h(e),ce=o(e,"P",{});var cs=p(ce);nl=n(cs,"Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),Ss=o(cs,"A",{href:!0,rel:!0});var kr=p(Ss);ll=n(kr,"Evaluate"),kr.forEach(t),rl=n(cs," library. For this task, load the "),Os=o(cs,"A",{href:!0,rel:!0});var Er=p(Os);ol=n(Er,"word error rate"),Er.forEach(t),pl=n(cs," (WER) metric (see the \u{1F917} Evaluate "),Is=o(cs,"A",{href:!0,rel:!0});var xr=p(Is);il=n(xr,"quick tour"),xr.forEach(t),cl=n(cs," to learn more about how to load and compute a metric):"),cs.forEach(t),ha=h(e),j(Rs.$$.fragment,e),ma=h(e),es=o(e,"P",{});var za=p(es);ul=n(za,"Then create a function that passes your predictions and labels to "),Ws=o(za,"A",{href:!0,rel:!0});var qr=p(Ws);hl=n(qr,"compute"),qr.forEach(t),ml=n(za," to calculate the WER:"),za.forEach(t),da=h(e),j(Ls.$$.fragment,e),fa=h(e),ss=o(e,"P",{});var Ma=p(ss);dl=n(Ma,"Your "),Pt=o(Ma,"CODE",{});var Ar=p(Pt);fl=n(Ar,"compute_metrics"),Ar.forEach(t),_l=n(Ma," function is ready to go now, and you\u2019ll return to it when you setup your training."),Ma.forEach(t),_a=h(e),Re=o(e,"H2",{class:!0});var Ua=p(Re);ts=o(Ua,"A",{id:!0,class:!0,href:!0});var Tr=p(ts);Ct=o(Tr,"SPAN",{});var Pr=p(Ct);j(Fs.$$.fragment,Pr),Pr.forEach(t),Tr.forEach(t),gl=h(Ua),Dt=o(Ua,"SPAN",{});var Cr=p(Dt);$l=n(Cr,"Train"),Cr.forEach(t),Ua.forEach(t),ga=h(e),j(as.$$.fragment,e),$a=h(e),j(ns.$$.fragment,e),va=h(e),We=o(e,"H2",{class:!0});var Na=p(We);ls=o(Na,"A",{id:!0,class:!0,href:!0});var Dr=p(ls);St=o(Dr,"SPAN",{});var Sr=p(St);j(zs.$$.fragment,Sr),Sr.forEach(t),Dr.forEach(t),vl=h(Na),Ot=o(Na,"SPAN",{});var Or=p(Ot);jl=n(Or,"Inference"),Or.forEach(t),Na.forEach(t),ja=h(e),Zs=o(e,"P",{});var Ir=p(Zs);bl=n(Ir,"Great, now that you\u2019ve finetuned a model, you can use it for inference!"),Ir.forEach(t),ba=h(e),et=o(e,"P",{});var Rr=p(et);yl=n(Rr,"Load an audio file you\u2019d like to run inference on. Remember to resample the sampling rate of the audio file to match the sampling rate of the model if you need to!"),Rr.forEach(t),ya=h(e),j(Ms.$$.fragment,e),wa=h(e),Ae=o(e,"P",{});var rt=p(Ae);wl=n(rt,"The simplest way to try out your finetuned model for inference is to use it in a "),st=o(rt,"A",{href:!0});var Wr=p(st);kl=n(Wr,"pipeline()"),Wr.forEach(t),El=n(rt,". Instantiate a "),It=o(rt,"CODE",{});var Lr=p(It);xl=n(Lr,"pipeline"),Lr.forEach(t),ql=n(rt," for automatic speech recognition with your model, and pass your audio file to it:"),rt.forEach(t),ka=h(e),j(Us.$$.fragment,e),Ea=h(e),j(rs.$$.fragment,e),xa=h(e),os=o(e,"P",{});var Ha=p(os);Al=n(Ha,"You can also manually replicate the results of the "),Rt=o(Ha,"CODE",{});var Fr=p(Rt);Tl=n(Fr,"pipeline"),Fr.forEach(t),Pl=n(Ha," if you\u2019d like:"),Ha.forEach(t),qa=h(e),j(ps.$$.fragment,e),this.h()},h(){f(c,"name","hf:doc:metadata"),f(c,"content",JSON.stringify(no)),f(g,"id","automatic-speech-recognition"),f(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(g,"href","#automatic-speech-recognition"),f(m,"class","relative group"),f(V,"href","https://huggingface.co/facebook/wav2vec2-base"),f(V,"rel","nofollow"),f(_,"href","https://huggingface.co/datasets/PolyAI/minds14"),f(_,"rel","nofollow"),f(le,"id","load-minds14-dataset"),f(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"),f(le,"href","#load-minds14-dataset"),f(G,"class","relative group"),f(_e,"href","https://huggingface.co/datasets/PolyAI/minds14"),f(_e,"rel","nofollow"),f(gs,"href","https://huggingface.co/docs/datasets/v2.7.1/en/package_reference/main_classes#datasets.Dataset.remove_columns"),f(gs,"rel","nofollow"),f(Be,"id","preprocess"),f(Be,"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"),f(Be,"href","#preprocess"),f(Se,"class","relative group"),f(ys,"href","https://huggingface.co/datasets/PolyAI/minds14"),f(ys,"rel","nofollow"),f(qs,"href","https://huggingface.co/docs/datasets/v2.7.1/en/package_reference/main_classes#datasets.Dataset.map"),f(qs,"rel","nofollow"),f(As,"href","https://huggingface.co/docs/datasets/v2.7.1/en/package_reference/main_classes#datasets.Dataset.remove_columns"),f(As,"rel","nofollow"),f(Xs,"href","/docs/transformers/v4.25.1/en/main_classes/data_collator#transformers.DataCollatorWithPadding"),f(Ze,"id","evaluate"),f(Ze,"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"),f(Ze,"href","#evaluate"),f(Ie,"class","relative group"),f(Ss,"href","https://huggingface.co/docs/evaluate/index"),f(Ss,"rel","nofollow"),f(Os,"href","https://huggingface.co/spaces/evaluate-metric/wer"),f(Os,"rel","nofollow"),f(Is,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),f(Is,"rel","nofollow"),f(Ws,"href","https://huggingface.co/docs/evaluate/v0.3.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),f(Ws,"rel","nofollow"),f(ts,"id","train"),f(ts,"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"),f(ts,"href","#train"),f(Re,"class","relative group"),f(ls,"id","inference"),f(ls,"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"),f(ls,"href","#inference"),f(We,"class","relative group"),f(st,"href","/docs/transformers/v4.25.1/en/main_classes/pipelines#transformers.pipeline")},m(e,l){s(document.head,c),i(e,$,l),i(e,m,l),s(m,g),s(g,x),b(E,x,null),s(m,q),s(m,P),s(P,C),i(e,A,l),b(I,e,l),i(e,D,l),i(e,Y,l),s(Y,W),i(e,te,l),i(e,N,l),s(N,M),i(e,R,l),i(e,U,l),s(U,L),s(L,he),s(L,V),s(V,H),s(L,ae),s(L,_),s(_,S),s(L,$e),s(U,ve),s(U,F),s(F,je),i(e,me,l),b(ne,e,l),i(e,X,l),i(e,be,l),s(be,ye),i(e,Le,l),b(de,e,l),i(e,we,l),i(e,ke,l),s(ke,us),i(e,Fe,l),b(K,e,l),i(e,ze,l),i(e,G,l),s(G,le),s(le,Pe),b(re,Pe,null),s(G,fe),s(G,Ee),s(Ee,oe),i(e,Me,l),i(e,Q,l),s(Q,hs),s(Q,_e),s(_e,Ue),s(Q,ge),i(e,Ce,l),b(d,e,l),i(e,T,l),i(e,B,l),s(B,Hs),s(B,Ne),s(Ne,xe),s(B,Z),s(B,He),s(He,Ys),s(B,Vs),i(e,ms,l),b(ee,e,l),i(e,ds,l),i(e,De,l),s(De,Ye),i(e,fs,l),b(pe,e,l),i(e,_s,l),i(e,J,l),s(J,Va),s(J,pt),s(pt,Ga),s(J,Ba),s(J,it),s(it,Ja),s(J,Ka),s(J,ct),s(ct,Qa),s(J,Xa),s(J,ut),s(ut,Za),s(J,en),s(J,gs),s(gs,sn),s(J,tn),i(e,Ut,l),b($s,e,l),i(e,Nt,l),i(e,Gs,l),s(Gs,an),i(e,Ht,l),b(vs,e,l),i(e,Yt,l),i(e,Bs,l),s(Bs,nn),i(e,Vt,l),i(e,Ve,l),s(Ve,Ge),s(Ge,ht),s(ht,ln),s(Ge,rn),s(Ge,mt),s(mt,on),s(Ge,pn),s(Ve,cn),s(Ve,Js),s(Js,dt),s(dt,un),s(Js,hn),i(e,Gt,l),i(e,Se,l),s(Se,Be),s(Be,ft),b(js,ft,null),s(Se,mn),s(Se,_t),s(_t,dn),i(e,Bt,l),i(e,Ks,l),s(Ks,fn),i(e,Jt,l),b(bs,e,l),i(e,Kt,l),i(e,Je,l),s(Je,_n),s(Je,ys),s(ys,gn),s(Je,$n),i(e,Qt,l),b(ws,e,l),i(e,Xt,l),i(e,Ke,l),s(Ke,vn),s(Ke,gt),s(gt,jn),s(Ke,bn),i(e,Zt,l),b(ks,e,l),i(e,ea,l),i(e,Qs,l),s(Qs,yn),i(e,sa,l),i(e,Qe,l),s(Qe,Es),s(Es,wn),s(Es,$t),s($t,kn),s(Es,En),s(Qe,xn),s(Qe,Oe),s(Oe,qn),s(Oe,vt),s(vt,An),s(Oe,Tn),s(Oe,jt),s(jt,Pn),s(Oe,Cn),i(e,ta,l),b(xs,e,l),i(e,aa,l),i(e,se,l),s(se,Dn),s(se,qs),s(qs,Sn),s(se,On),s(se,bt),s(bt,In),s(se,Rn),s(se,yt),s(yt,Wn),s(se,Ln),s(se,As),s(As,Fn),s(se,zn),i(e,na,l),b(Ts,e,l),i(e,la,l),i(e,ie,l),s(ie,Mn),s(ie,Xs),s(Xs,Un),s(ie,Nn),s(ie,wt),s(wt,Hn),s(ie,Yn),s(ie,kt),s(kt,Vn),s(ie,Gn),i(e,ra,l),i(e,qe,l),s(qe,Bn),s(qe,Et),s(Et,Jn),s(qe,Kn),s(qe,xt),s(xt,Qn),s(qe,Xn),i(e,oa,l),b(Ps,e,l),i(e,pa,l),i(e,Xe,l),s(Xe,Zn),s(Xe,qt),s(qt,el),s(Xe,sl),i(e,ia,l),b(Cs,e,l),i(e,ca,l),i(e,Ie,l),s(Ie,Ze),s(Ze,At),b(Ds,At,null),s(Ie,tl),s(Ie,Tt),s(Tt,al),i(e,ua,l),i(e,ce,l),s(ce,nl),s(ce,Ss),s(Ss,ll),s(ce,rl),s(ce,Os),s(Os,ol),s(ce,pl),s(ce,Is),s(Is,il),s(ce,cl),i(e,ha,l),b(Rs,e,l),i(e,ma,l),i(e,es,l),s(es,ul),s(es,Ws),s(Ws,hl),s(es,ml),i(e,da,l),b(Ls,e,l),i(e,fa,l),i(e,ss,l),s(ss,dl),s(ss,Pt),s(Pt,fl),s(ss,_l),i(e,_a,l),i(e,Re,l),s(Re,ts),s(ts,Ct),b(Fs,Ct,null),s(Re,gl),s(Re,Dt),s(Dt,$l),i(e,ga,l),b(as,e,l),i(e,$a,l),b(ns,e,l),i(e,va,l),i(e,We,l),s(We,ls),s(ls,St),b(zs,St,null),s(We,vl),s(We,Ot),s(Ot,jl),i(e,ja,l),i(e,Zs,l),s(Zs,bl),i(e,ba,l),i(e,et,l),s(et,yl),i(e,ya,l),b(Ms,e,l),i(e,wa,l),i(e,Ae,l),s(Ae,wl),s(Ae,st),s(st,kl),s(Ae,El),s(Ae,It),s(It,xl),s(Ae,ql),i(e,ka,l),b(Us,e,l),i(e,Ea,l),b(rs,e,l),i(e,xa,l),i(e,os,l),s(os,Al),s(os,Rt),s(Rt,Tl),s(os,Pl),i(e,qa,l),b(ps,e,l),Aa=!0},p(e,[l]){const Ns={};l&2&&(Ns.$$scope={dirty:l,ctx:e}),ne.$set(Ns);const Wt={};l&2&&(Wt.$$scope={dirty:l,ctx:e}),as.$set(Wt);const Lt={};l&2&&(Lt.$$scope={dirty:l,ctx:e}),ns.$set(Lt);const Ft={};l&2&&(Ft.$$scope={dirty:l,ctx:e}),rs.$set(Ft);const zt={};l&2&&(zt.$$scope={dirty:l,ctx:e}),ps.$set(zt)},i(e){Aa||(y(E.$$.fragment,e),y(I.$$.fragment,e),y(ne.$$.fragment,e),y(de.$$.fragment,e),y(K.$$.fragment,e),y(re.$$.fragment,e),y(d.$$.fragment,e),y(ee.$$.fragment,e),y(pe.$$.fragment,e),y($s.$$.fragment,e),y(vs.$$.fragment,e),y(js.$$.fragment,e),y(bs.$$.fragment,e),y(ws.$$.fragment,e),y(ks.$$.fragment,e),y(xs.$$.fragment,e),y(Ts.$$.fragment,e),y(Ps.$$.fragment,e),y(Cs.$$.fragment,e),y(Ds.$$.fragment,e),y(Rs.$$.fragment,e),y(Ls.$$.fragment,e),y(Fs.$$.fragment,e),y(as.$$.fragment,e),y(ns.$$.fragment,e),y(zs.$$.fragment,e),y(Ms.$$.fragment,e),y(Us.$$.fragment,e),y(rs.$$.fragment,e),y(ps.$$.fragment,e),Aa=!0)},o(e){w(E.$$.fragment,e),w(I.$$.fragment,e),w(ne.$$.fragment,e),w(de.$$.fragment,e),w(K.$$.fragment,e),w(re.$$.fragment,e),w(d.$$.fragment,e),w(ee.$$.fragment,e),w(pe.$$.fragment,e),w($s.$$.fragment,e),w(vs.$$.fragment,e),w(js.$$.fragment,e),w(bs.$$.fragment,e),w(ws.$$.fragment,e),w(ks.$$.fragment,e),w(xs.$$.fragment,e),w(Ts.$$.fragment,e),w(Ps.$$.fragment,e),w(Cs.$$.fragment,e),w(Ds.$$.fragment,e),w(Rs.$$.fragment,e),w(Ls.$$.fragment,e),w(Fs.$$.fragment,e),w(as.$$.fragment,e),w(ns.$$.fragment,e),w(zs.$$.fragment,e),w(Ms.$$.fragment,e),w(Us.$$.fragment,e),w(rs.$$.fragment,e),w(ps.$$.fragment,e),Aa=!1},d(e){t(c),e&&t($),e&&t(m),k(E),e&&t(A),k(I,e),e&&t(D),e&&t(Y),e&&t(te),e&&t(N),e&&t(R),e&&t(U),e&&t(me),k(ne,e),e&&t(X),e&&t(be),e&&t(Le),k(de,e),e&&t(we),e&&t(ke),e&&t(Fe),k(K,e),e&&t(ze),e&&t(G),k(re),e&&t(Me),e&&t(Q),e&&t(Ce),k(d,e),e&&t(T),e&&t(B),e&&t(ms),k(ee,e),e&&t(ds),e&&t(De),e&&t(fs),k(pe,e),e&&t(_s),e&&t(J),e&&t(Ut),k($s,e),e&&t(Nt),e&&t(Gs),e&&t(Ht),k(vs,e),e&&t(Yt),e&&t(Bs),e&&t(Vt),e&&t(Ve),e&&t(Gt),e&&t(Se),k(js),e&&t(Bt),e&&t(Ks),e&&t(Jt),k(bs,e),e&&t(Kt),e&&t(Je),e&&t(Qt),k(ws,e),e&&t(Xt),e&&t(Ke),e&&t(Zt),k(ks,e),e&&t(ea),e&&t(Qs),e&&t(sa),e&&t(Qe),e&&t(ta),k(xs,e),e&&t(aa),e&&t(se),e&&t(na),k(Ts,e),e&&t(la),e&&t(ie),e&&t(ra),e&&t(qe),e&&t(oa),k(Ps,e),e&&t(pa),e&&t(Xe),e&&t(ia),k(Cs,e),e&&t(ca),e&&t(Ie),k(Ds),e&&t(ua),e&&t(ce),e&&t(ha),k(Rs,e),e&&t(ma),e&&t(es),e&&t(da),k(Ls,e),e&&t(fa),e&&t(ss),e&&t(_a),e&&t(Re),k(Fs),e&&t(ga),k(as,e),e&&t($a),k(ns,e),e&&t(va),e&&t(We),k(zs),e&&t(ja),e&&t(Zs),e&&t(ba),e&&t(et),e&&t(ya),k(Ms,e),e&&t(wa),e&&t(Ae),e&&t(ka),k(Us,e),e&&t(Ea),k(rs,e),e&&t(xa),e&&t(os),e&&t(qa),k(ps,e)}}}const no={local:"automatic-speech-recognition",sections:[{local:"load-minds14-dataset",title:"Load MInDS-14 dataset"},{local:"preprocess",title:"Preprocess"},{local:"evaluate",title:"Evaluate"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Automatic speech recognition"};function lo(z){return Vr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ho extends Ur{constructor(c){super();Nr(this,c,lo,ao,Hr,{})}}export{ho as default,no as metadata};
