import{S as zr,i as Nr,s as Hr,e as l,k as c,w as v,t as a,M as Vr,c as r,d as t,m as h,a as o,x as j,h as n,b as m,G as s,g as p,y as b,q as y,o as w,B as k,v as Yr,L as Gr}from"../../chunks/vendor-hf-doc-builder.js";import{T as Va}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 F}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as Mr,M as Ur}from"../../chunks/Markdown-hf-doc-builder.js";function Jr(K){let u,_,d,$,A,E,I,O,T,q,W,P,Y,R,B,N,U,S,z,L,Q,G,H,J,g,C,Z,re,M,ee,ne;return{c(){u=a(`The task illustrated in this tutorial is supported by the following model architectures:

`),_=l("p"),d=l("a"),$=a("Data2VecAudio"),A=a(", "),E=l("a"),I=a("Hubert"),O=a(", "),T=l("a"),q=a("M-CTC-T"),W=a(", "),P=l("a"),Y=a("SEW"),R=a(", "),B=l("a"),N=a("SEW-D"),U=a(", "),S=l("a"),z=a("UniSpeech"),L=a(", "),Q=l("a"),G=a("UniSpeechSat"),H=a(", "),J=l("a"),g=a("Wav2Vec2"),C=a(", "),Z=l("a"),re=a("Wav2Vec2-Conformer"),M=a(", "),ee=l("a"),ne=a("WavLM"),this.h()},l(V){u=n(V,`The task illustrated in this tutorial is supported by the following model architectures:

`),_=r(V,"P",{});var x=o(_);d=r(x,"A",{href:!0});var he=o(d);$=n(he,"Data2VecAudio"),he.forEach(t),A=n(x,", "),E=r(x,"A",{href:!0});var ue=o(E);I=n(ue,"Hubert"),ue.forEach(t),O=n(x,", "),T=r(x,"A",{href:!0});var ye=o(T);q=n(ye,"M-CTC-T"),ye.forEach(t),W=n(x,", "),P=r(x,"A",{href:!0});var oe=o(P);Y=n(oe,"SEW"),oe.forEach(t),R=n(x,", "),B=r(x,"A",{href:!0});var de=o(B);N=n(de,"SEW-D"),de.forEach(t),U=n(x,", "),S=r(x,"A",{href:!0});var me=o(S);z=n(me,"UniSpeech"),me.forEach(t),L=n(x,", "),Q=r(x,"A",{href:!0});var qe=o(Q);G=n(qe,"UniSpeechSat"),qe.forEach(t),H=n(x,", "),J=r(x,"A",{href:!0});var we=o(J);g=n(we,"Wav2Vec2"),we.forEach(t),C=n(x,", "),Z=r(x,"A",{href:!0});var X=o(Z);re=n(X,"Wav2Vec2-Conformer"),X.forEach(t),M=n(x,", "),ee=r(x,"A",{href:!0});var ke=o(ee);ne=n(ke,"WavLM"),ke.forEach(t),x.forEach(t),this.h()},h(){m(d,"href","../model_doc/data2vec-audio"),m(E,"href","../model_doc/hubert"),m(T,"href","../model_doc/mctct"),m(P,"href","../model_doc/sew"),m(B,"href","../model_doc/sew-d"),m(S,"href","../model_doc/unispeech"),m(Q,"href","../model_doc/unispeech-sat"),m(J,"href","../model_doc/wav2vec2"),m(Z,"href","../model_doc/wav2vec2-conformer"),m(ee,"href","../model_doc/wavlm")},m(V,x){p(V,u,x),p(V,_,x),s(_,d),s(d,$),s(_,A),s(_,E),s(E,I),s(_,O),s(_,T),s(T,q),s(_,W),s(_,P),s(P,Y),s(_,R),s(_,B),s(B,N),s(_,U),s(_,S),s(S,z),s(_,L),s(_,Q),s(Q,G),s(_,H),s(_,J),s(J,g),s(_,C),s(_,Z),s(Z,re),s(_,M),s(_,ee),s(ee,ne)},d(V){V&&t(u),V&&t(_)}}}function Kr(K){let u,_,d,$,A,E,I,O;return{c(){u=l("p"),_=a("If you aren\u2019t familiar with finetuning a model with the "),d=l("a"),$=a("Trainer"),A=a(", take a look at the basic tutorial "),E=l("a"),I=a("here"),O=a("!"),this.h()},l(T){u=r(T,"P",{});var q=o(u);_=n(q,"If you aren\u2019t familiar with finetuning a model with the "),d=r(q,"A",{href:!0});var W=o(d);$=n(W,"Trainer"),W.forEach(t),A=n(q,", take a look at the basic tutorial "),E=r(q,"A",{href:!0});var P=o(E);I=n(P,"here"),P.forEach(t),O=n(q,"!"),q.forEach(t),this.h()},h(){m(d,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(E,"href","../training#train-with-pytorch-trainer")},m(T,q){p(T,u,q),s(u,_),s(u,d),s(d,$),s(u,A),s(u,E),s(E,I),s(u,O)},d(T){T&&t(u)}}}function Qr(K){let u,_,d,$,A,E,I,O,T,q,W,P,Y,R,B,N,U,S,z,L,Q,G,H,J,g,C,Z,re,M,ee,ne,V,x,he,ue,ye,oe,de,me,qe,we,X,ke,se,fe,Oe,_e,Ee,Te,ge,ze,le,us,xe,Ne,Ae,Ie;return u=new Va({props:{$$slots:{default:[Kr]},$$scope:{ctx:K}}}),P=new F({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>)`}}),Ee=new F({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()`}}),Ae=new F({props:{code:"trainer.push_to_hub()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){v(u.$$.fragment),_=c(),d=l("p"),$=a("You\u2019re ready to start training your model now! Load Wav2Vec2 with "),A=l("a"),E=a("AutoModelForCTC"),I=a(". Specify the reduction to apply with the "),O=l("code"),T=a("ctc_loss_reduction"),q=a(" parameter. It is often better to use the average instead of the default summation:"),W=c(),v(P.$$.fragment),Y=c(),R=l("p"),B=a("At this point, only three steps remain:"),N=c(),U=l("ol"),S=l("li"),z=a("Define your training hyperparameters in "),L=l("a"),Q=a("TrainingArguments"),G=a(". The only required parameter is "),H=l("code"),J=a("output_dir"),g=a(" which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),C=l("code"),Z=a("push_to_hub=True"),re=a(" (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),M=l("a"),ee=a("Trainer"),ne=a(" will evaluate the WER and save the training checkpoint."),V=c(),x=l("li"),he=a("Pass the training arguments to "),ue=l("a"),ye=a("Trainer"),oe=a(" along with the model, dataset, tokenizer, data collator, and "),de=l("code"),me=a("compute_metrics"),qe=a(" function."),we=c(),X=l("li"),ke=a("Call "),se=l("a"),fe=a("train()"),Oe=a(" to finetune your model."),_e=c(),v(Ee.$$.fragment),Te=c(),ge=l("p"),ze=a("Once training is completed, share your model to the Hub with the "),le=l("a"),us=a("push_to_hub()"),xe=a(" method so everyone can use your model:"),Ne=c(),v(Ae.$$.fragment),this.h()},l(f){j(u.$$.fragment,f),_=h(f),d=r(f,"P",{});var D=o(d);$=n(D,"You\u2019re ready to start training your model now! Load Wav2Vec2 with "),A=r(D,"A",{href:!0});var te=o(A);E=n(te,"AutoModelForCTC"),te.forEach(t),I=n(D,". Specify the reduction to apply with the "),O=r(D,"CODE",{});var Hs=o(O);T=n(Hs,"ctc_loss_reduction"),Hs.forEach(t),q=n(D," parameter. It is often better to use the average instead of the default summation:"),D.forEach(t),W=h(f),j(P.$$.fragment,f),Y=h(f),R=r(f,"P",{});var He=o(R);B=n(He,"At this point, only three steps remain:"),He.forEach(t),N=h(f),U=r(f,"OL",{});var Pe=o(U);S=r(Pe,"LI",{});var ie=o(S);z=n(ie,"Define your training hyperparameters in "),L=r(ie,"A",{href:!0});var Ve=o(L);Q=n(Ve,"TrainingArguments"),Ve.forEach(t),G=n(ie,". The only required parameter is "),H=r(ie,"CODE",{});var Vs=o(H);J=n(Vs,"output_dir"),Vs.forEach(t),g=n(ie," which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),C=r(ie,"CODE",{});var Ys=o(C);Z=n(Ys,"push_to_hub=True"),Ys.forEach(t),re=n(ie," (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),M=r(ie,"A",{href:!0});var ds=o(M);ee=n(ds,"Trainer"),ds.forEach(t),ne=n(ie," will evaluate the WER and save the training checkpoint."),ie.forEach(t),V=h(Pe),x=r(Pe,"LI",{});var pe=o(x);he=n(pe,"Pass the training arguments to "),ue=r(pe,"A",{href:!0});var ms=o(ue);ye=n(ms,"Trainer"),ms.forEach(t),oe=n(pe," along with the model, dataset, tokenizer, data collator, and "),de=r(pe,"CODE",{});var We=o(de);me=n(We,"compute_metrics"),We.forEach(t),qe=n(pe," function."),pe.forEach(t),we=h(Pe),X=r(Pe,"LI",{});var Ye=o(X);ke=n(Ye,"Call "),se=r(Ye,"A",{href:!0});var fs=o(se);fe=n(fs,"train()"),fs.forEach(t),Oe=n(Ye," to finetune your model."),Ye.forEach(t),Pe.forEach(t),_e=h(f),j(Ee.$$.fragment,f),Te=h(f),ge=r(f,"P",{});var $e=o(ge);ze=n($e,"Once training is completed, share your model to the Hub with the "),le=r($e,"A",{href:!0});var _s=o(le);us=n(_s,"push_to_hub()"),_s.forEach(t),xe=n($e," method so everyone can use your model:"),$e.forEach(t),Ne=h(f),j(Ae.$$.fragment,f),this.h()},h(){m(A,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForCTC"),m(L,"href","/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments"),m(M,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(ue,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(se,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.train"),m(le,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.push_to_hub")},m(f,D){b(u,f,D),p(f,_,D),p(f,d,D),s(d,$),s(d,A),s(A,E),s(d,I),s(d,O),s(O,T),s(d,q),p(f,W,D),b(P,f,D),p(f,Y,D),p(f,R,D),s(R,B),p(f,N,D),p(f,U,D),s(U,S),s(S,z),s(S,L),s(L,Q),s(S,G),s(S,H),s(H,J),s(S,g),s(S,C),s(C,Z),s(S,re),s(S,M),s(M,ee),s(S,ne),s(U,V),s(U,x),s(x,he),s(x,ue),s(ue,ye),s(x,oe),s(x,de),s(de,me),s(x,qe),s(U,we),s(U,X),s(X,ke),s(X,se),s(se,fe),s(X,Oe),p(f,_e,D),b(Ee,f,D),p(f,Te,D),p(f,ge,D),s(ge,ze),s(ge,le),s(le,us),s(ge,xe),p(f,Ne,D),b(Ae,f,D),Ie=!0},p(f,D){const te={};D&2&&(te.$$scope={dirty:D,ctx:f}),u.$set(te)},i(f){Ie||(y(u.$$.fragment,f),y(P.$$.fragment,f),y(Ee.$$.fragment,f),y(Ae.$$.fragment,f),Ie=!0)},o(f){w(u.$$.fragment,f),w(P.$$.fragment,f),w(Ee.$$.fragment,f),w(Ae.$$.fragment,f),Ie=!1},d(f){k(u,f),f&&t(_),f&&t(d),f&&t(W),k(P,f),f&&t(Y),f&&t(R),f&&t(N),f&&t(U),f&&t(_e),k(Ee,f),f&&t(Te),f&&t(ge),f&&t(Ne),k(Ae,f)}}}function Xr(K){let u,_;return u=new Ur({props:{$$slots:{default:[Qr]},$$scope:{ctx:K}}}),{c(){v(u.$$.fragment)},l(d){j(u.$$.fragment,d)},m(d,$){b(u,d,$),_=!0},p(d,$){const A={};$&2&&(A.$$scope={dirty:$,ctx:d}),u.$set(A)},i(d){_||(y(u.$$.fragment,d),_=!0)},o(d){w(u.$$.fragment,d),_=!1},d(d){k(u,d)}}}function Zr(K){let u,_,d,$,A,E,I,O;return{c(){u=l("p"),_=a("For a more in-depth example of how to finetune a model for automatic speech recognition, take a look at this blog "),d=l("a"),$=a("post"),A=a(" for English ASR and this "),E=l("a"),I=a("post"),O=a(" for multilingual ASR."),this.h()},l(T){u=r(T,"P",{});var q=o(u);_=n(q,"For a more in-depth example of how to finetune a model for automatic speech recognition, take a look at this blog "),d=r(q,"A",{href:!0,rel:!0});var W=o(d);$=n(W,"post"),W.forEach(t),A=n(q," for English ASR and this "),E=r(q,"A",{href:!0,rel:!0});var P=o(E);I=n(P,"post"),P.forEach(t),O=n(q," for multilingual ASR."),q.forEach(t),this.h()},h(){m(d,"href","https://huggingface.co/blog/fine-tune-wav2vec2-english"),m(d,"rel","nofollow"),m(E,"href","https://huggingface.co/blog/fine-tune-xlsr-wav2vec2"),m(E,"rel","nofollow")},m(T,q){p(T,u,q),s(u,_),s(u,d),s(d,$),s(u,A),s(u,E),s(E,I),s(u,O)},d(T){T&&t(u)}}}function eo(K){let u,_;return{c(){u=l("p"),_=a("The transcription is decent, but it could be better! Try finetuning your model on more examples to get even better results!")},l(d){u=r(d,"P",{});var $=o(u);_=n($,"The transcription is decent, but it could be better! Try finetuning your model on more examples to get even better results!"),$.forEach(t)},m(d,$){p(d,u,$),s(u,_)},d(d){d&&t(u)}}}function so(K){let u,_,d,$,A,E,I,O,T,q,W,P,Y,R,B,N,U,S,z,L,Q,G,H,J;return I=new F({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>)`}}),P=new F({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 F({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(){u=l("p"),_=a("Load a processor to preprocess the audio file and transcription and return the "),d=l("code"),$=a("input"),A=a(" as PyTorch tensors:"),E=c(),v(I.$$.fragment),O=c(),T=l("p"),q=a("Pass your inputs to the model and return the logits:"),W=c(),v(P.$$.fragment),Y=c(),R=l("p"),B=a("Get the predicted "),N=l("code"),U=a("input_ids"),S=a(" with the highest probability, and use the processor to decode the predicted "),z=l("code"),L=a("input_ids"),Q=a(" back into text:"),G=c(),v(H.$$.fragment)},l(g){u=r(g,"P",{});var C=o(u);_=n(C,"Load a processor to preprocess the audio file and transcription and return the "),d=r(C,"CODE",{});var Z=o(d);$=n(Z,"input"),Z.forEach(t),A=n(C," as PyTorch tensors:"),C.forEach(t),E=h(g),j(I.$$.fragment,g),O=h(g),T=r(g,"P",{});var re=o(T);q=n(re,"Pass your inputs to the model and return the logits:"),re.forEach(t),W=h(g),j(P.$$.fragment,g),Y=h(g),R=r(g,"P",{});var M=o(R);B=n(M,"Get the predicted "),N=r(M,"CODE",{});var ee=o(N);U=n(ee,"input_ids"),ee.forEach(t),S=n(M," with the highest probability, and use the processor to decode the predicted "),z=r(M,"CODE",{});var ne=o(z);L=n(ne,"input_ids"),ne.forEach(t),Q=n(M," back into text:"),M.forEach(t),G=h(g),j(H.$$.fragment,g)},m(g,C){p(g,u,C),s(u,_),s(u,d),s(d,$),s(u,A),p(g,E,C),b(I,g,C),p(g,O,C),p(g,T,C),s(T,q),p(g,W,C),b(P,g,C),p(g,Y,C),p(g,R,C),s(R,B),s(R,N),s(N,U),s(R,S),s(R,z),s(z,L),s(R,Q),p(g,G,C),b(H,g,C),J=!0},p:Gr,i(g){J||(y(I.$$.fragment,g),y(P.$$.fragment,g),y(H.$$.fragment,g),J=!0)},o(g){w(I.$$.fragment,g),w(P.$$.fragment,g),w(H.$$.fragment,g),J=!1},d(g){g&&t(u),g&&t(E),k(I,g),g&&t(O),g&&t(T),g&&t(W),k(P,g),g&&t(Y),g&&t(R),g&&t(G),k(H,g)}}}function to(K){let u,_;return u=new Ur({props:{$$slots:{default:[so]},$$scope:{ctx:K}}}),{c(){v(u.$$.fragment)},l(d){j(u.$$.fragment,d)},m(d,$){b(u,d,$),_=!0},p(d,$){const A={};$&2&&(A.$$scope={dirty:$,ctx:d}),u.$set(A)},i(d){_||(y(u.$$.fragment,d),_=!0)},o(d){w(u.$$.fragment,d),_=!1},d(d){k(u,d)}}}function ao(K){let u,_,d,$,A,E,I,O,T,q,W,P,Y,R,B,N,U,S,z,L,Q,G,H,J,g,C,Z,re,M,ee,ne,V,x,he,ue,ye,oe,de,me,qe,we,X,ke,se,fe,Oe,_e,Ee,Te,ge,ze,le,us,xe,Ne,Ae,Ie,f,D,te,Hs,He,Pe,ie,Ve,Vs,Ys,ds,pe,ms,We,Ye,fs,$e,_s,ae,Ya,it,Ga,Ba,pt,Ja,Ka,ct,Qa,Xa,ht,Za,en,gs,sn,tn,zt,$s,Nt,Gs,an,Ht,vs,Vt,Bs,nn,Yt,Ge,Be,ut,ln,rn,dt,on,pn,cn,Js,mt,hn,un,Gt,Re,Je,ft,js,dn,_t,mn,Bt,Ks,fn,Jt,bs,Kt,Ke,_n,ys,gn,$n,Qt,ws,Xt,Qe,vn,gt,jn,bn,Zt,ks,ea,Qs,yn,sa,Xe,Es,wn,$t,kn,En,xn,Le,An,vt,qn,Tn,jt,Pn,Cn,ta,xs,aa,ce,Dn,As,Sn,On,bt,In,Wn,yt,Rn,Ln,qs,Fn,Mn,na,Ts,la,ve,Un,Xs,zn,Nn,wt,Hn,Vn,kt,Yn,Gn,ra,Ce,Bn,Et,Jn,Kn,xt,Qn,Xn,oa,Ps,ia,Ze,Zn,At,el,sl,pa,Cs,ca,Fe,es,qt,Ds,tl,Tt,al,ha,je,nl,Ss,ll,rl,Os,ol,il,Is,pl,cl,ua,Ws,da,ss,hl,Rs,ul,dl,ma,Ls,fa,ts,ml,Pt,fl,_l,_a,Me,as,Ct,Fs,gl,Dt,$l,ga,ns,$a,ls,va,Ue,rs,St,Ms,vl,Ot,jl,ja,Zs,bl,ba,et,yl,ya,Us,wa,De,wl,st,kl,El,It,xl,Al,ka,zs,Ea,os,xa,is,ql,Wt,Tl,Pl,Aa,ps,qa;return E=new ot({}),W=new Br({props:{id:"TksaY_FDgnk"}}),V=new Va({props:{$$slots:{default:[Jr]},$$scope:{ctx:K}}}),oe=new F({props:{code:"pip install transformers datasets evaluate jiwer",highlighted:"pip install transformers datasets evaluate jiwer"}}),X=new F({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()`}}),_e=new ot({}),f=new F({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>)`}}),pe=new F({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>)'}}),$e=new F({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 F({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 F({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 F({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 F({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 F({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 F({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 F({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 F({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 F({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({}),Ws=new F({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 F({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({}),ns=new Mr({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[Xr]},$$scope:{ctx:K}}}),ls=new Va({props:{$$slots:{default:[Zr]},$$scope:{ctx:K}}}),Ms=new ot({}),Us=new F({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>]`}}),zs=new F({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>}`}}),os=new Va({props:{$$slots:{default:[eo]},$$scope:{ctx:K}}}),ps=new Mr({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[to]},$$scope:{ctx:K}}}),{c(){u=l("meta"),_=c(),d=l("h1"),$=l("a"),A=l("span"),v(E.$$.fragment),I=c(),O=l("span"),T=a("Automatic speech recognition"),q=c(),v(W.$$.fragment),P=c(),Y=l("p"),R=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."),B=c(),N=l("p"),U=a("This guide will show you how to:"),S=c(),z=l("ol"),L=l("li"),Q=a("Finetune "),G=l("a"),H=a("Wav2Vec2"),J=a(" on the "),g=l("a"),C=a("MInDS-14"),Z=a(" dataset to transcribe audio to text."),re=c(),M=l("li"),ee=a("Use your finetuned model for inference."),ne=c(),v(V.$$.fragment),x=c(),he=l("p"),ue=a("Before you begin, make sure you have all the necessary libraries installed:"),ye=c(),v(oe.$$.fragment),de=c(),me=l("p"),qe=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:"),we=c(),v(X.$$.fragment),ke=c(),se=l("h2"),fe=l("a"),Oe=l("span"),v(_e.$$.fragment),Ee=c(),Te=l("span"),ge=a("Load MInDS-14 dataset"),ze=c(),le=l("p"),us=a("Start by loading a smaller subset of the "),xe=l("a"),Ne=a("MInDS-14"),Ae=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."),Ie=c(),v(f.$$.fragment),D=c(),te=l("p"),Hs=a("Split the dataset\u2019s "),He=l("code"),Pe=a("train"),ie=a(" split into a train and test set with the "),Ve=l("code"),Vs=a("~Dataset.train_test_split"),Ys=a(" method:"),ds=c(),v(pe.$$.fragment),ms=c(),We=l("p"),Ye=a("Then take a look at the dataset:"),fs=c(),v($e.$$.fragment),_s=c(),ae=l("p"),Ya=a("While the dataset contains a lot of useful information, like "),it=l("code"),Ga=a("lang_id"),Ba=a(" and "),pt=l("code"),Ja=a("english_transcription"),Ka=a(", you\u2019ll focus on the "),ct=l("code"),Qa=a("audio"),Xa=a(" and "),ht=l("code"),Za=a("transcription"),en=a(" in this guide. Remove the other columns with the "),gs=l("a"),sn=a("remove_columns"),tn=a(" method:"),zt=c(),v($s.$$.fragment),Nt=c(),Gs=l("p"),an=a("Take a look at the example again:"),Ht=c(),v(vs.$$.fragment),Vt=c(),Bs=l("p"),nn=a("There are two fields:"),Yt=c(),Ge=l("ul"),Be=l("li"),ut=l("code"),ln=a("audio"),rn=a(": a 1-dimensional "),dt=l("code"),on=a("array"),pn=a(" of the speech signal that must be called to load and resample the audio file."),cn=c(),Js=l("li"),mt=l("code"),hn=a("transcription"),un=a(": the target text."),Gt=c(),Re=l("h2"),Je=l("a"),ft=l("span"),v(js.$$.fragment),dn=c(),_t=l("span"),mn=a("Preprocess"),Bt=c(),Ks=l("p"),fn=a("The next step is to load a Wav2Vec2 processor to process the audio signal:"),Jt=c(),v(bs.$$.fragment),Kt=c(),Ke=l("p"),_n=a("The MInDS-14 dataset has a sampling rate of 8000kHz (you can find this information in its "),ys=l("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=c(),v(ws.$$.fragment),Xt=c(),Qe=l("p"),vn=a("As you can see in the "),gt=l("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=c(),v(ks.$$.fragment),ea=c(),Qs=l("p"),yn=a("Now create a preprocessing function that:"),sa=c(),Xe=l("ol"),Es=l("li"),wn=a("Calls the "),$t=l("code"),kn=a("audio"),En=a(" column to load and resample the audio file."),xn=c(),Le=l("li"),An=a("Extracts the "),vt=l("code"),qn=a("input_values"),Tn=a(" from the audio file and tokenize the "),jt=l("code"),Pn=a("transcription"),Cn=a(" column with the processor."),ta=c(),v(xs.$$.fragment),aa=c(),ce=l("p"),Dn=a("To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),As=l("a"),Sn=a("map"),On=a(" function. You can speed up "),bt=l("code"),In=a("map"),Wn=a(" by increasing the number of processes with the "),yt=l("code"),Rn=a("num_proc"),Ln=a(" parameter. Remove the columns you don\u2019t need with the "),qs=l("a"),Fn=a("remove_columns"),Mn=a(" method:"),na=c(),v(Ts.$$.fragment),la=c(),ve=l("p"),Un=a("\u{1F917} Transformers doesn\u2019t have a data collator for ASR, so you\u2019ll need to adapt the "),Xs=l("a"),zn=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=l("code"),Hn=a("tokenizer"),Vn=a(" function by setting "),kt=l("code"),Yn=a("padding=True"),Gn=a(", dynamic padding is more efficient."),ra=c(),Ce=l("p"),Bn=a("Unlike other data collators, this specific data collator needs to apply a different padding method to "),Et=l("code"),Jn=a("input_values"),Kn=a(" and "),xt=l("code"),Qn=a("labels"),Xn=a(":"),oa=c(),v(Ps.$$.fragment),ia=c(),Ze=l("p"),Zn=a("Now instantiate your "),At=l("code"),el=a("DataCollatorForCTCWithPadding"),sl=a(":"),pa=c(),v(Cs.$$.fragment),ca=c(),Fe=l("h2"),es=l("a"),qt=l("span"),v(Ds.$$.fragment),tl=c(),Tt=l("span"),al=a("Evaluate"),ha=c(),je=l("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=l("a"),ll=a("Evaluate"),rl=a(" library. For this task, load the "),Os=l("a"),ol=a("word error rate"),il=a(" (WER) metric (see the \u{1F917} Evaluate "),Is=l("a"),pl=a("quick tour"),cl=a(" to learn more about how to load and compute a metric):"),ua=c(),v(Ws.$$.fragment),da=c(),ss=l("p"),hl=a("Then create a function that passes your predictions and labels to "),Rs=l("a"),ul=a("compute"),dl=a(" to calculate the WER:"),ma=c(),v(Ls.$$.fragment),fa=c(),ts=l("p"),ml=a("Your "),Pt=l("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=c(),Me=l("h2"),as=l("a"),Ct=l("span"),v(Fs.$$.fragment),gl=c(),Dt=l("span"),$l=a("Train"),ga=c(),v(ns.$$.fragment),$a=c(),v(ls.$$.fragment),va=c(),Ue=l("h2"),rs=l("a"),St=l("span"),v(Ms.$$.fragment),vl=c(),Ot=l("span"),jl=a("Inference"),ja=c(),Zs=l("p"),bl=a("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),ba=c(),et=l("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=c(),v(Us.$$.fragment),wa=c(),De=l("p"),wl=a("The simplest way to try out your finetuned model for inference is to use it in a "),st=l("a"),kl=a("pipeline()"),El=a(". Instantiate a "),It=l("code"),xl=a("pipeline"),Al=a(" for automatic speech recognition with your model, and pass your audio file to it:"),ka=c(),v(zs.$$.fragment),Ea=c(),v(os.$$.fragment),xa=c(),is=l("p"),ql=a("You can also manually replicate the results of the "),Wt=l("code"),Tl=a("pipeline"),Pl=a(" if you\u2019d like:"),Aa=c(),v(ps.$$.fragment),this.h()},l(e){const i=Vr('[data-svelte="svelte-1phssyn"]',document.head);u=r(i,"META",{name:!0,content:!0}),i.forEach(t),_=h(e),d=r(e,"H1",{class:!0});var Ns=o(d);$=r(Ns,"A",{id:!0,class:!0,href:!0});var Rt=o($);A=r(Rt,"SPAN",{});var Lt=o(A);j(E.$$.fragment,Lt),Lt.forEach(t),Rt.forEach(t),I=h(Ns),O=r(Ns,"SPAN",{});var Ft=o(O);T=n(Ft,"Automatic speech recognition"),Ft.forEach(t),Ns.forEach(t),q=h(e),j(W.$$.fragment,e),P=h(e),Y=r(e,"P",{});var Mt=o(Y);R=n(Mt,"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."),Mt.forEach(t),B=h(e),N=r(e,"P",{});var Dl=o(N);U=n(Dl,"This guide will show you how to:"),Dl.forEach(t),S=h(e),z=r(e,"OL",{});var Ta=o(z);L=r(Ta,"LI",{});var tt=o(L);Q=n(tt,"Finetune "),G=r(tt,"A",{href:!0,rel:!0});var Sl=o(G);H=n(Sl,"Wav2Vec2"),Sl.forEach(t),J=n(tt," on the "),g=r(tt,"A",{href:!0,rel:!0});var Ol=o(g);C=n(Ol,"MInDS-14"),Ol.forEach(t),Z=n(tt," dataset to transcribe audio to text."),tt.forEach(t),re=h(Ta),M=r(Ta,"LI",{});var Il=o(M);ee=n(Il,"Use your finetuned model for inference."),Il.forEach(t),Ta.forEach(t),ne=h(e),j(V.$$.fragment,e),x=h(e),he=r(e,"P",{});var Wl=o(he);ue=n(Wl,"Before you begin, make sure you have all the necessary libraries installed:"),Wl.forEach(t),ye=h(e),j(oe.$$.fragment,e),de=h(e),me=r(e,"P",{});var Rl=o(me);qe=n(Rl,"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:"),Rl.forEach(t),we=h(e),j(X.$$.fragment,e),ke=h(e),se=r(e,"H2",{class:!0});var Pa=o(se);fe=r(Pa,"A",{id:!0,class:!0,href:!0});var Ll=o(fe);Oe=r(Ll,"SPAN",{});var Fl=o(Oe);j(_e.$$.fragment,Fl),Fl.forEach(t),Ll.forEach(t),Ee=h(Pa),Te=r(Pa,"SPAN",{});var Ml=o(Te);ge=n(Ml,"Load MInDS-14 dataset"),Ml.forEach(t),Pa.forEach(t),ze=h(e),le=r(e,"P",{});var Ca=o(le);us=n(Ca,"Start by loading a smaller subset of the "),xe=r(Ca,"A",{href:!0,rel:!0});var Ul=o(xe);Ne=n(Ul,"MInDS-14"),Ul.forEach(t),Ae=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),Ie=h(e),j(f.$$.fragment,e),D=h(e),te=r(e,"P",{});var at=o(te);Hs=n(at,"Split the dataset\u2019s "),He=r(at,"CODE",{});var zl=o(He);Pe=n(zl,"train"),zl.forEach(t),ie=n(at," split into a train and test set with the "),Ve=r(at,"CODE",{});var Nl=o(Ve);Vs=n(Nl,"~Dataset.train_test_split"),Nl.forEach(t),Ys=n(at," method:"),at.forEach(t),ds=h(e),j(pe.$$.fragment,e),ms=h(e),We=r(e,"P",{});var Hl=o(We);Ye=n(Hl,"Then take a look at the dataset:"),Hl.forEach(t),fs=h(e),j($e.$$.fragment,e),_s=h(e),ae=r(e,"P",{});var be=o(ae);Ya=n(be,"While the dataset contains a lot of useful information, like "),it=r(be,"CODE",{});var Vl=o(it);Ga=n(Vl,"lang_id"),Vl.forEach(t),Ba=n(be," and "),pt=r(be,"CODE",{});var Yl=o(pt);Ja=n(Yl,"english_transcription"),Yl.forEach(t),Ka=n(be,", you\u2019ll focus on the "),ct=r(be,"CODE",{});var Gl=o(ct);Qa=n(Gl,"audio"),Gl.forEach(t),Xa=n(be," and "),ht=r(be,"CODE",{});var Bl=o(ht);Za=n(Bl,"transcription"),Bl.forEach(t),en=n(be," in this guide. Remove the other columns with the "),gs=r(be,"A",{href:!0,rel:!0});var Jl=o(gs);sn=n(Jl,"remove_columns"),Jl.forEach(t),tn=n(be," method:"),be.forEach(t),zt=h(e),j($s.$$.fragment,e),Nt=h(e),Gs=r(e,"P",{});var Kl=o(Gs);an=n(Kl,"Take a look at the example again:"),Kl.forEach(t),Ht=h(e),j(vs.$$.fragment,e),Vt=h(e),Bs=r(e,"P",{});var Ql=o(Bs);nn=n(Ql,"There are two fields:"),Ql.forEach(t),Yt=h(e),Ge=r(e,"UL",{});var Da=o(Ge);Be=r(Da,"LI",{});var Ut=o(Be);ut=r(Ut,"CODE",{});var Xl=o(ut);ln=n(Xl,"audio"),Xl.forEach(t),rn=n(Ut,": a 1-dimensional "),dt=r(Ut,"CODE",{});var Zl=o(dt);on=n(Zl,"array"),Zl.forEach(t),pn=n(Ut," of the speech signal that must be called to load and resample the audio file."),Ut.forEach(t),cn=h(Da),Js=r(Da,"LI",{});var Cl=o(Js);mt=r(Cl,"CODE",{});var er=o(mt);hn=n(er,"transcription"),er.forEach(t),un=n(Cl,": the target text."),Cl.forEach(t),Da.forEach(t),Gt=h(e),Re=r(e,"H2",{class:!0});var Sa=o(Re);Je=r(Sa,"A",{id:!0,class:!0,href:!0});var sr=o(Je);ft=r(sr,"SPAN",{});var tr=o(ft);j(js.$$.fragment,tr),tr.forEach(t),sr.forEach(t),dn=h(Sa),_t=r(Sa,"SPAN",{});var ar=o(_t);mn=n(ar,"Preprocess"),ar.forEach(t),Sa.forEach(t),Bt=h(e),Ks=r(e,"P",{});var nr=o(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),Ke=r(e,"P",{});var Oa=o(Ke);_n=n(Oa,"The MInDS-14 dataset has a sampling rate of 8000kHz (you can find this information in its "),ys=r(Oa,"A",{href:!0,rel:!0});var lr=o(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),Qe=r(e,"P",{});var Ia=o(Qe);vn=n(Ia,"As you can see in the "),gt=r(Ia,"CODE",{});var rr=o(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=r(e,"P",{});var or=o(Qs);yn=n(or,"Now create a preprocessing function that:"),or.forEach(t),sa=h(e),Xe=r(e,"OL",{});var Wa=o(Xe);Es=r(Wa,"LI",{});var Ra=o(Es);wn=n(Ra,"Calls the "),$t=r(Ra,"CODE",{});var ir=o($t);kn=n(ir,"audio"),ir.forEach(t),En=n(Ra," column to load and resample the audio file."),Ra.forEach(t),xn=h(Wa),Le=r(Wa,"LI",{});var nt=o(Le);An=n(nt,"Extracts the "),vt=r(nt,"CODE",{});var pr=o(vt);qn=n(pr,"input_values"),pr.forEach(t),Tn=n(nt," from the audio file and tokenize the "),jt=r(nt,"CODE",{});var cr=o(jt);Pn=n(cr,"transcription"),cr.forEach(t),Cn=n(nt," column with the processor."),nt.forEach(t),Wa.forEach(t),ta=h(e),j(xs.$$.fragment,e),aa=h(e),ce=r(e,"P",{});var Se=o(ce);Dn=n(Se,"To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),As=r(Se,"A",{href:!0,rel:!0});var hr=o(As);Sn=n(hr,"map"),hr.forEach(t),On=n(Se," function. You can speed up "),bt=r(Se,"CODE",{});var ur=o(bt);In=n(ur,"map"),ur.forEach(t),Wn=n(Se," by increasing the number of processes with the "),yt=r(Se,"CODE",{});var dr=o(yt);Rn=n(dr,"num_proc"),dr.forEach(t),Ln=n(Se," parameter. Remove the columns you don\u2019t need with the "),qs=r(Se,"A",{href:!0,rel:!0});var mr=o(qs);Fn=n(mr,"remove_columns"),mr.forEach(t),Mn=n(Se," method:"),Se.forEach(t),na=h(e),j(Ts.$$.fragment,e),la=h(e),ve=r(e,"P",{});var cs=o(ve);Un=n(cs,"\u{1F917} Transformers doesn\u2019t have a data collator for ASR, so you\u2019ll need to adapt the "),Xs=r(cs,"A",{href:!0});var fr=o(Xs);zn=n(fr,"DataCollatorWithPadding"),fr.forEach(t),Nn=n(cs," 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(cs,"CODE",{});var _r=o(wt);Hn=n(_r,"tokenizer"),_r.forEach(t),Vn=n(cs," function by setting "),kt=r(cs,"CODE",{});var gr=o(kt);Yn=n(gr,"padding=True"),gr.forEach(t),Gn=n(cs,", dynamic padding is more efficient."),cs.forEach(t),ra=h(e),Ce=r(e,"P",{});var lt=o(Ce);Bn=n(lt,"Unlike other data collators, this specific data collator needs to apply a different padding method to "),Et=r(lt,"CODE",{});var $r=o(Et);Jn=n($r,"input_values"),$r.forEach(t),Kn=n(lt," and "),xt=r(lt,"CODE",{});var vr=o(xt);Qn=n(vr,"labels"),vr.forEach(t),Xn=n(lt,":"),lt.forEach(t),oa=h(e),j(Ps.$$.fragment,e),ia=h(e),Ze=r(e,"P",{});var La=o(Ze);Zn=n(La,"Now instantiate your "),At=r(La,"CODE",{});var jr=o(At);el=n(jr,"DataCollatorForCTCWithPadding"),jr.forEach(t),sl=n(La,":"),La.forEach(t),pa=h(e),j(Cs.$$.fragment,e),ca=h(e),Fe=r(e,"H2",{class:!0});var Fa=o(Fe);es=r(Fa,"A",{id:!0,class:!0,href:!0});var br=o(es);qt=r(br,"SPAN",{});var yr=o(qt);j(Ds.$$.fragment,yr),yr.forEach(t),br.forEach(t),tl=h(Fa),Tt=r(Fa,"SPAN",{});var wr=o(Tt);al=n(wr,"Evaluate"),wr.forEach(t),Fa.forEach(t),ha=h(e),je=r(e,"P",{});var hs=o(je);nl=n(hs,"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(hs,"A",{href:!0,rel:!0});var kr=o(Ss);ll=n(kr,"Evaluate"),kr.forEach(t),rl=n(hs," library. For this task, load the "),Os=r(hs,"A",{href:!0,rel:!0});var Er=o(Os);ol=n(Er,"word error rate"),Er.forEach(t),il=n(hs," (WER) metric (see the \u{1F917} Evaluate "),Is=r(hs,"A",{href:!0,rel:!0});var xr=o(Is);pl=n(xr,"quick tour"),xr.forEach(t),cl=n(hs," to learn more about how to load and compute a metric):"),hs.forEach(t),ua=h(e),j(Ws.$$.fragment,e),da=h(e),ss=r(e,"P",{});var Ma=o(ss);hl=n(Ma,"Then create a function that passes your predictions and labels to "),Rs=r(Ma,"A",{href:!0,rel:!0});var Ar=o(Rs);ul=n(Ar,"compute"),Ar.forEach(t),dl=n(Ma," to calculate the WER:"),Ma.forEach(t),ma=h(e),j(Ls.$$.fragment,e),fa=h(e),ts=r(e,"P",{});var Ua=o(ts);ml=n(Ua,"Your "),Pt=r(Ua,"CODE",{});var qr=o(Pt);fl=n(qr,"compute_metrics"),qr.forEach(t),_l=n(Ua," function is ready to go now, and you\u2019ll return to it when you setup your training."),Ua.forEach(t),_a=h(e),Me=r(e,"H2",{class:!0});var za=o(Me);as=r(za,"A",{id:!0,class:!0,href:!0});var Tr=o(as);Ct=r(Tr,"SPAN",{});var Pr=o(Ct);j(Fs.$$.fragment,Pr),Pr.forEach(t),Tr.forEach(t),gl=h(za),Dt=r(za,"SPAN",{});var Cr=o(Dt);$l=n(Cr,"Train"),Cr.forEach(t),za.forEach(t),ga=h(e),j(ns.$$.fragment,e),$a=h(e),j(ls.$$.fragment,e),va=h(e),Ue=r(e,"H2",{class:!0});var Na=o(Ue);rs=r(Na,"A",{id:!0,class:!0,href:!0});var Dr=o(rs);St=r(Dr,"SPAN",{});var Sr=o(St);j(Ms.$$.fragment,Sr),Sr.forEach(t),Dr.forEach(t),vl=h(Na),Ot=r(Na,"SPAN",{});var Or=o(Ot);jl=n(Or,"Inference"),Or.forEach(t),Na.forEach(t),ja=h(e),Zs=r(e,"P",{});var Ir=o(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=r(e,"P",{});var Wr=o(et);yl=n(Wr,"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!"),Wr.forEach(t),ya=h(e),j(Us.$$.fragment,e),wa=h(e),De=r(e,"P",{});var rt=o(De);wl=n(rt,"The simplest way to try out your finetuned model for inference is to use it in a "),st=r(rt,"A",{href:!0});var Rr=o(st);kl=n(Rr,"pipeline()"),Rr.forEach(t),El=n(rt,". Instantiate a "),It=r(rt,"CODE",{});var Lr=o(It);xl=n(Lr,"pipeline"),Lr.forEach(t),Al=n(rt," for automatic speech recognition with your model, and pass your audio file to it:"),rt.forEach(t),ka=h(e),j(zs.$$.fragment,e),Ea=h(e),j(os.$$.fragment,e),xa=h(e),is=r(e,"P",{});var Ha=o(is);ql=n(Ha,"You can also manually replicate the results of the "),Wt=r(Ha,"CODE",{});var Fr=o(Wt);Tl=n(Fr,"pipeline"),Fr.forEach(t),Pl=n(Ha," if you\u2019d like:"),Ha.forEach(t),Aa=h(e),j(ps.$$.fragment,e),this.h()},h(){m(u,"name","hf:doc:metadata"),m(u,"content",JSON.stringify(no)),m($,"id","automatic-speech-recognition"),m($,"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"),m($,"href","#automatic-speech-recognition"),m(d,"class","relative group"),m(G,"href","https://huggingface.co/facebook/wav2vec2-base"),m(G,"rel","nofollow"),m(g,"href","https://huggingface.co/datasets/PolyAI/minds14"),m(g,"rel","nofollow"),m(fe,"id","load-minds14-dataset"),m(fe,"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"),m(fe,"href","#load-minds14-dataset"),m(se,"class","relative group"),m(xe,"href","https://huggingface.co/datasets/PolyAI/minds14"),m(xe,"rel","nofollow"),m(gs,"href","https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.remove_columns"),m(gs,"rel","nofollow"),m(Je,"id","preprocess"),m(Je,"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"),m(Je,"href","#preprocess"),m(Re,"class","relative group"),m(ys,"href","https://huggingface.co/datasets/PolyAI/minds14"),m(ys,"rel","nofollow"),m(As,"href","https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.map"),m(As,"rel","nofollow"),m(qs,"href","https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.remove_columns"),m(qs,"rel","nofollow"),m(Xs,"href","/docs/transformers/main/en/main_classes/data_collator#transformers.DataCollatorWithPadding"),m(es,"id","evaluate"),m(es,"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"),m(es,"href","#evaluate"),m(Fe,"class","relative group"),m(Ss,"href","https://huggingface.co/docs/evaluate/index"),m(Ss,"rel","nofollow"),m(Os,"href","https://huggingface.co/spaces/evaluate-metric/wer"),m(Os,"rel","nofollow"),m(Is,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),m(Is,"rel","nofollow"),m(Rs,"href","https://huggingface.co/docs/evaluate/main/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),m(Rs,"rel","nofollow"),m(as,"id","train"),m(as,"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"),m(as,"href","#train"),m(Me,"class","relative group"),m(rs,"id","inference"),m(rs,"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"),m(rs,"href","#inference"),m(Ue,"class","relative group"),m(st,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline")},m(e,i){s(document.head,u),p(e,_,i),p(e,d,i),s(d,$),s($,A),b(E,A,null),s(d,I),s(d,O),s(O,T),p(e,q,i),b(W,e,i),p(e,P,i),p(e,Y,i),s(Y,R),p(e,B,i),p(e,N,i),s(N,U),p(e,S,i),p(e,z,i),s(z,L),s(L,Q),s(L,G),s(G,H),s(L,J),s(L,g),s(g,C),s(L,Z),s(z,re),s(z,M),s(M,ee),p(e,ne,i),b(V,e,i),p(e,x,i),p(e,he,i),s(he,ue),p(e,ye,i),b(oe,e,i),p(e,de,i),p(e,me,i),s(me,qe),p(e,we,i),b(X,e,i),p(e,ke,i),p(e,se,i),s(se,fe),s(fe,Oe),b(_e,Oe,null),s(se,Ee),s(se,Te),s(Te,ge),p(e,ze,i),p(e,le,i),s(le,us),s(le,xe),s(xe,Ne),s(le,Ae),p(e,Ie,i),b(f,e,i),p(e,D,i),p(e,te,i),s(te,Hs),s(te,He),s(He,Pe),s(te,ie),s(te,Ve),s(Ve,Vs),s(te,Ys),p(e,ds,i),b(pe,e,i),p(e,ms,i),p(e,We,i),s(We,Ye),p(e,fs,i),b($e,e,i),p(e,_s,i),p(e,ae,i),s(ae,Ya),s(ae,it),s(it,Ga),s(ae,Ba),s(ae,pt),s(pt,Ja),s(ae,Ka),s(ae,ct),s(ct,Qa),s(ae,Xa),s(ae,ht),s(ht,Za),s(ae,en),s(ae,gs),s(gs,sn),s(ae,tn),p(e,zt,i),b($s,e,i),p(e,Nt,i),p(e,Gs,i),s(Gs,an),p(e,Ht,i),b(vs,e,i),p(e,Vt,i),p(e,Bs,i),s(Bs,nn),p(e,Yt,i),p(e,Ge,i),s(Ge,Be),s(Be,ut),s(ut,ln),s(Be,rn),s(Be,dt),s(dt,on),s(Be,pn),s(Ge,cn),s(Ge,Js),s(Js,mt),s(mt,hn),s(Js,un),p(e,Gt,i),p(e,Re,i),s(Re,Je),s(Je,ft),b(js,ft,null),s(Re,dn),s(Re,_t),s(_t,mn),p(e,Bt,i),p(e,Ks,i),s(Ks,fn),p(e,Jt,i),b(bs,e,i),p(e,Kt,i),p(e,Ke,i),s(Ke,_n),s(Ke,ys),s(ys,gn),s(Ke,$n),p(e,Qt,i),b(ws,e,i),p(e,Xt,i),p(e,Qe,i),s(Qe,vn),s(Qe,gt),s(gt,jn),s(Qe,bn),p(e,Zt,i),b(ks,e,i),p(e,ea,i),p(e,Qs,i),s(Qs,yn),p(e,sa,i),p(e,Xe,i),s(Xe,Es),s(Es,wn),s(Es,$t),s($t,kn),s(Es,En),s(Xe,xn),s(Xe,Le),s(Le,An),s(Le,vt),s(vt,qn),s(Le,Tn),s(Le,jt),s(jt,Pn),s(Le,Cn),p(e,ta,i),b(xs,e,i),p(e,aa,i),p(e,ce,i),s(ce,Dn),s(ce,As),s(As,Sn),s(ce,On),s(ce,bt),s(bt,In),s(ce,Wn),s(ce,yt),s(yt,Rn),s(ce,Ln),s(ce,qs),s(qs,Fn),s(ce,Mn),p(e,na,i),b(Ts,e,i),p(e,la,i),p(e,ve,i),s(ve,Un),s(ve,Xs),s(Xs,zn),s(ve,Nn),s(ve,wt),s(wt,Hn),s(ve,Vn),s(ve,kt),s(kt,Yn),s(ve,Gn),p(e,ra,i),p(e,Ce,i),s(Ce,Bn),s(Ce,Et),s(Et,Jn),s(Ce,Kn),s(Ce,xt),s(xt,Qn),s(Ce,Xn),p(e,oa,i),b(Ps,e,i),p(e,ia,i),p(e,Ze,i),s(Ze,Zn),s(Ze,At),s(At,el),s(Ze,sl),p(e,pa,i),b(Cs,e,i),p(e,ca,i),p(e,Fe,i),s(Fe,es),s(es,qt),b(Ds,qt,null),s(Fe,tl),s(Fe,Tt),s(Tt,al),p(e,ha,i),p(e,je,i),s(je,nl),s(je,Ss),s(Ss,ll),s(je,rl),s(je,Os),s(Os,ol),s(je,il),s(je,Is),s(Is,pl),s(je,cl),p(e,ua,i),b(Ws,e,i),p(e,da,i),p(e,ss,i),s(ss,hl),s(ss,Rs),s(Rs,ul),s(ss,dl),p(e,ma,i),b(Ls,e,i),p(e,fa,i),p(e,ts,i),s(ts,ml),s(ts,Pt),s(Pt,fl),s(ts,_l),p(e,_a,i),p(e,Me,i),s(Me,as),s(as,Ct),b(Fs,Ct,null),s(Me,gl),s(Me,Dt),s(Dt,$l),p(e,ga,i),b(ns,e,i),p(e,$a,i),b(ls,e,i),p(e,va,i),p(e,Ue,i),s(Ue,rs),s(rs,St),b(Ms,St,null),s(Ue,vl),s(Ue,Ot),s(Ot,jl),p(e,ja,i),p(e,Zs,i),s(Zs,bl),p(e,ba,i),p(e,et,i),s(et,yl),p(e,ya,i),b(Us,e,i),p(e,wa,i),p(e,De,i),s(De,wl),s(De,st),s(st,kl),s(De,El),s(De,It),s(It,xl),s(De,Al),p(e,ka,i),b(zs,e,i),p(e,Ea,i),b(os,e,i),p(e,xa,i),p(e,is,i),s(is,ql),s(is,Wt),s(Wt,Tl),s(is,Pl),p(e,Aa,i),b(ps,e,i),qa=!0},p(e,[i]){const Ns={};i&2&&(Ns.$$scope={dirty:i,ctx:e}),V.$set(Ns);const Rt={};i&2&&(Rt.$$scope={dirty:i,ctx:e}),ns.$set(Rt);const Lt={};i&2&&(Lt.$$scope={dirty:i,ctx:e}),ls.$set(Lt);const Ft={};i&2&&(Ft.$$scope={dirty:i,ctx:e}),os.$set(Ft);const Mt={};i&2&&(Mt.$$scope={dirty:i,ctx:e}),ps.$set(Mt)},i(e){qa||(y(E.$$.fragment,e),y(W.$$.fragment,e),y(V.$$.fragment,e),y(oe.$$.fragment,e),y(X.$$.fragment,e),y(_e.$$.fragment,e),y(f.$$.fragment,e),y(pe.$$.fragment,e),y($e.$$.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(Ws.$$.fragment,e),y(Ls.$$.fragment,e),y(Fs.$$.fragment,e),y(ns.$$.fragment,e),y(ls.$$.fragment,e),y(Ms.$$.fragment,e),y(Us.$$.fragment,e),y(zs.$$.fragment,e),y(os.$$.fragment,e),y(ps.$$.fragment,e),qa=!0)},o(e){w(E.$$.fragment,e),w(W.$$.fragment,e),w(V.$$.fragment,e),w(oe.$$.fragment,e),w(X.$$.fragment,e),w(_e.$$.fragment,e),w(f.$$.fragment,e),w(pe.$$.fragment,e),w($e.$$.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(Ws.$$.fragment,e),w(Ls.$$.fragment,e),w(Fs.$$.fragment,e),w(ns.$$.fragment,e),w(ls.$$.fragment,e),w(Ms.$$.fragment,e),w(Us.$$.fragment,e),w(zs.$$.fragment,e),w(os.$$.fragment,e),w(ps.$$.fragment,e),qa=!1},d(e){t(u),e&&t(_),e&&t(d),k(E),e&&t(q),k(W,e),e&&t(P),e&&t(Y),e&&t(B),e&&t(N),e&&t(S),e&&t(z),e&&t(ne),k(V,e),e&&t(x),e&&t(he),e&&t(ye),k(oe,e),e&&t(de),e&&t(me),e&&t(we),k(X,e),e&&t(ke),e&&t(se),k(_e),e&&t(ze),e&&t(le),e&&t(Ie),k(f,e),e&&t(D),e&&t(te),e&&t(ds),k(pe,e),e&&t(ms),e&&t(We),e&&t(fs),k($e,e),e&&t(_s),e&&t(ae),e&&t(zt),k($s,e),e&&t(Nt),e&&t(Gs),e&&t(Ht),k(vs,e),e&&t(Vt),e&&t(Bs),e&&t(Yt),e&&t(Ge),e&&t(Gt),e&&t(Re),k(js),e&&t(Bt),e&&t(Ks),e&&t(Jt),k(bs,e),e&&t(Kt),e&&t(Ke),e&&t(Qt),k(ws,e),e&&t(Xt),e&&t(Qe),e&&t(Zt),k(ks,e),e&&t(ea),e&&t(Qs),e&&t(sa),e&&t(Xe),e&&t(ta),k(xs,e),e&&t(aa),e&&t(ce),e&&t(na),k(Ts,e),e&&t(la),e&&t(ve),e&&t(ra),e&&t(Ce),e&&t(oa),k(Ps,e),e&&t(ia),e&&t(Ze),e&&t(pa),k(Cs,e),e&&t(ca),e&&t(Fe),k(Ds),e&&t(ha),e&&t(je),e&&t(ua),k(Ws,e),e&&t(da),e&&t(ss),e&&t(ma),k(Ls,e),e&&t(fa),e&&t(ts),e&&t(_a),e&&t(Me),k(Fs),e&&t(ga),k(ns,e),e&&t($a),k(ls,e),e&&t(va),e&&t(Ue),k(Ms),e&&t(ja),e&&t(Zs),e&&t(ba),e&&t(et),e&&t(ya),k(Us,e),e&&t(wa),e&&t(De),e&&t(ka),k(zs,e),e&&t(Ea),k(os,e),e&&t(xa),e&&t(is),e&&t(Aa),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(K){return Yr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class uo extends zr{constructor(u){super();Nr(this,u,lo,ao,Hr,{})}}export{uo as default,no as metadata};
