import{S as Hr,i as Vr,s as Yr,e as l,k as c,w as v,t as a,M as Gr,c as r,d as t,m as h,a as o,x as b,h as n,b as d,G as s,g as p,y as j,q as y,o as w,B as k,v as Br,L as Jr}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ga}from"../../chunks/Tip-hf-doc-builder.js";import{Y as Kr}from"../../chunks/Youtube-hf-doc-builder.js";import{I as it}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as L}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Qr}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as zr,M as Nr}from"../../chunks/Markdown-hf-doc-builder.js";function Xr(J){let u,_,f,$,A,E,I,O,T,q,W,P,N,R,H,K,F,C,Q,B,M,z,V,U,g,D,Y,le,G,X,Z;return{c(){u=a(`The task illustrated in this tutorial is supported by the following model architectures:

`),_=l("p"),f=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"),N=a("SEW"),R=a(", "),H=l("a"),K=a("SEW-D"),F=a(", "),C=l("a"),Q=a("UniSpeech"),B=a(", "),M=l("a"),z=a("UniSpeechSat"),V=a(", "),U=l("a"),g=a("Wav2Vec2"),D=a(", "),Y=l("a"),le=a("Wav2Vec2-Conformer"),G=a(", "),X=l("a"),Z=a("WavLM"),this.h()},l(ee){u=n(ee,`The task illustrated in this tutorial is supported by the following model architectures:

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