import{S as Mr,i as Fr,s as Nr,e as r,k as d,w as j,t,M as Vr,c as o,d as s,m as u,a as p,x as v,h as n,b as _,G as a,g as i,y as b,q as E,o as y,B as q,v as Yr,L as Gr}from"../../chunks/vendor-hf-doc-builder.js";import{T as Vt}from"../../chunks/Tip-hf-doc-builder.js";import{Y as Jr}from"../../chunks/Youtube-hf-doc-builder.js";import{I as as}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as S}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as Ur,M as Hr}from"../../chunks/Markdown-hf-doc-builder.js";import"../../chunks/IconTensorflow-hf-doc-builder.js";function Br(L){let c,$,m,g,k;return{c(){c=r("p"),$=t("Revisa la "),m=r("a"),g=t("p\xE1gina de la tarea"),k=t(" de reconocimiento autom\xE1tico del habla para acceder a m\xE1s informaci\xF3n sobre los modelos, datasets y m\xE9tricas asociados."),this.h()},l(w){c=o(w,"P",{});var A=p(c);$=n(A,"Revisa la "),m=o(A,"A",{href:!0,rel:!0});var D=p(m);g=n(D,"p\xE1gina de la tarea"),D.forEach(s),k=n(A," de reconocimiento autom\xE1tico del habla para acceder a m\xE1s informaci\xF3n sobre los modelos, datasets y m\xE9tricas asociados."),A.forEach(s),this.h()},h(){_(m,"href","https://huggingface.co/tasks/automatic-speech-recognition"),_(m,"rel","nofollow")},m(w,A){i(w,c,A),a(c,$),a(c,m),a(m,g),a(c,k)},d(w){w&&s(c)}}}function Kr(L){let c,$,m,g,k,w,A,D;return{c(){c=r("p"),$=t("Si no tienes experiencia haci\xE9ndole fine-tuning a un modelo con el "),m=r("code"),g=t("Trainer"),k=t(", \xA1\xE9chale un vistazo al tutorial b\xE1sico "),w=r("a"),A=t("aqu\xED"),D=t("!"),this.h()},l(T){c=o(T,"P",{});var P=p(c);$=n(P,"Si no tienes experiencia haci\xE9ndole fine-tuning a un modelo con el "),m=o(P,"CODE",{});var z=p(m);g=n(z,"Trainer"),z.forEach(s),k=n(P,", \xA1\xE9chale un vistazo al tutorial b\xE1sico "),w=o(P,"A",{href:!0});var O=p(w);A=n(O,"aqu\xED"),O.forEach(s),D=n(P,"!"),P.forEach(s),this.h()},h(){_(w,"href","../training#train-with-pytorch-trainer")},m(T,P){i(T,c,P),a(c,$),a(c,m),a(m,g),a(c,k),a(c,w),a(w,A),a(c,D)},d(T){T&&s(c)}}}function Qr(L){let c,$,m,g,k,w,A,D,T,P,z,O,U,W,X,H,R,I,h,x,fe,Y,Z,oa,pe,ye,pa,ia,ie,ca,Oe,ee,G,he,qe,Se,ce,_e,ge,da,ze,N,Ie,V,ae,we,se,de,$e,te,Re,J,ua,ue,Le,me,ke;return c=new Vt({props:{$$slots:{default:[Kr]},$$scope:{ctx:L}}}),O=new S({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>)`}}),de=new S({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()`}}),me=new S({props:{code:"trainer.push_to_hub()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){j(c.$$.fragment),$=d(),m=r("p"),g=t("\xA1Ya puedes empezar a entrenar tu modelo! Para ello, carga Wav2Vec2 con "),k=r("code"),w=t("AutoModelForCTC"),A=t(". Especifica la reducci\xF3n que quieres aplicar con el par\xE1metro "),D=r("code"),T=t("ctc_loss_reduction"),P=t(". A menudo, es mejor usar el promedio en lugar de la sumatoria que se hace por defecto."),z=d(),j(O.$$.fragment),U=d(),W=r("p"),X=t("En este punto, solo quedan tres pasos:"),H=d(),R=r("ol"),I=r("li"),h=t("Define tus hiperpar\xE1metros de entrenamiento en "),x=r("code"),fe=t("TrainingArguments"),Y=t(". El \xFAnico par\xE1metro obligatorio es "),Z=r("code"),oa=t("output_dir"),pe=t(" (carpeta de salida), el cual especifica d\xF3nde guardar tu modelo. Puedes subir este modelo al Hub haciendo "),ye=r("code"),pa=t("push_to_hub=True"),ia=t(" (debes haber iniciado sesi\xF3n en Hugging Face para subir tu modelo). Al final de cada \xE9poca, el "),ie=r("code"),ca=t("Trainer"),Oe=t(" evaluar\xE1 la WER y guardar\xE1 el punto de control del entrenamiento."),ee=d(),G=r("li"),he=t("P\xE1sale los argumentos del entrenamiento al "),qe=r("code"),Se=t("Trainer"),ce=t(" junto con el modelo, el dataset, el tokenizer, el collator de datos y la funci\xF3n "),_e=r("code"),ge=t("compute_metrics"),da=t("."),ze=d(),N=r("li"),Ie=t("Llama el m\xE9todo "),V=r("code"),ae=t("train()"),we=t(" para hacerle fine-tuning a tu modelo."),se=d(),j(de.$$.fragment),$e=d(),te=r("p"),Re=t("Una vez que el entrenamiento haya sido completado, comparte tu modelo en el Hub con el m\xE9todo "),J=r("code"),ua=t("push_to_hub()"),ue=t(" para que todo el mundo pueda usar tu modelo:"),Le=d(),j(me.$$.fragment)},l(f){v(c.$$.fragment,f),$=u(f),m=o(f,"P",{});var C=p(m);g=n(C,"\xA1Ya puedes empezar a entrenar tu modelo! Para ello, carga Wav2Vec2 con "),k=o(C,"CODE",{});var M=p(k);w=n(M,"AutoModelForCTC"),M.forEach(s),A=n(C,". Especifica la reducci\xF3n que quieres aplicar con el par\xE1metro "),D=o(C,"CODE",{});var Ua=p(D);T=n(Ua,"ctc_loss_reduction"),Ua.forEach(s),P=n(C,". A menudo, es mejor usar el promedio en lugar de la sumatoria que se hace por defecto."),C.forEach(s),z=u(f),v(O.$$.fragment,f),U=u(f),W=o(f,"P",{});var We=p(W);X=n(We,"En este punto, solo quedan tres pasos:"),We.forEach(s),H=u(f),R=o(f,"OL",{});var je=p(R);I=o(je,"LI",{});var B=p(I);h=n(B,"Define tus hiperpar\xE1metros de entrenamiento en "),x=o(B,"CODE",{});var Ue=p(x);fe=n(Ue,"TrainingArguments"),Ue.forEach(s),Y=n(B,". El \xFAnico par\xE1metro obligatorio es "),Z=o(B,"CODE",{});var Ha=p(Z);oa=n(Ha,"output_dir"),Ha.forEach(s),pe=n(B," (carpeta de salida), el cual especifica d\xF3nde guardar tu modelo. Puedes subir este modelo al Hub haciendo "),ye=o(B,"CODE",{});var Ma=p(ye);pa=n(Ma,"push_to_hub=True"),Ma.forEach(s),ia=n(B," (debes haber iniciado sesi\xF3n en Hugging Face para subir tu modelo). Al final de cada \xE9poca, el "),ie=o(B,"CODE",{});var ma=p(ie);ca=n(ma,"Trainer"),ma.forEach(s),Oe=n(B," evaluar\xE1 la WER y guardar\xE1 el punto de control del entrenamiento."),B.forEach(s),ee=u(je),G=o(je,"LI",{});var K=p(G);he=n(K,"P\xE1sale los argumentos del entrenamiento al "),qe=o(K,"CODE",{});var fa=p(qe);Se=n(fa,"Trainer"),fa.forEach(s),ce=n(K," junto con el modelo, el dataset, el tokenizer, el collator de datos y la funci\xF3n "),_e=o(K,"CODE",{});var xe=p(_e);ge=n(xe,"compute_metrics"),xe.forEach(s),da=n(K,"."),K.forEach(s),ze=u(je),N=o(je,"LI",{});var He=p(N);Ie=n(He,"Llama el m\xE9todo "),V=o(He,"CODE",{});var ha=p(V);ae=n(ha,"train()"),ha.forEach(s),we=n(He," para hacerle fine-tuning a tu modelo."),He.forEach(s),je.forEach(s),se=u(f),v(de.$$.fragment,f),$e=u(f),te=o(f,"P",{});var ne=p(te);Re=n(ne,"Una vez que el entrenamiento haya sido completado, comparte tu modelo en el Hub con el m\xE9todo "),J=o(ne,"CODE",{});var _a=p(J);ua=n(_a,"push_to_hub()"),_a.forEach(s),ue=n(ne," para que todo el mundo pueda usar tu modelo:"),ne.forEach(s),Le=u(f),v(me.$$.fragment,f)},m(f,C){b(c,f,C),i(f,$,C),i(f,m,C),a(m,g),a(m,k),a(k,w),a(m,A),a(m,D),a(D,T),a(m,P),i(f,z,C),b(O,f,C),i(f,U,C),i(f,W,C),a(W,X),i(f,H,C),i(f,R,C),a(R,I),a(I,h),a(I,x),a(x,fe),a(I,Y),a(I,Z),a(Z,oa),a(I,pe),a(I,ye),a(ye,pa),a(I,ia),a(I,ie),a(ie,ca),a(I,Oe),a(R,ee),a(R,G),a(G,he),a(G,qe),a(qe,Se),a(G,ce),a(G,_e),a(_e,ge),a(G,da),a(R,ze),a(R,N),a(N,Ie),a(N,V),a(V,ae),a(N,we),i(f,se,C),b(de,f,C),i(f,$e,C),i(f,te,C),a(te,Re),a(te,J),a(J,ua),a(te,ue),i(f,Le,C),b(me,f,C),ke=!0},p(f,C){const M={};C&2&&(M.$$scope={dirty:C,ctx:f}),c.$set(M)},i(f){ke||(E(c.$$.fragment,f),E(O.$$.fragment,f),E(de.$$.fragment,f),E(me.$$.fragment,f),ke=!0)},o(f){y(c.$$.fragment,f),y(O.$$.fragment,f),y(de.$$.fragment,f),y(me.$$.fragment,f),ke=!1},d(f){q(c,f),f&&s($),f&&s(m),f&&s(z),q(O,f),f&&s(U),f&&s(W),f&&s(H),f&&s(R),f&&s(se),q(de,f),f&&s($e),f&&s(te),f&&s(Le),q(me,f)}}}function Xr(L){let c,$;return c=new Hr({props:{$$slots:{default:[Qr]},$$scope:{ctx:L}}}),{c(){j(c.$$.fragment)},l(m){v(c.$$.fragment,m)},m(m,g){b(c,m,g),$=!0},p(m,g){const k={};g&2&&(k.$$scope={dirty:g,ctx:m}),c.$set(k)},i(m){$||(E(c.$$.fragment,m),$=!0)},o(m){y(c.$$.fragment,m),$=!1},d(m){q(c,m)}}}function Zr(L){let c,$,m,g,k,w,A,D;return{c(){c=r("p"),$=t("Para ver un ejemplo m\xE1s detallado de c\xF3mo hacerle fine-tuning a un modelo para reconocimiento autom\xE1tico del habla, \xE9chale un vistazo a esta "),m=r("a"),g=t("entrada de blog"),k=t(" para ASR en ingl\xE9s y a esta "),w=r("a"),A=t("entrada"),D=t(" para ASR multiling\xFCe."),this.h()},l(T){c=o(T,"P",{});var P=p(c);$=n(P,"Para ver un ejemplo m\xE1s detallado de c\xF3mo hacerle fine-tuning a un modelo para reconocimiento autom\xE1tico del habla, \xE9chale un vistazo a esta "),m=o(P,"A",{href:!0,rel:!0});var z=p(m);g=n(z,"entrada de blog"),z.forEach(s),k=n(P," para ASR en ingl\xE9s y a esta "),w=o(P,"A",{href:!0,rel:!0});var O=p(w);A=n(O,"entrada"),O.forEach(s),D=n(P," para ASR multiling\xFCe."),P.forEach(s),this.h()},h(){_(m,"href","https://huggingface.co/blog/fine-tune-wav2vec2-english"),_(m,"rel","nofollow"),_(w,"href","https://huggingface.co/blog/fine-tune-xlsr-wav2vec2"),_(w,"rel","nofollow")},m(T,P){i(T,c,P),a(c,$),a(c,m),a(m,g),a(c,k),a(c,w),a(w,A),a(c,D)},d(T){T&&s(c)}}}function eo(L){let c,$;return{c(){c=r("p"),$=t("La transcripci\xF3n es decente, pero podr\xEDa ser mejor. \xA1Intenta hacerle fine-tuning a tu modelo con m\xE1s ejemplos para obtener resultados a\xFAn mejores!")},l(m){c=o(m,"P",{});var g=p(c);$=n(g,"La transcripci\xF3n es decente, pero podr\xEDa ser mejor. \xA1Intenta hacerle fine-tuning a tu modelo con m\xE1s ejemplos para obtener resultados a\xFAn mejores!"),g.forEach(s)},m(m,g){i(m,c,g),a(c,$)},d(m){m&&s(c)}}}function ao(L){let c,$,m,g,k,w,A,D,T,P,z,O,U,W,X,H,R,I;return A=new S({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>)`}}),O=new S({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`}}),R=new S({props:{code:`import torch

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

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_ids = torch.argmax(logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcription = processor.batch_decode(predicted_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcription
[<span class="hljs-string">&#x27;I WOUL LIKE O SET UP JOINT ACOUNT WTH Y PARTNER&#x27;</span>]`}}),{c(){c=r("p"),$=t("Carga un procesador para preprocesar el archivo de audio y la transcripci\xF3n y devuelve el "),m=r("code"),g=t("input"),k=t(" como un tensor de PyTorch:"),w=d(),j(A.$$.fragment),D=d(),T=r("p"),P=t("P\xE1sale tus entradas al modelo y devuelve los logits:"),z=d(),j(O.$$.fragment),U=d(),W=r("p"),X=t("Obt\xE9n los identificadores de los tokens con mayor probabilidad en las predicciones y usa el procesador para decodificarlos y transformarlos en texto:"),H=d(),j(R.$$.fragment)},l(h){c=o(h,"P",{});var x=p(c);$=n(x,"Carga un procesador para preprocesar el archivo de audio y la transcripci\xF3n y devuelve el "),m=o(x,"CODE",{});var fe=p(m);g=n(fe,"input"),fe.forEach(s),k=n(x," como un tensor de PyTorch:"),x.forEach(s),w=u(h),v(A.$$.fragment,h),D=u(h),T=o(h,"P",{});var Y=p(T);P=n(Y,"P\xE1sale tus entradas al modelo y devuelve los logits:"),Y.forEach(s),z=u(h),v(O.$$.fragment,h),U=u(h),W=o(h,"P",{});var Z=p(W);X=n(Z,"Obt\xE9n los identificadores de los tokens con mayor probabilidad en las predicciones y usa el procesador para decodificarlos y transformarlos en texto:"),Z.forEach(s),H=u(h),v(R.$$.fragment,h)},m(h,x){i(h,c,x),a(c,$),a(c,m),a(m,g),a(c,k),i(h,w,x),b(A,h,x),i(h,D,x),i(h,T,x),a(T,P),i(h,z,x),b(O,h,x),i(h,U,x),i(h,W,x),a(W,X),i(h,H,x),b(R,h,x),I=!0},p:Gr,i(h){I||(E(A.$$.fragment,h),E(O.$$.fragment,h),E(R.$$.fragment,h),I=!0)},o(h){y(A.$$.fragment,h),y(O.$$.fragment,h),y(R.$$.fragment,h),I=!1},d(h){h&&s(c),h&&s(w),q(A,h),h&&s(D),h&&s(T),h&&s(z),q(O,h),h&&s(U),h&&s(W),h&&s(H),q(R,h)}}}function so(L){let c,$;return c=new Hr({props:{$$slots:{default:[ao]},$$scope:{ctx:L}}}),{c(){j(c.$$.fragment)},l(m){v(c.$$.fragment,m)},m(m,g){b(c,m,g),$=!0},p(m,g){const k={};g&2&&(k.$$scope={dirty:g,ctx:m}),c.$set(k)},i(m){$||(E(c.$$.fragment,m),$=!0)},o(m){y(c.$$.fragment,m),$=!1},d(m){q(c,m)}}}function to(L){let c,$,m,g,k,w,A,D,T,P,z,O,U,W,X,H,R,I,h,x,fe,Y,Z,oa,pe,ye,pa,ia,ie,ca,Oe,ee,G,he,qe,Se,ce,_e,ge,da,ze,N,Ie,V,ae,we,se,de,$e,te,Re,J,ua,ue,Le,me,ke,f,C,M,Ua,We,je,B,Ue,Ha,Ma,ma,K,fa,xe,He,ha,ne,_a,F,Yt,ss,Gt,Jt,ts,Bt,Kt,ns,Qt,Xt,ls,Zt,en,rs,an,sn,Ms,ga,Fs,Fa,tn,Ns,$a,Vs,Na,nn,Ys,Me,Fe,os,ln,rn,ps,on,pn,cn,Va,is,dn,un,Gs,Ae,Ne,cs,ja,mn,ds,fn,Js,Ya,hn,Bs,va,Ks,Ve,_n,ba,gn,$n,Qs,Ea,Xs,Ye,jn,us,vn,bn,Zs,ya,et,Ga,En,at,Ge,qa,yn,ms,qn,wn,kn,Pe,xn,fs,An,Pn,hs,Cn,Dn,st,wa,tt,Q,Tn,_s,On,Sn,gs,zn,In,$s,Rn,Ln,js,Wn,Un,nt,ka,lt,le,Hn,vs,Mn,Fn,bs,Nn,Vn,Es,Yn,Gn,rt,ve,Jn,ys,Bn,Kn,qs,Qn,Xn,ot,xa,pt,Je,Zn,ws,el,al,it,Aa,ct,Ce,Be,ks,Pa,sl,xs,tl,dt,re,nl,Ca,ll,rl,Da,ol,pl,Ta,il,cl,ut,Oa,mt,Ke,dl,As,ul,ml,ft,Sa,ht,Qe,fl,Ps,hl,_l,_t,De,Xe,Cs,za,gl,Ds,$l,gt,Ze,$t,ea,jt,Te,aa,Ts,Ia,jl,Os,vl,vt,Ja,bl,bt,Ba,El,Et,Ra,yt,be,yl,Ss,ql,wl,zs,kl,xl,qt,La,wt,sa,kt,ta,Al,Is,Pl,Cl,xt,na,At;return w=new as({}),z=new Jr({props:{id:"TksaY_FDgnk"}}),ee=new Vt({props:{$$slots:{default:[Br]},$$scope:{ctx:L}}}),ce=new S({props:{code:"pip install transformers datasets evaluate jiwer",highlighted:"pip install transformers datasets evaluate jiwer"}}),N=new S({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()`}}),se=new as({}),f=new S({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>)`}}),K=new S({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>)'}}),ne=new S({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>
    })
})`}}),ga=new S({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>])'}}),$a=new S({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>}`}}),ja=new as({}),va=new S({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>)`}}),Ea=new S({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>}`}}),ya=new S({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)`}}),wa=new S({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`}}),ka=new S({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>)'}}),xa=new S({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]:
        # particiona las entradas y las etiquetas ya que tienen que tener longitudes distintas y
        # requieren m\xE9todos de padding diferentes
        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")

        # remplaza el padding con -100 para ignorar la p\xE9rdida de forma correcta
        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"># particiona las entradas y las etiquetas ya que tienen que tener longitudes distintas y</span>
<span class="hljs-meta">... </span>        <span class="hljs-comment"># requieren m\xE9todos de padding diferentes</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"># remplaza el padding con -100 para ignorar la p\xE9rdida de forma correcta</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`}}),Aa=new S({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>)'}}),Pa=new as({}),Oa=new S({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>)`}}),Sa=new S({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}`}}),za=new as({}),Ze=new Ur({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[Xr]},$$scope:{ctx:L}}}),ea=new Vt({props:{$$slots:{default:[Zr]},$$scope:{ctx:L}}}),Ia=new as({}),Ra=new S({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>]`}}),La=new S({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>}`}}),sa=new Vt({props:{$$slots:{default:[eo]},$$scope:{ctx:L}}}),na=new Ur({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[so]},$$scope:{ctx:L}}}),{c(){c=r("meta"),$=d(),m=r("h1"),g=r("a"),k=r("span"),j(w.$$.fragment),A=d(),D=r("span"),T=t("Reconocimiento autom\xE1tico del habla"),P=d(),j(z.$$.fragment),O=d(),U=r("p"),W=t("El reconocimiento autom\xE1tico del habla (ASR, por sus siglas en ingl\xE9s) convierte una se\xF1al de habla en texto y mapea una secuencia de entradas de audio en salidas en forma de texto. Los asistentes virtuales como Siri y Alexa usan modelos de ASR para ayudar a sus usuarios todos los d\xEDas. De igual forma, hay muchas otras aplicaciones, como la transcripci\xF3n de contenidos en vivo y la toma autom\xE1tica de notas durante reuniones."),X=d(),H=r("p"),R=t("En esta gu\xEDa te mostraremos como:"),I=d(),h=r("ol"),x=r("li"),fe=t("Hacer fine-tuning al modelo "),Y=r("a"),Z=t("Wav2Vec2"),oa=t(" con el dataset "),pe=r("a"),ye=t("MInDS-14"),pa=t(" para transcribir audio a texto."),ia=d(),ie=r("li"),ca=t("Usar tu modelo ajustado para tareas de inferencia."),Oe=d(),j(ee.$$.fragment),G=d(),he=r("p"),qe=t("Antes de comenzar, aseg\xFArate de haber instalado todas las librer\xEDas necesarias:"),Se=d(),j(ce.$$.fragment),_e=d(),ge=r("p"),da=t("Te aconsejamos iniciar sesi\xF3n con tu cuenta de Hugging Face para que puedas subir tu modelo y comartirlo con la comunidad. Cuando te sea solicitado, ingresa tu token para iniciar sesi\xF3n:"),ze=d(),j(N.$$.fragment),Ie=d(),V=r("h2"),ae=r("a"),we=r("span"),j(se.$$.fragment),de=d(),$e=r("span"),te=t("Cargar el dataset MInDS-14"),Re=d(),J=r("p"),ua=t("Comencemos cargando un subconjunto m\xE1s peque\xF1o del dataset "),ue=r("a"),Le=t("MInDS-14"),me=t(" desde la biblioteca \u{1F917} Datasets. De esta forma, tendr\xE1s la oportunidad de experimentar y asegurarte de que todo funcione antes de invertir m\xE1s tiempo entrenando con el dataset entero."),ke=d(),j(f.$$.fragment),C=d(),M=r("p"),Ua=t("Divide la partici\xF3n "),We=r("code"),je=t("train"),B=t(" (entrenamiento) en una partici\xF3n de entrenamiento y una de prueba usando el m\xE9todo "),Ue=r("code"),Ha=t("~Dataset.train_test_split"),Ma=t(":"),ma=d(),j(K.$$.fragment),fa=d(),xe=r("p"),He=t("Ahora \xE9chale un vistazo al dataset:"),ha=d(),j(ne.$$.fragment),_a=d(),F=r("p"),Yt=t("Aunque el dataset contiene mucha informaci\xF3n \xFAtil, como los campos "),ss=r("code"),Gt=t("lang_id"),Jt=t(" (identificador del lenguaje) y "),ts=r("code"),Bt=t("english_transcription"),Kt=t(" (transcripci\xF3n al ingl\xE9s), en esta gu\xEDa nos enfocaremos en los campos "),ns=r("code"),Qt=t("audio"),Xt=t(" y "),ls=r("code"),Zt=t("transcription"),en=t(". Puedes quitar las otras columnas con el m\xE9todo "),rs=r("code"),an=t("remove_columns"),sn=t(":"),Ms=d(),j(ga.$$.fragment),Fs=d(),Fa=r("p"),tn=t("Vuelve a echarle un vistazo al ejemplo:"),Ns=d(),j($a.$$.fragment),Vs=d(),Na=r("p"),nn=t("Hay dos campos:"),Ys=d(),Me=r("ul"),Fe=r("li"),os=r("code"),ln=t("audio"),rn=t(": un "),ps=r("code"),on=t("array"),pn=t(" (arreglo) unidimensional de la se\xF1al de habla que debe ser invocado para cargar y re-muestrear el archivo de audio."),cn=d(),Va=r("li"),is=r("code"),dn=t("transcription"),un=t(": el texto objetivo."),Gs=d(),Ae=r("h2"),Ne=r("a"),cs=r("span"),j(ja.$$.fragment),mn=d(),ds=r("span"),fn=t("Preprocesamiento"),Js=d(),Ya=r("p"),hn=t("El siguiente paso es cargar un procesador Wav2Vec2 para procesar la se\xF1al de audio:"),Bs=d(),j(va.$$.fragment),Ks=d(),Ve=r("p"),_n=t("El dataset MInDS-14 tiene una tasa de muestreo de 8000kHz (puedes encontrar esta informaci\xF3n en su "),ba=r("a"),gn=t("tarjeta de dataset"),$n=t("), lo que significa que tendr\xE1s que re-muestrear el dataset a 16000kHz para poder usar el modelo Wav2Vec2 pre-entrenado:"),Qs=d(),j(Ea.$$.fragment),Xs=d(),Ye=r("p"),jn=t("Como puedes ver en el campo "),us=r("code"),vn=t("transcription"),bn=t(", el texto contiene una mezcla de car\xE1cteres en may\xFAsculas y en min\xFAsculas. El tokenizer Wav2Vec2 fue entrenado \xFAnicamente con car\xE1cteres en may\xFAsculas, as\xED que tendr\xE1s que asegurarte de que el texto se ajuste al vocabulario del tokenizer:"),Zs=d(),j(ya.$$.fragment),et=d(),Ga=r("p"),En=t("Ahora vamos a crear una funci\xF3n de preprocesamiento que:"),at=d(),Ge=r("ol"),qa=r("li"),yn=t("Invoque la columna "),ms=r("code"),qn=t("audio"),wn=t(" para cargar y re-muestrear el archivo de audio."),kn=d(),Pe=r("li"),xn=t("Extraiga el campo "),fs=r("code"),An=t("input_values"),Pn=t(" (valores de entrada) del archivo de audio y haga la tokenizaci\xF3n de la columna "),hs=r("code"),Cn=t("transcription"),Dn=t(" con el procesador."),st=d(),j(wa.$$.fragment),tt=d(),Q=r("p"),Tn=t("Para aplicar la funci\xF3n de preprocesamiento a todo el dataset, puedes usar la funci\xF3n "),_s=r("code"),On=t("map"),Sn=t(" de \u{1F917} Datasets. Para acelerar la funci\xF3n "),gs=r("code"),zn=t("map"),In=t(" puedes incrementar el n\xFAmero de procesos con el par\xE1metro "),$s=r("code"),Rn=t("num_proc"),Ln=t(". Quita las columnas que no necesites con el m\xE9todo "),js=r("code"),Wn=t("remove_columns"),Un=t(":"),nt=d(),j(ka.$$.fragment),lt=d(),le=r("p"),Hn=t("\u{1F917} Transformers no tiene un collator de datos para la tarea de ASR, as\xED que tendr\xE1s que adaptar el "),vs=r("code"),Mn=t("DataCollatorWithPadding"),Fn=t(" para crear un lote de ejemplos. El collator tambi\xE9n le aplicar\xE1 padding din\xE1mico a tu texto y etiquetas para que tengan la longitud del elemento m\xE1s largo en su lote (en vez de la mayor longitud en el dataset entero), de forma que todas las muestras tengan una longitud uniforme. Aunque es posible hacerle padding a tu texto con el "),bs=r("code"),Nn=t("tokenizer"),Vn=t(" haciendo "),Es=r("code"),Yn=t("padding=True"),Gn=t(", el padding din\xE1mico es m\xE1s eficiente."),rt=d(),ve=r("p"),Jn=t("A diferencia de otros collators de datos, este tiene que aplicarle un m\xE9todo de padding distinto a los campos "),ys=r("code"),Bn=t("input_values"),Kn=t(" (valores de entrada) y "),qs=r("code"),Qn=t("labels"),Xn=t(" (etiquetas):"),ot=d(),j(xa.$$.fragment),pt=d(),Je=r("p"),Zn=t("Ahora puedes instanciar tu "),ws=r("code"),el=t("DataCollatorForCTCWithPadding"),al=t(":"),it=d(),j(Aa.$$.fragment),ct=d(),Ce=r("h2"),Be=r("a"),ks=r("span"),j(Pa.$$.fragment),sl=d(),xs=r("span"),tl=t("Evaluaci\xF3n"),dt=d(),re=r("p"),nl=t("A menudo es \xFAtil incluir una m\xE9trica durante el entrenamiento para evaluar el rendimiento de tu modelo. Puedes cargar un m\xE9todo de evaluaci\xF3n r\xE1pidamente con la biblioteca \u{1F917} "),Ca=r("a"),ll=t("Evaluate"),rl=t(". Para esta tarea, puedes usar la m\xE9trica de "),Da=r("a"),ol=t("tasa de error por palabra"),pl=t(" (WER, por sus siglas en ingl\xE9s). Puedes ver la "),Ta=r("a"),il=t("gu\xEDa r\xE1pida"),cl=t(" de \u{1F917} Evaluate para aprender m\xE1s acerca de c\xF3mo cargar y computar una m\xE9trica."),ut=d(),j(Oa.$$.fragment),mt=d(),Ke=r("p"),dl=t("Ahora crea una funci\xF3n que le pase tus predicciones y etiquetas a "),As=r("code"),ul=t("compute"),ml=t(" para calcular la WER:"),ft=d(),j(Sa.$$.fragment),ht=d(),Qe=r("p"),fl=t("Ahora tu funci\xF3n "),Ps=r("code"),hl=t("compute_metrics"),_l=t(" (computar m\xE9tricas) est\xE1 lista y podr\xE1s usarla cuando est\xE9s preparando tu entrenamiento."),_t=d(),De=r("h2"),Xe=r("a"),Cs=r("span"),j(za.$$.fragment),gl=d(),Ds=r("span"),$l=t("Entrenamiento"),gt=d(),j(Ze.$$.fragment),$t=d(),j(ea.$$.fragment),jt=d(),Te=r("h2"),aa=r("a"),Ts=r("span"),j(Ia.$$.fragment),jl=d(),Os=r("span"),vl=t("Inferencia"),vt=d(),Ja=r("p"),bl=t("\xA1Genial, ahora que le has hecho fine-tuning a un modelo, puedes usarlo para inferencia!"),bt=d(),Ba=r("p"),El=t("Carga el archivo de audio sobre el cual quieras correr la inferencia. \xA1Recuerda re-muestrar la tasa de muestreo del archivo de audio para que sea la misma del modelo si es necesario!"),Et=d(),j(Ra.$$.fragment),yt=d(),be=r("p"),yl=t("La manera m\xE1s simple de probar tu modelo para hacer inferencia es usarlo en un "),Ss=r("code"),ql=t("pipeline()"),wl=t(". Puedes instanciar un "),zs=r("code"),kl=t("pipeline"),xl=t(" para reconocimiento autom\xE1tico del habla con tu modelo y pasarle tu archivo de audio:"),qt=d(),j(La.$$.fragment),wt=d(),j(sa.$$.fragment),kt=d(),ta=r("p"),Al=t("Tambi\xE9n puedes replicar de forma manual los resultados del "),Is=r("code"),Pl=t("pipeline"),Cl=t(" si lo deseas:"),xt=d(),j(na.$$.fragment),this.h()},l(e){const l=Vr('[data-svelte="svelte-1phssyn"]',document.head);c=o(l,"META",{name:!0,content:!0}),l.forEach(s),$=u(e),m=o(e,"H1",{class:!0});var Wa=p(m);g=o(Wa,"A",{id:!0,class:!0,href:!0});var Rs=p(g);k=o(Rs,"SPAN",{});var Ls=p(k);v(w.$$.fragment,Ls),Ls.forEach(s),Rs.forEach(s),A=u(Wa),D=o(Wa,"SPAN",{});var Ws=p(D);T=n(Ws,"Reconocimiento autom\xE1tico del habla"),Ws.forEach(s),Wa.forEach(s),P=u(e),v(z.$$.fragment,e),O=u(e),U=o(e,"P",{});var Us=p(U);W=n(Us,"El reconocimiento autom\xE1tico del habla (ASR, por sus siglas en ingl\xE9s) convierte una se\xF1al de habla en texto y mapea una secuencia de entradas de audio en salidas en forma de texto. Los asistentes virtuales como Siri y Alexa usan modelos de ASR para ayudar a sus usuarios todos los d\xEDas. De igual forma, hay muchas otras aplicaciones, como la transcripci\xF3n de contenidos en vivo y la toma autom\xE1tica de notas durante reuniones."),Us.forEach(s),X=u(e),H=o(e,"P",{});var Tl=p(H);R=n(Tl,"En esta gu\xEDa te mostraremos como:"),Tl.forEach(s),I=u(e),h=o(e,"OL",{});var Pt=p(h);x=o(Pt,"LI",{});var Ka=p(x);fe=n(Ka,"Hacer fine-tuning al modelo "),Y=o(Ka,"A",{href:!0,rel:!0});var Ol=p(Y);Z=n(Ol,"Wav2Vec2"),Ol.forEach(s),oa=n(Ka," con el dataset "),pe=o(Ka,"A",{href:!0,rel:!0});var Sl=p(pe);ye=n(Sl,"MInDS-14"),Sl.forEach(s),pa=n(Ka," para transcribir audio a texto."),Ka.forEach(s),ia=u(Pt),ie=o(Pt,"LI",{});var zl=p(ie);ca=n(zl,"Usar tu modelo ajustado para tareas de inferencia."),zl.forEach(s),Pt.forEach(s),Oe=u(e),v(ee.$$.fragment,e),G=u(e),he=o(e,"P",{});var Il=p(he);qe=n(Il,"Antes de comenzar, aseg\xFArate de haber instalado todas las librer\xEDas necesarias:"),Il.forEach(s),Se=u(e),v(ce.$$.fragment,e),_e=u(e),ge=o(e,"P",{});var Rl=p(ge);da=n(Rl,"Te aconsejamos iniciar sesi\xF3n con tu cuenta de Hugging Face para que puedas subir tu modelo y comartirlo con la comunidad. Cuando te sea solicitado, ingresa tu token para iniciar sesi\xF3n:"),Rl.forEach(s),ze=u(e),v(N.$$.fragment,e),Ie=u(e),V=o(e,"H2",{class:!0});var Ct=p(V);ae=o(Ct,"A",{id:!0,class:!0,href:!0});var Ll=p(ae);we=o(Ll,"SPAN",{});var Wl=p(we);v(se.$$.fragment,Wl),Wl.forEach(s),Ll.forEach(s),de=u(Ct),$e=o(Ct,"SPAN",{});var Ul=p($e);te=n(Ul,"Cargar el dataset MInDS-14"),Ul.forEach(s),Ct.forEach(s),Re=u(e),J=o(e,"P",{});var Dt=p(J);ua=n(Dt,"Comencemos cargando un subconjunto m\xE1s peque\xF1o del dataset "),ue=o(Dt,"A",{href:!0,rel:!0});var Hl=p(ue);Le=n(Hl,"MInDS-14"),Hl.forEach(s),me=n(Dt," desde la biblioteca \u{1F917} Datasets. De esta forma, tendr\xE1s la oportunidad de experimentar y asegurarte de que todo funcione antes de invertir m\xE1s tiempo entrenando con el dataset entero."),Dt.forEach(s),ke=u(e),v(f.$$.fragment,e),C=u(e),M=o(e,"P",{});var Qa=p(M);Ua=n(Qa,"Divide la partici\xF3n "),We=o(Qa,"CODE",{});var Ml=p(We);je=n(Ml,"train"),Ml.forEach(s),B=n(Qa," (entrenamiento) en una partici\xF3n de entrenamiento y una de prueba usando el m\xE9todo "),Ue=o(Qa,"CODE",{});var Fl=p(Ue);Ha=n(Fl,"~Dataset.train_test_split"),Fl.forEach(s),Ma=n(Qa,":"),Qa.forEach(s),ma=u(e),v(K.$$.fragment,e),fa=u(e),xe=o(e,"P",{});var Nl=p(xe);He=n(Nl,"Ahora \xE9chale un vistazo al dataset:"),Nl.forEach(s),ha=u(e),v(ne.$$.fragment,e),_a=u(e),F=o(e,"P",{});var oe=p(F);Yt=n(oe,"Aunque el dataset contiene mucha informaci\xF3n \xFAtil, como los campos "),ss=o(oe,"CODE",{});var Vl=p(ss);Gt=n(Vl,"lang_id"),Vl.forEach(s),Jt=n(oe," (identificador del lenguaje) y "),ts=o(oe,"CODE",{});var Yl=p(ts);Bt=n(Yl,"english_transcription"),Yl.forEach(s),Kt=n(oe," (transcripci\xF3n al ingl\xE9s), en esta gu\xEDa nos enfocaremos en los campos "),ns=o(oe,"CODE",{});var Gl=p(ns);Qt=n(Gl,"audio"),Gl.forEach(s),Xt=n(oe," y "),ls=o(oe,"CODE",{});var Jl=p(ls);Zt=n(Jl,"transcription"),Jl.forEach(s),en=n(oe,". Puedes quitar las otras columnas con el m\xE9todo "),rs=o(oe,"CODE",{});var Bl=p(rs);an=n(Bl,"remove_columns"),Bl.forEach(s),sn=n(oe,":"),oe.forEach(s),Ms=u(e),v(ga.$$.fragment,e),Fs=u(e),Fa=o(e,"P",{});var Kl=p(Fa);tn=n(Kl,"Vuelve a echarle un vistazo al ejemplo:"),Kl.forEach(s),Ns=u(e),v($a.$$.fragment,e),Vs=u(e),Na=o(e,"P",{});var Ql=p(Na);nn=n(Ql,"Hay dos campos:"),Ql.forEach(s),Ys=u(e),Me=o(e,"UL",{});var Tt=p(Me);Fe=o(Tt,"LI",{});var Hs=p(Fe);os=o(Hs,"CODE",{});var Xl=p(os);ln=n(Xl,"audio"),Xl.forEach(s),rn=n(Hs,": un "),ps=o(Hs,"CODE",{});var Zl=p(ps);on=n(Zl,"array"),Zl.forEach(s),pn=n(Hs," (arreglo) unidimensional de la se\xF1al de habla que debe ser invocado para cargar y re-muestrear el archivo de audio."),Hs.forEach(s),cn=u(Tt),Va=o(Tt,"LI",{});var Dl=p(Va);is=o(Dl,"CODE",{});var er=p(is);dn=n(er,"transcription"),er.forEach(s),un=n(Dl,": el texto objetivo."),Dl.forEach(s),Tt.forEach(s),Gs=u(e),Ae=o(e,"H2",{class:!0});var Ot=p(Ae);Ne=o(Ot,"A",{id:!0,class:!0,href:!0});var ar=p(Ne);cs=o(ar,"SPAN",{});var sr=p(cs);v(ja.$$.fragment,sr),sr.forEach(s),ar.forEach(s),mn=u(Ot),ds=o(Ot,"SPAN",{});var tr=p(ds);fn=n(tr,"Preprocesamiento"),tr.forEach(s),Ot.forEach(s),Js=u(e),Ya=o(e,"P",{});var nr=p(Ya);hn=n(nr,"El siguiente paso es cargar un procesador Wav2Vec2 para procesar la se\xF1al de audio:"),nr.forEach(s),Bs=u(e),v(va.$$.fragment,e),Ks=u(e),Ve=o(e,"P",{});var St=p(Ve);_n=n(St,"El dataset MInDS-14 tiene una tasa de muestreo de 8000kHz (puedes encontrar esta informaci\xF3n en su "),ba=o(St,"A",{href:!0,rel:!0});var lr=p(ba);gn=n(lr,"tarjeta de dataset"),lr.forEach(s),$n=n(St,"), lo que significa que tendr\xE1s que re-muestrear el dataset a 16000kHz para poder usar el modelo Wav2Vec2 pre-entrenado:"),St.forEach(s),Qs=u(e),v(Ea.$$.fragment,e),Xs=u(e),Ye=o(e,"P",{});var zt=p(Ye);jn=n(zt,"Como puedes ver en el campo "),us=o(zt,"CODE",{});var rr=p(us);vn=n(rr,"transcription"),rr.forEach(s),bn=n(zt,", el texto contiene una mezcla de car\xE1cteres en may\xFAsculas y en min\xFAsculas. El tokenizer Wav2Vec2 fue entrenado \xFAnicamente con car\xE1cteres en may\xFAsculas, as\xED que tendr\xE1s que asegurarte de que el texto se ajuste al vocabulario del tokenizer:"),zt.forEach(s),Zs=u(e),v(ya.$$.fragment,e),et=u(e),Ga=o(e,"P",{});var or=p(Ga);En=n(or,"Ahora vamos a crear una funci\xF3n de preprocesamiento que:"),or.forEach(s),at=u(e),Ge=o(e,"OL",{});var It=p(Ge);qa=o(It,"LI",{});var Rt=p(qa);yn=n(Rt,"Invoque la columna "),ms=o(Rt,"CODE",{});var pr=p(ms);qn=n(pr,"audio"),pr.forEach(s),wn=n(Rt," para cargar y re-muestrear el archivo de audio."),Rt.forEach(s),kn=u(It),Pe=o(It,"LI",{});var Xa=p(Pe);xn=n(Xa,"Extraiga el campo "),fs=o(Xa,"CODE",{});var ir=p(fs);An=n(ir,"input_values"),ir.forEach(s),Pn=n(Xa," (valores de entrada) del archivo de audio y haga la tokenizaci\xF3n de la columna "),hs=o(Xa,"CODE",{});var cr=p(hs);Cn=n(cr,"transcription"),cr.forEach(s),Dn=n(Xa," con el procesador."),Xa.forEach(s),It.forEach(s),st=u(e),v(wa.$$.fragment,e),tt=u(e),Q=o(e,"P",{});var Ee=p(Q);Tn=n(Ee,"Para aplicar la funci\xF3n de preprocesamiento a todo el dataset, puedes usar la funci\xF3n "),_s=o(Ee,"CODE",{});var dr=p(_s);On=n(dr,"map"),dr.forEach(s),Sn=n(Ee," de \u{1F917} Datasets. Para acelerar la funci\xF3n "),gs=o(Ee,"CODE",{});var ur=p(gs);zn=n(ur,"map"),ur.forEach(s),In=n(Ee," puedes incrementar el n\xFAmero de procesos con el par\xE1metro "),$s=o(Ee,"CODE",{});var mr=p($s);Rn=n(mr,"num_proc"),mr.forEach(s),Ln=n(Ee,". Quita las columnas que no necesites con el m\xE9todo "),js=o(Ee,"CODE",{});var fr=p(js);Wn=n(fr,"remove_columns"),fr.forEach(s),Un=n(Ee,":"),Ee.forEach(s),nt=u(e),v(ka.$$.fragment,e),lt=u(e),le=o(e,"P",{});var la=p(le);Hn=n(la,"\u{1F917} Transformers no tiene un collator de datos para la tarea de ASR, as\xED que tendr\xE1s que adaptar el "),vs=o(la,"CODE",{});var hr=p(vs);Mn=n(hr,"DataCollatorWithPadding"),hr.forEach(s),Fn=n(la," para crear un lote de ejemplos. El collator tambi\xE9n le aplicar\xE1 padding din\xE1mico a tu texto y etiquetas para que tengan la longitud del elemento m\xE1s largo en su lote (en vez de la mayor longitud en el dataset entero), de forma que todas las muestras tengan una longitud uniforme. Aunque es posible hacerle padding a tu texto con el "),bs=o(la,"CODE",{});var _r=p(bs);Nn=n(_r,"tokenizer"),_r.forEach(s),Vn=n(la," haciendo "),Es=o(la,"CODE",{});var gr=p(Es);Yn=n(gr,"padding=True"),gr.forEach(s),Gn=n(la,", el padding din\xE1mico es m\xE1s eficiente."),la.forEach(s),rt=u(e),ve=o(e,"P",{});var Za=p(ve);Jn=n(Za,"A diferencia de otros collators de datos, este tiene que aplicarle un m\xE9todo de padding distinto a los campos "),ys=o(Za,"CODE",{});var $r=p(ys);Bn=n($r,"input_values"),$r.forEach(s),Kn=n(Za," (valores de entrada) y "),qs=o(Za,"CODE",{});var jr=p(qs);Qn=n(jr,"labels"),jr.forEach(s),Xn=n(Za," (etiquetas):"),Za.forEach(s),ot=u(e),v(xa.$$.fragment,e),pt=u(e),Je=o(e,"P",{});var Lt=p(Je);Zn=n(Lt,"Ahora puedes instanciar tu "),ws=o(Lt,"CODE",{});var vr=p(ws);el=n(vr,"DataCollatorForCTCWithPadding"),vr.forEach(s),al=n(Lt,":"),Lt.forEach(s),it=u(e),v(Aa.$$.fragment,e),ct=u(e),Ce=o(e,"H2",{class:!0});var Wt=p(Ce);Be=o(Wt,"A",{id:!0,class:!0,href:!0});var br=p(Be);ks=o(br,"SPAN",{});var Er=p(ks);v(Pa.$$.fragment,Er),Er.forEach(s),br.forEach(s),sl=u(Wt),xs=o(Wt,"SPAN",{});var yr=p(xs);tl=n(yr,"Evaluaci\xF3n"),yr.forEach(s),Wt.forEach(s),dt=u(e),re=o(e,"P",{});var ra=p(re);nl=n(ra,"A menudo es \xFAtil incluir una m\xE9trica durante el entrenamiento para evaluar el rendimiento de tu modelo. Puedes cargar un m\xE9todo de evaluaci\xF3n r\xE1pidamente con la biblioteca \u{1F917} "),Ca=o(ra,"A",{href:!0,rel:!0});var qr=p(Ca);ll=n(qr,"Evaluate"),qr.forEach(s),rl=n(ra,". Para esta tarea, puedes usar la m\xE9trica de "),Da=o(ra,"A",{href:!0,rel:!0});var wr=p(Da);ol=n(wr,"tasa de error por palabra"),wr.forEach(s),pl=n(ra," (WER, por sus siglas en ingl\xE9s). Puedes ver la "),Ta=o(ra,"A",{href:!0,rel:!0});var kr=p(Ta);il=n(kr,"gu\xEDa r\xE1pida"),kr.forEach(s),cl=n(ra," de \u{1F917} Evaluate para aprender m\xE1s acerca de c\xF3mo cargar y computar una m\xE9trica."),ra.forEach(s),ut=u(e),v(Oa.$$.fragment,e),mt=u(e),Ke=o(e,"P",{});var Ut=p(Ke);dl=n(Ut,"Ahora crea una funci\xF3n que le pase tus predicciones y etiquetas a "),As=o(Ut,"CODE",{});var xr=p(As);ul=n(xr,"compute"),xr.forEach(s),ml=n(Ut," para calcular la WER:"),Ut.forEach(s),ft=u(e),v(Sa.$$.fragment,e),ht=u(e),Qe=o(e,"P",{});var Ht=p(Qe);fl=n(Ht,"Ahora tu funci\xF3n "),Ps=o(Ht,"CODE",{});var Ar=p(Ps);hl=n(Ar,"compute_metrics"),Ar.forEach(s),_l=n(Ht," (computar m\xE9tricas) est\xE1 lista y podr\xE1s usarla cuando est\xE9s preparando tu entrenamiento."),Ht.forEach(s),_t=u(e),De=o(e,"H2",{class:!0});var Mt=p(De);Xe=o(Mt,"A",{id:!0,class:!0,href:!0});var Pr=p(Xe);Cs=o(Pr,"SPAN",{});var Cr=p(Cs);v(za.$$.fragment,Cr),Cr.forEach(s),Pr.forEach(s),gl=u(Mt),Ds=o(Mt,"SPAN",{});var Dr=p(Ds);$l=n(Dr,"Entrenamiento"),Dr.forEach(s),Mt.forEach(s),gt=u(e),v(Ze.$$.fragment,e),$t=u(e),v(ea.$$.fragment,e),jt=u(e),Te=o(e,"H2",{class:!0});var Ft=p(Te);aa=o(Ft,"A",{id:!0,class:!0,href:!0});var Tr=p(aa);Ts=o(Tr,"SPAN",{});var Or=p(Ts);v(Ia.$$.fragment,Or),Or.forEach(s),Tr.forEach(s),jl=u(Ft),Os=o(Ft,"SPAN",{});var Sr=p(Os);vl=n(Sr,"Inferencia"),Sr.forEach(s),Ft.forEach(s),vt=u(e),Ja=o(e,"P",{});var zr=p(Ja);bl=n(zr,"\xA1Genial, ahora que le has hecho fine-tuning a un modelo, puedes usarlo para inferencia!"),zr.forEach(s),bt=u(e),Ba=o(e,"P",{});var Ir=p(Ba);El=n(Ir,"Carga el archivo de audio sobre el cual quieras correr la inferencia. \xA1Recuerda re-muestrar la tasa de muestreo del archivo de audio para que sea la misma del modelo si es necesario!"),Ir.forEach(s),Et=u(e),v(Ra.$$.fragment,e),yt=u(e),be=o(e,"P",{});var es=p(be);yl=n(es,"La manera m\xE1s simple de probar tu modelo para hacer inferencia es usarlo en un "),Ss=o(es,"CODE",{});var Rr=p(Ss);ql=n(Rr,"pipeline()"),Rr.forEach(s),wl=n(es,". Puedes instanciar un "),zs=o(es,"CODE",{});var Lr=p(zs);kl=n(Lr,"pipeline"),Lr.forEach(s),xl=n(es," para reconocimiento autom\xE1tico del habla con tu modelo y pasarle tu archivo de audio:"),es.forEach(s),qt=u(e),v(La.$$.fragment,e),wt=u(e),v(sa.$$.fragment,e),kt=u(e),ta=o(e,"P",{});var Nt=p(ta);Al=n(Nt,"Tambi\xE9n puedes replicar de forma manual los resultados del "),Is=o(Nt,"CODE",{});var Wr=p(Is);Pl=n(Wr,"pipeline"),Wr.forEach(s),Cl=n(Nt," si lo deseas:"),Nt.forEach(s),xt=u(e),v(na.$$.fragment,e),this.h()},h(){_(c,"name","hf:doc:metadata"),_(c,"content",JSON.stringify(no)),_(g,"id","reconocimiento-automtico-del-habla"),_(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),_(g,"href","#reconocimiento-automtico-del-habla"),_(m,"class","relative group"),_(Y,"href","https://huggingface.co/facebook/wav2vec2-base"),_(Y,"rel","nofollow"),_(pe,"href","https://huggingface.co/datasets/PolyAI/minds14"),_(pe,"rel","nofollow"),_(ae,"id","cargar-el-dataset-minds14"),_(ae,"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"),_(ae,"href","#cargar-el-dataset-minds14"),_(V,"class","relative group"),_(ue,"href","https://huggingface.co/datasets/PolyAI/minds14"),_(ue,"rel","nofollow"),_(Ne,"id","preprocesamiento"),_(Ne,"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"),_(Ne,"href","#preprocesamiento"),_(Ae,"class","relative group"),_(ba,"href","https://huggingface.co/datasets/PolyAI/minds14"),_(ba,"rel","nofollow"),_(Be,"id","evaluacin"),_(Be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),_(Be,"href","#evaluacin"),_(Ce,"class","relative group"),_(Ca,"href","https://huggingface.co/docs/evaluate/index"),_(Ca,"rel","nofollow"),_(Da,"href","https://huggingface.co/spaces/evaluate-metric/wer"),_(Da,"rel","nofollow"),_(Ta,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),_(Ta,"rel","nofollow"),_(Xe,"id","entrenamiento"),_(Xe,"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"),_(Xe,"href","#entrenamiento"),_(De,"class","relative group"),_(aa,"id","inferencia"),_(aa,"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"),_(aa,"href","#inferencia"),_(Te,"class","relative group")},m(e,l){a(document.head,c),i(e,$,l),i(e,m,l),a(m,g),a(g,k),b(w,k,null),a(m,A),a(m,D),a(D,T),i(e,P,l),b(z,e,l),i(e,O,l),i(e,U,l),a(U,W),i(e,X,l),i(e,H,l),a(H,R),i(e,I,l),i(e,h,l),a(h,x),a(x,fe),a(x,Y),a(Y,Z),a(x,oa),a(x,pe),a(pe,ye),a(x,pa),a(h,ia),a(h,ie),a(ie,ca),i(e,Oe,l),b(ee,e,l),i(e,G,l),i(e,he,l),a(he,qe),i(e,Se,l),b(ce,e,l),i(e,_e,l),i(e,ge,l),a(ge,da),i(e,ze,l),b(N,e,l),i(e,Ie,l),i(e,V,l),a(V,ae),a(ae,we),b(se,we,null),a(V,de),a(V,$e),a($e,te),i(e,Re,l),i(e,J,l),a(J,ua),a(J,ue),a(ue,Le),a(J,me),i(e,ke,l),b(f,e,l),i(e,C,l),i(e,M,l),a(M,Ua),a(M,We),a(We,je),a(M,B),a(M,Ue),a(Ue,Ha),a(M,Ma),i(e,ma,l),b(K,e,l),i(e,fa,l),i(e,xe,l),a(xe,He),i(e,ha,l),b(ne,e,l),i(e,_a,l),i(e,F,l),a(F,Yt),a(F,ss),a(ss,Gt),a(F,Jt),a(F,ts),a(ts,Bt),a(F,Kt),a(F,ns),a(ns,Qt),a(F,Xt),a(F,ls),a(ls,Zt),a(F,en),a(F,rs),a(rs,an),a(F,sn),i(e,Ms,l),b(ga,e,l),i(e,Fs,l),i(e,Fa,l),a(Fa,tn),i(e,Ns,l),b($a,e,l),i(e,Vs,l),i(e,Na,l),a(Na,nn),i(e,Ys,l),i(e,Me,l),a(Me,Fe),a(Fe,os),a(os,ln),a(Fe,rn),a(Fe,ps),a(ps,on),a(Fe,pn),a(Me,cn),a(Me,Va),a(Va,is),a(is,dn),a(Va,un),i(e,Gs,l),i(e,Ae,l),a(Ae,Ne),a(Ne,cs),b(ja,cs,null),a(Ae,mn),a(Ae,ds),a(ds,fn),i(e,Js,l),i(e,Ya,l),a(Ya,hn),i(e,Bs,l),b(va,e,l),i(e,Ks,l),i(e,Ve,l),a(Ve,_n),a(Ve,ba),a(ba,gn),a(Ve,$n),i(e,Qs,l),b(Ea,e,l),i(e,Xs,l),i(e,Ye,l),a(Ye,jn),a(Ye,us),a(us,vn),a(Ye,bn),i(e,Zs,l),b(ya,e,l),i(e,et,l),i(e,Ga,l),a(Ga,En),i(e,at,l),i(e,Ge,l),a(Ge,qa),a(qa,yn),a(qa,ms),a(ms,qn),a(qa,wn),a(Ge,kn),a(Ge,Pe),a(Pe,xn),a(Pe,fs),a(fs,An),a(Pe,Pn),a(Pe,hs),a(hs,Cn),a(Pe,Dn),i(e,st,l),b(wa,e,l),i(e,tt,l),i(e,Q,l),a(Q,Tn),a(Q,_s),a(_s,On),a(Q,Sn),a(Q,gs),a(gs,zn),a(Q,In),a(Q,$s),a($s,Rn),a(Q,Ln),a(Q,js),a(js,Wn),a(Q,Un),i(e,nt,l),b(ka,e,l),i(e,lt,l),i(e,le,l),a(le,Hn),a(le,vs),a(vs,Mn),a(le,Fn),a(le,bs),a(bs,Nn),a(le,Vn),a(le,Es),a(Es,Yn),a(le,Gn),i(e,rt,l),i(e,ve,l),a(ve,Jn),a(ve,ys),a(ys,Bn),a(ve,Kn),a(ve,qs),a(qs,Qn),a(ve,Xn),i(e,ot,l),b(xa,e,l),i(e,pt,l),i(e,Je,l),a(Je,Zn),a(Je,ws),a(ws,el),a(Je,al),i(e,it,l),b(Aa,e,l),i(e,ct,l),i(e,Ce,l),a(Ce,Be),a(Be,ks),b(Pa,ks,null),a(Ce,sl),a(Ce,xs),a(xs,tl),i(e,dt,l),i(e,re,l),a(re,nl),a(re,Ca),a(Ca,ll),a(re,rl),a(re,Da),a(Da,ol),a(re,pl),a(re,Ta),a(Ta,il),a(re,cl),i(e,ut,l),b(Oa,e,l),i(e,mt,l),i(e,Ke,l),a(Ke,dl),a(Ke,As),a(As,ul),a(Ke,ml),i(e,ft,l),b(Sa,e,l),i(e,ht,l),i(e,Qe,l),a(Qe,fl),a(Qe,Ps),a(Ps,hl),a(Qe,_l),i(e,_t,l),i(e,De,l),a(De,Xe),a(Xe,Cs),b(za,Cs,null),a(De,gl),a(De,Ds),a(Ds,$l),i(e,gt,l),b(Ze,e,l),i(e,$t,l),b(ea,e,l),i(e,jt,l),i(e,Te,l),a(Te,aa),a(aa,Ts),b(Ia,Ts,null),a(Te,jl),a(Te,Os),a(Os,vl),i(e,vt,l),i(e,Ja,l),a(Ja,bl),i(e,bt,l),i(e,Ba,l),a(Ba,El),i(e,Et,l),b(Ra,e,l),i(e,yt,l),i(e,be,l),a(be,yl),a(be,Ss),a(Ss,ql),a(be,wl),a(be,zs),a(zs,kl),a(be,xl),i(e,qt,l),b(La,e,l),i(e,wt,l),b(sa,e,l),i(e,kt,l),i(e,ta,l),a(ta,Al),a(ta,Is),a(Is,Pl),a(ta,Cl),i(e,xt,l),b(na,e,l),At=!0},p(e,[l]){const Wa={};l&2&&(Wa.$$scope={dirty:l,ctx:e}),ee.$set(Wa);const Rs={};l&2&&(Rs.$$scope={dirty:l,ctx:e}),Ze.$set(Rs);const Ls={};l&2&&(Ls.$$scope={dirty:l,ctx:e}),ea.$set(Ls);const Ws={};l&2&&(Ws.$$scope={dirty:l,ctx:e}),sa.$set(Ws);const Us={};l&2&&(Us.$$scope={dirty:l,ctx:e}),na.$set(Us)},i(e){At||(E(w.$$.fragment,e),E(z.$$.fragment,e),E(ee.$$.fragment,e),E(ce.$$.fragment,e),E(N.$$.fragment,e),E(se.$$.fragment,e),E(f.$$.fragment,e),E(K.$$.fragment,e),E(ne.$$.fragment,e),E(ga.$$.fragment,e),E($a.$$.fragment,e),E(ja.$$.fragment,e),E(va.$$.fragment,e),E(Ea.$$.fragment,e),E(ya.$$.fragment,e),E(wa.$$.fragment,e),E(ka.$$.fragment,e),E(xa.$$.fragment,e),E(Aa.$$.fragment,e),E(Pa.$$.fragment,e),E(Oa.$$.fragment,e),E(Sa.$$.fragment,e),E(za.$$.fragment,e),E(Ze.$$.fragment,e),E(ea.$$.fragment,e),E(Ia.$$.fragment,e),E(Ra.$$.fragment,e),E(La.$$.fragment,e),E(sa.$$.fragment,e),E(na.$$.fragment,e),At=!0)},o(e){y(w.$$.fragment,e),y(z.$$.fragment,e),y(ee.$$.fragment,e),y(ce.$$.fragment,e),y(N.$$.fragment,e),y(se.$$.fragment,e),y(f.$$.fragment,e),y(K.$$.fragment,e),y(ne.$$.fragment,e),y(ga.$$.fragment,e),y($a.$$.fragment,e),y(ja.$$.fragment,e),y(va.$$.fragment,e),y(Ea.$$.fragment,e),y(ya.$$.fragment,e),y(wa.$$.fragment,e),y(ka.$$.fragment,e),y(xa.$$.fragment,e),y(Aa.$$.fragment,e),y(Pa.$$.fragment,e),y(Oa.$$.fragment,e),y(Sa.$$.fragment,e),y(za.$$.fragment,e),y(Ze.$$.fragment,e),y(ea.$$.fragment,e),y(Ia.$$.fragment,e),y(Ra.$$.fragment,e),y(La.$$.fragment,e),y(sa.$$.fragment,e),y(na.$$.fragment,e),At=!1},d(e){s(c),e&&s($),e&&s(m),q(w),e&&s(P),q(z,e),e&&s(O),e&&s(U),e&&s(X),e&&s(H),e&&s(I),e&&s(h),e&&s(Oe),q(ee,e),e&&s(G),e&&s(he),e&&s(Se),q(ce,e),e&&s(_e),e&&s(ge),e&&s(ze),q(N,e),e&&s(Ie),e&&s(V),q(se),e&&s(Re),e&&s(J),e&&s(ke),q(f,e),e&&s(C),e&&s(M),e&&s(ma),q(K,e),e&&s(fa),e&&s(xe),e&&s(ha),q(ne,e),e&&s(_a),e&&s(F),e&&s(Ms),q(ga,e),e&&s(Fs),e&&s(Fa),e&&s(Ns),q($a,e),e&&s(Vs),e&&s(Na),e&&s(Ys),e&&s(Me),e&&s(Gs),e&&s(Ae),q(ja),e&&s(Js),e&&s(Ya),e&&s(Bs),q(va,e),e&&s(Ks),e&&s(Ve),e&&s(Qs),q(Ea,e),e&&s(Xs),e&&s(Ye),e&&s(Zs),q(ya,e),e&&s(et),e&&s(Ga),e&&s(at),e&&s(Ge),e&&s(st),q(wa,e),e&&s(tt),e&&s(Q),e&&s(nt),q(ka,e),e&&s(lt),e&&s(le),e&&s(rt),e&&s(ve),e&&s(ot),q(xa,e),e&&s(pt),e&&s(Je),e&&s(it),q(Aa,e),e&&s(ct),e&&s(Ce),q(Pa),e&&s(dt),e&&s(re),e&&s(ut),q(Oa,e),e&&s(mt),e&&s(Ke),e&&s(ft),q(Sa,e),e&&s(ht),e&&s(Qe),e&&s(_t),e&&s(De),q(za),e&&s(gt),q(Ze,e),e&&s($t),q(ea,e),e&&s(jt),e&&s(Te),q(Ia),e&&s(vt),e&&s(Ja),e&&s(bt),e&&s(Ba),e&&s(Et),q(Ra,e),e&&s(yt),e&&s(be),e&&s(qt),q(La,e),e&&s(wt),q(sa,e),e&&s(kt),e&&s(ta),e&&s(xt),q(na,e)}}}const no={local:"reconocimiento-automtico-del-habla",sections:[{local:"cargar-el-dataset-minds14",title:"Cargar el dataset MInDS-14"},{local:"preprocesamiento",title:"Preprocesamiento"},{local:"evaluacin",title:"Evaluaci\xF3n"},{local:"entrenamiento",title:"Entrenamiento"},{local:"inferencia",title:"Inferencia"}],title:"Reconocimiento autom\xE1tico del habla"};function lo(L){return Yr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fo extends Mr{constructor(c){super();Fr(this,c,lo,to,Nr,{})}}export{fo as default,no as metadata};
