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 m,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 lt}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,_,d,$,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"),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"),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(_);d=r(x,"A",{href:!0});var ae=o(d);$=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 de=o(U);g=n(de,"Wav2Vec2"),de.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(){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(H,"href","../model_doc/sew-d"),m(C,"href","../model_doc/unispeech"),m(M,"href","../model_doc/unispeech-sat"),m(U,"href","../model_doc/wav2vec2"),m(Y,"href","../model_doc/wav2vec2-conformer"),m(X,"href","../model_doc/wavlm")},m(ee,x){p(ee,u,x),p(ee,_,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,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,_,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/v4.27.1/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 eo(J){let u,_,d,$,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,de,ie,xe,pe,Ne,me,fe,_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(),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),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."),de=c(),ie=l("li"),xe=a("Call "),pe=l("a"),Ne=a("train()"),me=a(" to finetune your model."),fe=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(f){b(u.$$.fragment,f),_=h(f),d=r(f,"P",{});var S=o(d);$=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 ms=o(O);T=n(ms,"ctc_loss_reduction"),ms.forEach(t),q=n(S," parameter. It is often better to use the average instead of the default summation:"),S.forEach(t),W=h(f),b(P.$$.fragment,f),N=h(f),R=r(f,"P",{});var $e=o(R);H=n($e,"At this point, only three steps remain:"),$e.forEach(t),K=h(f),F=r(f,"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 zs=o(B);M=n(zs,"TrainingArguments"),zs.forEach(t),z=n(se,". The only required parameter is "),V=r(se,"CODE",{});var Ns=o(V);U=n(Ns,"output_dir"),Ns.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 Hs=o(G);X=n(Hs,"Trainer"),Hs.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 fs=o(re);he=n(fs,"Trainer"),fs.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),de=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),me=n(We," to finetune your model."),We.forEach(t),Te.forEach(t),fe=h(f),b(_e.$$.fragment,f),ve=h(f),be=r(f,"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(f),b(ne.$$.fragment,f),this.h()},h(){m(A,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModelForCTC"),m(B,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.TrainingArguments"),m(G,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer"),m(re,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer"),m(pe,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer.train"),m(qe,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer.push_to_hub")},m(f,S){j(u,f,S),p(f,_,S),p(f,d,S),s(d,$),s(d,A),s(A,E),s(d,I),s(d,O),s(O,T),s(d,q),p(f,W,S),j(P,f,S),p(f,N,S),p(f,R,S),s(R,H),p(f,K,S),p(f,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,de),s(F,ie),s(ie,xe),s(ie,pe),s(pe,Ne),s(ie,me),p(f,fe,S),j(_e,f,S),p(f,ve,S),p(f,be,S),s(be,Ie),s(be,qe),s(qe,He),s(be,je),p(f,Ve,S),j(ne,f,S),Ye=!0},p(f,S){const ge={};S&2&&(ge.$$scope={dirty:S,ctx:f}),u.$set(ge)},i(f){Ye||(y(u.$$.fragment,f),y(P.$$.fragment,f),y(_e.$$.fragment,f),y(ne.$$.fragment,f),Ye=!0)},o(f){w(u.$$.fragment,f),w(P.$$.fragment,f),w(_e.$$.fragment,f),w(ne.$$.fragment,f),Ye=!1},d(f){k(u,f),f&&t(_),f&&t(d),f&&t(W),k(P,f),f&&t(N),f&&t(R),f&&t(K),f&&t(F),f&&t(fe),k(_e,f),f&&t(ve),f&&t(be),f&&t(Ve),k(ne,f)}}}function so(J){let u,_;return u=new Nr({props:{$$slots:{default:[eo]},$$scope:{ctx:J}}}),{c(){v(u.$$.fragment)},l(d){b(u.$$.fragment,d)},m(d,$){j(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 to(J){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 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(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 no(J){let u,_,d,$,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 "),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),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 "),d=r(D,"CODE",{});var Y=o(d);$=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,d),s(d,$),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(d){b(u.$$.fragment,d)},m(d,$){j(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 ro(J){let u,_,d,$,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,de,ie,xe,pe,Ne,me,fe,_e,ve,be,Ie,qe,He,je,Ve,ne,Ye,f,S,ge,ms,$e,Te,se,zs,Ns,Ge,Hs,Pe,fs,Ce,We,Re,Be,_s,gs,Nt,te,Ba,rt,Ja,Ka,ot,Qa,Xa,it,Za,en,pt,sn,tn,ct,an,nn,Ht,$s,Vt,Vs,ln,Yt,vs,Gt,Ys,rn,Bt,Je,Ke,ht,on,pn,ut,cn,hn,un,Gs,dt,dn,mn,Jt,Le,Qe,mt,bs,fn,ft,_n,Kt,Bs,gn,Qt,js,Xt,Xe,$n,ys,vn,bn,Zt,ws,ea,Ze,jn,_t,yn,wn,sa,ks,ta,Js,kn,aa,es,Es,En,gt,xn,An,qn,Fe,Tn,$t,Pn,Cn,vt,Dn,Sn,na,xs,la,ce,On,bt,In,Wn,jt,Rn,Ln,yt,Fn,Mn,wt,Un,zn,ra,As,oa,ye,Nn,Ks,Hn,Vn,kt,Yn,Gn,Et,Bn,Jn,ia,De,Kn,xt,Qn,Xn,At,Zn,el,pa,qs,ca,ss,sl,qt,tl,al,ha,Ts,ua,Me,ts,Tt,Ps,nl,Pt,ll,da,we,rl,Cs,ol,il,Ds,pl,cl,Ss,hl,ul,ma,Os,fa,as,dl,Is,ml,fl,_a,Ws,ga,ns,_l,Ct,gl,$l,$a,Ue,ls,Dt,Rs,vl,St,bl,va,rs,ba,os,ja,ze,is,Ot,Ls,jl,It,yl,ya,Qs,wl,wa,Xs,kl,ka,Fs,Ea,Se,El,Zs,xl,Al,Wt,ql,Tl,xa,Ms,Aa,ps,qa,cs,Pl,Rt,Cl,Dl,Ta,hs,Pa;return E=new lt({}),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 lt({}),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>
    })
})`}}),$s=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>])'}}),vs=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>}`}}),bs=new lt({}),js=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>)`}}),ws=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>}`}}),ks=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)`}}),xs=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`}}),As=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>)'}}),qs=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`}}),Ts=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>)'}}),Ps=new lt({}),Os=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>)`}}),Ws=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}`}}),Rs=new lt({}),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}}}),Ls=new lt({}),Fs=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>]`}}),Ms=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(),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(),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(),de=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(),me=l("h2"),fe=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"),f=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),ms=c(),$e=l("p"),Te=a("Split the dataset\u2019s "),se=l("code"),zs=a("train"),Ns=a(" split into a train and test set with the "),Ge=l("code"),Hs=a("~Dataset.train_test_split"),Pe=a(" method:"),fs=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 "),rt=l("code"),Ja=a("lang_id"),Ka=a(" and "),ot=l("code"),Qa=a("english_transcription"),Xa=a(", you\u2019ll focus on the "),it=l("code"),Za=a("audio"),en=a(" and "),pt=l("code"),sn=a("transcription"),tn=a(" in this guide. Remove the other columns with the "),ct=l("code"),an=a("remove_columns"),nn=a(" method:"),Ht=c(),v($s.$$.fragment),Vt=c(),Vs=l("p"),ln=a("Take a look at the example again:"),Yt=c(),v(vs.$$.fragment),Gt=c(),Ys=l("p"),rn=a("There are two fields:"),Bt=c(),Je=l("ul"),Ke=l("li"),ht=l("code"),on=a("audio"),pn=a(": a 1-dimensional "),ut=l("code"),cn=a("array"),hn=a(" of the speech signal that must be called to load and resample the audio file."),un=c(),Gs=l("li"),dt=l("code"),dn=a("transcription"),mn=a(": the target text."),Jt=c(),Le=l("h2"),Qe=l("a"),mt=l("span"),v(bs.$$.fragment),fn=c(),ft=l("span"),_n=a("Preprocess"),Kt=c(),Bs=l("p"),gn=a("The next step is to load a Wav2Vec2 processor to process the audio signal:"),Qt=c(),v(js.$$.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 "),ys=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(ws.$$.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(ks.$$.fragment),ta=c(),Js=l("p"),kn=a("Now create a preprocessing function that:"),aa=c(),es=l("ol"),Es=l("li"),En=a("Calls the "),gt=l("code"),xn=a("audio"),An=a(" column to load and resample the audio file."),qn=c(),Fe=l("li"),Tn=a("Extracts the "),$t=l("code"),Pn=a("input_values"),Cn=a(" from the audio file and tokenize the "),vt=l("code"),Dn=a("transcription"),Sn=a(" column with the processor."),na=c(),v(xs.$$.fragment),la=c(),ce=l("p"),On=a("To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),bt=l("code"),In=a("map"),Wn=a(" function. You can speed up "),jt=l("code"),Rn=a("map"),Ln=a(" by increasing the number of processes with the "),yt=l("code"),Fn=a("num_proc"),Mn=a(" parameter. Remove the columns you don\u2019t need with the "),wt=l("code"),Un=a("remove_columns"),zn=a(" method:"),ra=c(),v(As.$$.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 "),Ks=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(qs.$$.fragment),ca=c(),ss=l("p"),sl=a("Now instantiate your "),qt=l("code"),tl=a("DataCollatorForCTCWithPadding"),al=a(":"),ha=c(),v(Ts.$$.fragment),ua=c(),Me=l("h2"),ts=l("a"),Tt=l("span"),v(Ps.$$.fragment),nl=c(),Pt=l("span"),ll=a("Evaluate"),da=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} "),Cs=l("a"),ol=a("Evaluate"),il=a(" library. For this task, load the "),Ds=l("a"),pl=a("word error rate"),cl=a(" (WER) metric (see the \u{1F917} Evaluate "),Ss=l("a"),hl=a("quick tour"),ul=a(" to learn more about how to load and compute a metric):"),ma=c(),v(Os.$$.fragment),fa=c(),as=l("p"),dl=a("Then create a function that passes your predictions and labels to "),Is=l("a"),ml=a("compute"),fl=a(" to calculate the WER:"),_a=c(),v(Ws.$$.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(Rs.$$.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(Ls.$$.fragment),jl=c(),It=l("span"),yl=a("Inference"),ya=c(),Qs=l("p"),wl=a("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),wa=c(),Xs=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(Fs.$$.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 "),Zs=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(Ms.$$.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),d=r(e,"H1",{class:!0});var Us=o(d);$=r(Us,"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(Us),O=r(Us,"SPAN",{});var Mt=o(O);T=n(Mt,"Automatic speech recognition"),Mt.forEach(t),Us.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 et=o(z);V=n(et,"Finetune "),U=r(et,"A",{href:!0,rel:!0});var Il=o(U);g=n(Il,"Wav2Vec2"),Il.forEach(t),D=n(et," on the "),Y=r(et,"A",{href:!0,rel:!0});var Wl=o(Y);le=n(Wl,"MInDS-14"),Wl.forEach(t),G=n(et," dataset to transcribe audio to text."),et.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),de=r(e,"P",{});var Fl=o(de);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),me=r(e,"H2",{class:!0});var Da=o(me);fe=r(Da,"A",{id:!0,class:!0,href:!0});var Ml=o(fe);_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),f=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),ms=h(e),$e=r(e,"P",{});var st=o($e);Te=n(st,"Split the dataset\u2019s "),se=r(st,"CODE",{});var Hl=o(se);zs=n(Hl,"train"),Hl.forEach(t),Ns=n(st," split into a train and test set with the "),Ge=r(st,"CODE",{});var Vl=o(Ge);Hs=n(Vl,"~Dataset.train_test_split"),Vl.forEach(t),Pe=n(st," method:"),st.forEach(t),fs=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 "),rt=r(ke,"CODE",{});var Gl=o(rt);Ja=n(Gl,"lang_id"),Gl.forEach(t),Ka=n(ke," and "),ot=r(ke,"CODE",{});var Bl=o(ot);Qa=n(Bl,"english_transcription"),Bl.forEach(t),Xa=n(ke,", you\u2019ll focus on the "),it=r(ke,"CODE",{});var Jl=o(it);Za=n(Jl,"audio"),Jl.forEach(t),en=n(ke," and "),pt=r(ke,"CODE",{});var Kl=o(pt);sn=n(Kl,"transcription"),Kl.forEach(t),tn=n(ke," in this guide. Remove the other columns with the "),ct=r(ke,"CODE",{});var Ql=o(ct);an=n(Ql,"remove_columns"),Ql.forEach(t),nn=n(ke," method:"),ke.forEach(t),Ht=h(e),b($s.$$.fragment,e),Vt=h(e),Vs=r(e,"P",{});var Xl=o(Vs);ln=n(Xl,"Take a look at the example again:"),Xl.forEach(t),Yt=h(e),b(vs.$$.fragment,e),Gt=h(e),Ys=r(e,"P",{});var Zl=o(Ys);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);ht=r(zt,"CODE",{});var er=o(ht);on=n(er,"audio"),er.forEach(t),pn=n(zt,": a 1-dimensional "),ut=r(zt,"CODE",{});var sr=o(ut);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),Gs=r(Oa,"LI",{});var Sl=o(Gs);dt=r(Sl,"CODE",{});var tr=o(dt);dn=n(tr,"transcription"),tr.forEach(t),mn=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);mt=r(ar,"SPAN",{});var nr=o(mt);b(bs.$$.fragment,nr),nr.forEach(t),ar.forEach(t),fn=h(Ia),ft=r(Ia,"SPAN",{});var lr=o(ft);_n=n(lr,"Preprocess"),lr.forEach(t),Ia.forEach(t),Kt=h(e),Bs=r(e,"P",{});var rr=o(Bs);gn=n(rr,"The next step is to load a Wav2Vec2 processor to process the audio signal:"),rr.forEach(t),Qt=h(e),b(js.$$.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 "),ys=r(Wa,"A",{href:!0,rel:!0});var or=o(ys);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(ws.$$.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(ks.$$.fragment,e),ta=h(e),Js=r(e,"P",{});var pr=o(Js);kn=n(pr,"Now create a preprocessing function that:"),pr.forEach(t),aa=h(e),es=r(e,"OL",{});var La=o(es);Es=r(La,"LI",{});var Fa=o(Es);En=n(Fa,"Calls the "),gt=r(Fa,"CODE",{});var cr=o(gt);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 tt=o(Fe);Tn=n(tt,"Extracts the "),$t=r(tt,"CODE",{});var hr=o($t);Pn=n(hr,"input_values"),hr.forEach(t),Cn=n(tt," from the audio file and tokenize the "),vt=r(tt,"CODE",{});var ur=o(vt);Dn=n(ur,"transcription"),ur.forEach(t),Sn=n(tt," column with the processor."),tt.forEach(t),La.forEach(t),na=h(e),b(xs.$$.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 "),bt=r(Oe,"CODE",{});var dr=o(bt);In=n(dr,"map"),dr.forEach(t),Wn=n(Oe," function. You can speed up "),jt=r(Oe,"CODE",{});var mr=o(jt);Rn=n(mr,"map"),mr.forEach(t),Ln=n(Oe," by increasing the number of processes with the "),yt=r(Oe,"CODE",{});var fr=o(yt);Fn=n(fr,"num_proc"),fr.forEach(t),Mn=n(Oe," parameter. Remove the columns you don\u2019t need with the "),wt=r(Oe,"CODE",{});var _r=o(wt);Un=n(_r,"remove_columns"),_r.forEach(t),zn=n(Oe," method:"),Oe.forEach(t),ra=h(e),b(As.$$.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 "),Ks=r(us,"A",{href:!0});var gr=o(Ks);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 at=o(De);Kn=n(at,"Unlike other data collators, this specific data collator needs to apply a different padding method to "),xt=r(at,"CODE",{});var br=o(xt);Qn=n(br,"input_values"),br.forEach(t),Xn=n(at," and "),At=r(at,"CODE",{});var jr=o(At);Zn=n(jr,"labels"),jr.forEach(t),el=n(at,":"),at.forEach(t),pa=h(e),b(qs.$$.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(Ts.$$.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(Ps.$$.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),da=h(e),we=r(e,"P",{});var ds=o(we);rl=n(ds,"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} "),Cs=r(ds,"A",{href:!0,rel:!0});var xr=o(Cs);ol=n(xr,"Evaluate"),xr.forEach(t),il=n(ds," library. For this task, load the "),Ds=r(ds,"A",{href:!0,rel:!0});var Ar=o(Ds);pl=n(Ar,"word error rate"),Ar.forEach(t),cl=n(ds," (WER) metric (see the \u{1F917} Evaluate "),Ss=r(ds,"A",{href:!0,rel:!0});var qr=o(Ss);hl=n(qr,"quick tour"),qr.forEach(t),ul=n(ds," to learn more about how to load and compute a metric):"),ds.forEach(t),ma=h(e),b(Os.$$.fragment,e),fa=h(e),as=r(e,"P",{});var za=o(as);dl=n(za,"Then create a function that passes your predictions and labels to "),Is=r(za,"A",{href:!0,rel:!0});var Tr=o(Is);ml=n(Tr,"compute"),Tr.forEach(t),fl=n(za," to calculate the WER:"),za.forEach(t),_a=h(e),b(Ws.$$.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(Rs.$$.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(Ls.$$.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),Qs=r(e,"P",{});var Rr=o(Qs);wl=n(Rr,"Great, now that you\u2019ve finetuned a model, you can use it for inference!"),Rr.forEach(t),wa=h(e),Xs=r(e,"P",{});var Lr=o(Xs);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(Fs.$$.fragment,e),Ea=h(e),Se=r(e,"P",{});var nt=o(Se);El=n(nt,"The simplest way to try out your finetuned model for inference is to use it in a "),Zs=r(nt,"A",{href:!0});var Fr=o(Zs);xl=n(Fr,"pipeline()"),Fr.forEach(t),Al=n(nt,". Instantiate a "),Wt=r(nt,"CODE",{});var Mr=o(Wt);ql=n(Mr,"pipeline"),Mr.forEach(t),Tl=n(nt," for automatic speech recognition with your model, and pass your audio file to it:"),nt.forEach(t),xa=h(e),b(Ms.$$.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(){m(u,"name","hf:doc:metadata"),m(u,"content",JSON.stringify(oo)),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(U,"href","https://huggingface.co/facebook/wav2vec2-base"),m(U,"rel","nofollow"),m(Y,"href","https://huggingface.co/datasets/PolyAI/minds14"),m(Y,"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(me,"class","relative group"),m(ne,"href","https://huggingface.co/datasets/PolyAI/minds14"),m(ne,"rel","nofollow"),m(Qe,"id","preprocess"),m(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"),m(Qe,"href","#preprocess"),m(Le,"class","relative group"),m(ys,"href","https://huggingface.co/datasets/PolyAI/minds14"),m(ys,"rel","nofollow"),m(Ks,"href","/docs/transformers/v4.27.1/en/main_classes/data_collator#transformers.DataCollatorWithPadding"),m(ts,"id","evaluate"),m(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"),m(ts,"href","#evaluate"),m(Me,"class","relative group"),m(Cs,"href","https://huggingface.co/docs/evaluate/index"),m(Cs,"rel","nofollow"),m(Ds,"href","https://huggingface.co/spaces/evaluate-metric/wer"),m(Ds,"rel","nofollow"),m(Ss,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),m(Ss,"rel","nofollow"),m(Is,"href","https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),m(Is,"rel","nofollow"),m(ls,"id","train"),m(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"),m(ls,"href","#train"),m(Ue,"class","relative group"),m(is,"id","inference"),m(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"),m(is,"href","#inference"),m(ze,"class","relative group"),m(Zs,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline")},m(e,i){s(document.head,u),p(e,_,i),p(e,d,i),s(d,$),s($,A),j(E,A,null),s(d,I),s(d,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,de,i),s(de,ie),p(e,xe,i),j(pe,e,i),p(e,Ne,i),p(e,me,i),s(me,fe),s(fe,_e),j(ve,_e,null),s(me,be),s(me,Ie),s(Ie,qe),p(e,He,i),p(e,je,i),s(je,Ve),s(je,ne),s(ne,Ye),s(je,f),p(e,S,i),j(ge,e,i),p(e,ms,i),p(e,$e,i),s($e,Te),s($e,se),s(se,zs),s($e,Ns),s($e,Ge),s(Ge,Hs),s($e,Pe),p(e,fs,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,rt),s(rt,Ja),s(te,Ka),s(te,ot),s(ot,Qa),s(te,Xa),s(te,it),s(it,Za),s(te,en),s(te,pt),s(pt,sn),s(te,tn),s(te,ct),s(ct,an),s(te,nn),p(e,Ht,i),j($s,e,i),p(e,Vt,i),p(e,Vs,i),s(Vs,ln),p(e,Yt,i),j(vs,e,i),p(e,Gt,i),p(e,Ys,i),s(Ys,rn),p(e,Bt,i),p(e,Je,i),s(Je,Ke),s(Ke,ht),s(ht,on),s(Ke,pn),s(Ke,ut),s(ut,cn),s(Ke,hn),s(Je,un),s(Je,Gs),s(Gs,dt),s(dt,dn),s(Gs,mn),p(e,Jt,i),p(e,Le,i),s(Le,Qe),s(Qe,mt),j(bs,mt,null),s(Le,fn),s(Le,ft),s(ft,_n),p(e,Kt,i),p(e,Bs,i),s(Bs,gn),p(e,Qt,i),j(js,e,i),p(e,Xt,i),p(e,Xe,i),s(Xe,$n),s(Xe,ys),s(ys,vn),s(Xe,bn),p(e,Zt,i),j(ws,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(ks,e,i),p(e,ta,i),p(e,Js,i),s(Js,kn),p(e,aa,i),p(e,es,i),s(es,Es),s(Es,En),s(Es,gt),s(gt,xn),s(Es,An),s(es,qn),s(es,Fe),s(Fe,Tn),s(Fe,$t),s($t,Pn),s(Fe,Cn),s(Fe,vt),s(vt,Dn),s(Fe,Sn),p(e,na,i),j(xs,e,i),p(e,la,i),p(e,ce,i),s(ce,On),s(ce,bt),s(bt,In),s(ce,Wn),s(ce,jt),s(jt,Rn),s(ce,Ln),s(ce,yt),s(yt,Fn),s(ce,Mn),s(ce,wt),s(wt,Un),s(ce,zn),p(e,ra,i),j(As,e,i),p(e,oa,i),p(e,ye,i),s(ye,Nn),s(ye,Ks),s(Ks,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(qs,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(Ts,e,i),p(e,ua,i),p(e,Me,i),s(Me,ts),s(ts,Tt),j(Ps,Tt,null),s(Me,nl),s(Me,Pt),s(Pt,ll),p(e,da,i),p(e,we,i),s(we,rl),s(we,Cs),s(Cs,ol),s(we,il),s(we,Ds),s(Ds,pl),s(we,cl),s(we,Ss),s(Ss,hl),s(we,ul),p(e,ma,i),j(Os,e,i),p(e,fa,i),p(e,as,i),s(as,dl),s(as,Is),s(Is,ml),s(as,fl),p(e,_a,i),j(Ws,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(Rs,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(Ls,Ot,null),s(ze,jl),s(ze,It),s(It,yl),p(e,ya,i),p(e,Qs,i),s(Qs,wl),p(e,wa,i),p(e,Xs,i),s(Xs,kl),p(e,ka,i),j(Fs,e,i),p(e,Ea,i),p(e,Se,i),s(Se,El),s(Se,Zs),s(Zs,xl),s(Se,Al),s(Se,Wt),s(Wt,ql),s(Se,Tl),p(e,xa,i),j(Ms,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 Us={};i&2&&(Us.$$scope={dirty:i,ctx:e}),ae.$set(Us);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($s.$$.fragment,e),y(vs.$$.fragment,e),y(bs.$$.fragment,e),y(js.$$.fragment,e),y(ws.$$.fragment,e),y(ks.$$.fragment,e),y(xs.$$.fragment,e),y(As.$$.fragment,e),y(qs.$$.fragment,e),y(Ts.$$.fragment,e),y(Ps.$$.fragment,e),y(Os.$$.fragment,e),y(Ws.$$.fragment,e),y(Rs.$$.fragment,e),y(rs.$$.fragment,e),y(os.$$.fragment,e),y(Ls.$$.fragment,e),y(Fs.$$.fragment,e),y(Ms.$$.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($s.$$.fragment,e),w(vs.$$.fragment,e),w(bs.$$.fragment,e),w(js.$$.fragment,e),w(ws.$$.fragment,e),w(ks.$$.fragment,e),w(xs.$$.fragment,e),w(As.$$.fragment,e),w(qs.$$.fragment,e),w(Ts.$$.fragment,e),w(Ps.$$.fragment,e),w(Os.$$.fragment,e),w(Ws.$$.fragment,e),w(Rs.$$.fragment,e),w(rs.$$.fragment,e),w(os.$$.fragment,e),w(Ls.$$.fragment,e),w(Fs.$$.fragment,e),w(Ms.$$.fragment,e),w(ps.$$.fragment,e),w(hs.$$.fragment,e),Pa=!1},d(e){t(u),e&&t(_),e&&t(d),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(de),e&&t(xe),k(pe,e),e&&t(Ne),e&&t(me),k(ve),e&&t(He),e&&t(je),e&&t(S),k(ge,e),e&&t(ms),e&&t($e),e&&t(fs),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($s,e),e&&t(Vt),e&&t(Vs),e&&t(Yt),k(vs,e),e&&t(Gt),e&&t(Ys),e&&t(Bt),e&&t(Je),e&&t(Jt),e&&t(Le),k(bs),e&&t(Kt),e&&t(Bs),e&&t(Qt),k(js,e),e&&t(Xt),e&&t(Xe),e&&t(Zt),k(ws,e),e&&t(ea),e&&t(Ze),e&&t(sa),k(ks,e),e&&t(ta),e&&t(Js),e&&t(aa),e&&t(es),e&&t(na),k(xs,e),e&&t(la),e&&t(ce),e&&t(ra),k(As,e),e&&t(oa),e&&t(ye),e&&t(ia),e&&t(De),e&&t(pa),k(qs,e),e&&t(ca),e&&t(ss),e&&t(ha),k(Ts,e),e&&t(ua),e&&t(Me),k(Ps),e&&t(da),e&&t(we),e&&t(ma),k(Os,e),e&&t(fa),e&&t(as),e&&t(_a),k(Ws,e),e&&t(ga),e&&t(ns),e&&t($a),e&&t(Ue),k(Rs),e&&t(va),k(rs,e),e&&t(ba),k(os,e),e&&t(ja),e&&t(ze),k(Ls),e&&t(ya),e&&t(Qs),e&&t(wa),e&&t(Xs),e&&t(ka),k(Fs,e),e&&t(Ea),e&&t(Se),e&&t(xa),k(Ms,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};
