import{S as lo,i as no,s as oo,e as n,k as c,w as j,t,M as ro,c as o,d as a,m as h,a as r,x as _,h as l,b as f,G as s,g as p,y as w,q as M,o as v,B as $,v as io,L as po}from"../../chunks/vendor-hf-doc-builder.js";import{T as Dl}from"../../chunks/Tip-hf-doc-builder.js";import{Y as co}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Ls}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as Y}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as ho}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as ao,M as to}from"../../chunks/Markdown-hf-doc-builder.js";function mo(ee){let m,g,u,b,k,J,W,A,E,R,X,V,N,I,U,L,q,F,se,C,G,y,Z,B,pe,H,Q,_e,we,S,ue,ce,oe,ae;return{c(){m=t(`The task illustrated in this tutorial is supported by the following model architectures:

`),g=n("p"),u=n("a"),b=t("Audio Spectrogram Transformer"),k=t(", "),J=n("a"),W=t("Data2VecAudio"),A=t(", "),E=n("a"),R=t("Hubert"),X=t(", "),V=n("a"),N=t("SEW"),I=t(", "),U=n("a"),L=t("SEW-D"),q=t(", "),F=n("a"),se=t("UniSpeech"),C=t(", "),G=n("a"),y=t("UniSpeechSat"),Z=t(", "),B=n("a"),pe=t("Wav2Vec2"),H=t(", "),Q=n("a"),_e=t("Wav2Vec2-Conformer"),we=t(", "),S=n("a"),ue=t("WavLM"),ce=t(", "),oe=n("a"),ae=t("Whisper"),this.h()},l(D){m=l(D,`The task illustrated in this tutorial is supported by the following model architectures:

`),g=o(D,"P",{});var T=r(g);u=o(T,"A",{href:!0});var ke=r(u);b=l(ke,"Audio Spectrogram Transformer"),ke.forEach(a),k=l(T,", "),J=o(T,"A",{href:!0});var Me=r(J);W=l(Me,"Data2VecAudio"),Me.forEach(a),A=l(T,", "),E=o(T,"A",{href:!0});var P=r(E);R=l(P,"Hubert"),P.forEach(a),X=l(T,", "),V=o(T,"A",{href:!0});var ve=r(V);N=l(ve,"SEW"),ve.forEach(a),I=l(T,", "),U=o(T,"A",{href:!0});var te=r(U);L=l(te,"SEW-D"),te.forEach(a),q=l(T,", "),F=o(T,"A",{href:!0});var Ee=r(F);se=l(Ee,"UniSpeech"),Ee.forEach(a),C=l(T,", "),G=o(T,"A",{href:!0});var $e=r(G);y=l($e,"UniSpeechSat"),$e.forEach(a),Z=l(T,", "),B=o(T,"A",{href:!0});var re=r(B);pe=l(re,"Wav2Vec2"),re.forEach(a),H=l(T,", "),Q=o(T,"A",{href:!0});var ie=r(Q);_e=l(ie,"Wav2Vec2-Conformer"),ie.forEach(a),we=l(T,", "),S=o(T,"A",{href:!0});var K=r(S);ue=l(K,"WavLM"),K.forEach(a),ce=l(T,", "),oe=o(T,"A",{href:!0});var z=r(oe);ae=l(z,"Whisper"),z.forEach(a),T.forEach(a),this.h()},h(){f(u,"href","../model_doc/audio-spectrogram-transformer"),f(J,"href","../model_doc/data2vec-audio"),f(E,"href","../model_doc/hubert"),f(V,"href","../model_doc/sew"),f(U,"href","../model_doc/sew-d"),f(F,"href","../model_doc/unispeech"),f(G,"href","../model_doc/unispeech-sat"),f(B,"href","../model_doc/wav2vec2"),f(Q,"href","../model_doc/wav2vec2-conformer"),f(S,"href","../model_doc/wavlm"),f(oe,"href","../model_doc/whisper")},m(D,T){p(D,m,T),p(D,g,T),s(g,u),s(u,b),s(g,k),s(g,J),s(J,W),s(g,A),s(g,E),s(E,R),s(g,X),s(g,V),s(V,N),s(g,I),s(g,U),s(U,L),s(g,q),s(g,F),s(F,se),s(g,C),s(g,G),s(G,y),s(g,Z),s(g,B),s(B,pe),s(g,H),s(g,Q),s(Q,_e),s(g,we),s(g,S),s(S,ue),s(g,ce),s(g,oe),s(oe,ae)},d(D){D&&a(m),D&&a(g)}}}function uo(ee){let m,g,u,b,k,J,W,A;return{c(){m=n("p"),g=t("If you aren\u2019t familiar with finetuning a model with the "),u=n("a"),b=t("Trainer"),k=t(", take a look at the basic tutorial "),J=n("a"),W=t("here"),A=t("!"),this.h()},l(E){m=o(E,"P",{});var R=r(m);g=l(R,"If you aren\u2019t familiar with finetuning a model with the "),u=o(R,"A",{href:!0});var X=r(u);b=l(X,"Trainer"),X.forEach(a),k=l(R,", take a look at the basic tutorial "),J=o(R,"A",{href:!0});var V=r(J);W=l(V,"here"),V.forEach(a),A=l(R,"!"),R.forEach(a),this.h()},h(){f(u,"href","/docs/transformers/v4.30.0/en/main_classes/trainer#transformers.Trainer"),f(J,"href","../training#train-with-pytorch-trainer")},m(E,R){p(E,m,R),s(m,g),s(m,u),s(u,b),s(m,k),s(m,J),s(J,W),s(m,A)},d(E){E&&a(m)}}}function fo(ee){let m,g,u,b,k,J,W,A,E,R,X,V,N,I,U,L,q,F,se,C,G,y,Z,B,pe,H,Q,_e,we,S,ue,ce,oe,ae,D,T,ke,Me,P,ve,te,Ee,$e,re,ie,K,z,xe,he,ss,Ae,Ye,de,Je;return m=new Dl({props:{$$slots:{default:[uo]},$$scope:{ctx:ee}}}),E=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckF1ZGlvQ2xhc3NpZmljYXRpb24lMkMlMjBUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFRyYWluZXIlMEElMEFudW1fbGFiZWxzJTIwJTNEJTIwbGVuKGlkMmxhYmVsKSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQXVkaW9DbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZmFjZWJvb2slMkZ3YXYydmVjMi1iYXNlJTIyJTJDJTIwbnVtX2xhYmVscyUzRG51bV9sYWJlbHMlMkMlMjBsYWJlbDJpZCUzRGxhYmVsMmlkJTJDJTIwaWQybGFiZWwlM0RpZDJsYWJlbCUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForAudioClassification, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(id2label)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForAudioClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;facebook/wav2vec2-base&quot;</span>, num_labels=num_labels, label2id=label2id, id2label=id2label
<span class="hljs-meta">... </span>)`}}),ie=new Y({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX21pbmRfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjBldmFsdWF0aW9uX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBzYXZlX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBsZWFybmluZ19yYXRlJTNEM2UtNSUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfdHJhaW5fYmF0Y2hfc2l6ZSUzRDMyJTJDJTBBJTIwJTIwJTIwJTIwZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNENCUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMzIlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMTAlMkMlMEElMjAlMjAlMjAlMjB3YXJtdXBfcmF0aW8lM0QwLjElMkMlMEElMjAlMjAlMjAlMjBsb2dnaW5nX3N0ZXBzJTNEMTAlMkMlMEElMjAlMjAlMjAlMjBsb2FkX2Jlc3RfbW9kZWxfYXRfZW5kJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMG1ldHJpY19mb3JfYmVzdF9tb2RlbCUzRCUyMmFjY3VyYWN5JTIyJTJDJTBBJTIwJTIwJTIwJTIwcHVzaF90b19odWIlM0RUcnVlJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0RlbmNvZGVkX21pbmRzJTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RlbmNvZGVkX21pbmRzJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRGZlYXR1cmVfZXh0cmFjdG9yJTJDJTBBJTIwJTIwJTIwJTIwY29tcHV0ZV9tZXRyaWNzJTNEY29tcHV0ZV9tZXRyaWNzJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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_mind_model&quot;</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">3e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">32</span>,
<span class="hljs-meta">... </span>    gradient_accumulation_steps=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">32</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">10</span>,
<span class="hljs-meta">... </span>    warmup_ratio=<span class="hljs-number">0.1</span>,
<span class="hljs-meta">... </span>    logging_steps=<span class="hljs-number">10</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;accuracy&quot;</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=feature_extractor,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),de=new Y({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){j(m.$$.fragment),g=c(),u=n("p"),b=t("You\u2019re ready to start training your model now! Load Wav2Vec2 with "),k=n("a"),J=t("AutoModelForAudioClassification"),W=t(" along with the number of expected labels, and the label mappings:"),A=c(),j(E.$$.fragment),R=c(),X=n("p"),V=t("At this point, only three steps remain:"),N=c(),I=n("ol"),U=n("li"),L=t("Define your training hyperparameters in "),q=n("a"),F=t("TrainingArguments"),se=t(". The only required parameter is "),C=n("code"),G=t("output_dir"),y=t(" which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),Z=n("code"),B=t("push_to_hub=True"),pe=t(" (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),H=n("a"),Q=t("Trainer"),_e=t(" will evaluate the accuracy and save the training checkpoint."),we=c(),S=n("li"),ue=t("Pass the training arguments to "),ce=n("a"),oe=t("Trainer"),ae=t(" along with the model, dataset, tokenizer, data collator, and "),D=n("code"),T=t("compute_metrics"),ke=t(" function."),Me=c(),P=n("li"),ve=t("Call "),te=n("a"),Ee=t("train()"),$e=t(" to finetune your model."),re=c(),j(ie.$$.fragment),K=c(),z=n("p"),xe=t("Once training is completed, share your model to the Hub with the "),he=n("a"),ss=t("push_to_hub()"),Ae=t(" method so everyone can use your model:"),Ye=c(),j(de.$$.fragment),this.h()},l(d){_(m.$$.fragment,d),g=h(d),u=o(d,"P",{});var x=r(u);b=l(x,"You\u2019re ready to start training your model now! Load Wav2Vec2 with "),k=o(x,"A",{href:!0});var fe=r(k);J=l(fe,"AutoModelForAudioClassification"),fe.forEach(a),W=l(x," along with the number of expected labels, and the label mappings:"),x.forEach(a),A=h(d),_(E.$$.fragment,d),R=h(d),X=o(d,"P",{});var as=r(X);V=l(as,"At this point, only three steps remain:"),as.forEach(a),N=h(d),I=o(d,"OL",{});var O=r(I);U=o(O,"LI",{});var me=r(U);L=l(me,"Define your training hyperparameters in "),q=o(me,"A",{href:!0});var Ce=r(q);F=l(Ce,"TrainingArguments"),Ce.forEach(a),se=l(me,". The only required parameter is "),C=o(me,"CODE",{});var xs=r(C);G=l(xs,"output_dir"),xs.forEach(a),y=l(me," which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),Z=o(me,"CODE",{});var As=r(Z);B=l(As,"push_to_hub=True"),As.forEach(a),pe=l(me," (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),H=o(me,"A",{href:!0});var Ue=r(H);Q=l(Ue,"Trainer"),Ue.forEach(a),_e=l(me," will evaluate the accuracy and save the training checkpoint."),me.forEach(a),we=h(O),S=o(O,"LI",{});var We=r(S);ue=l(We,"Pass the training arguments to "),ce=o(We,"A",{href:!0});var Rs=r(ce);oe=l(Rs,"Trainer"),Rs.forEach(a),ae=l(We," along with the model, dataset, tokenizer, data collator, and "),D=o(We,"CODE",{});var ts=r(D);T=l(ts,"compute_metrics"),ts.forEach(a),ke=l(We," function."),We.forEach(a),Me=h(O),P=o(O,"LI",{});var ye=r(P);ve=l(ye,"Call "),te=o(ye,"A",{href:!0});var ls=r(te);Ee=l(ls,"train()"),ls.forEach(a),$e=l(ye," to finetune your model."),ye.forEach(a),O.forEach(a),re=h(d),_(ie.$$.fragment,d),K=h(d),z=o(d,"P",{});var Te=r(z);xe=l(Te,"Once training is completed, share your model to the Hub with the "),he=o(Te,"A",{href:!0});var Xs=r(he);ss=l(Xs,"push_to_hub()"),Xs.forEach(a),Ae=l(Te," method so everyone can use your model:"),Te.forEach(a),Ye=h(d),_(de.$$.fragment,d),this.h()},h(){f(k,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.AutoModelForAudioClassification"),f(q,"href","/docs/transformers/v4.30.0/en/main_classes/trainer#transformers.TrainingArguments"),f(H,"href","/docs/transformers/v4.30.0/en/main_classes/trainer#transformers.Trainer"),f(ce,"href","/docs/transformers/v4.30.0/en/main_classes/trainer#transformers.Trainer"),f(te,"href","/docs/transformers/v4.30.0/en/main_classes/trainer#transformers.Trainer.train"),f(he,"href","/docs/transformers/v4.30.0/en/main_classes/trainer#transformers.Trainer.push_to_hub")},m(d,x){w(m,d,x),p(d,g,x),p(d,u,x),s(u,b),s(u,k),s(k,J),s(u,W),p(d,A,x),w(E,d,x),p(d,R,x),p(d,X,x),s(X,V),p(d,N,x),p(d,I,x),s(I,U),s(U,L),s(U,q),s(q,F),s(U,se),s(U,C),s(C,G),s(U,y),s(U,Z),s(Z,B),s(U,pe),s(U,H),s(H,Q),s(U,_e),s(I,we),s(I,S),s(S,ue),s(S,ce),s(ce,oe),s(S,ae),s(S,D),s(D,T),s(S,ke),s(I,Me),s(I,P),s(P,ve),s(P,te),s(te,Ee),s(P,$e),p(d,re,x),w(ie,d,x),p(d,K,x),p(d,z,x),s(z,xe),s(z,he),s(he,ss),s(z,Ae),p(d,Ye,x),w(de,d,x),Je=!0},p(d,x){const fe={};x&2&&(fe.$$scope={dirty:x,ctx:d}),m.$set(fe)},i(d){Je||(M(m.$$.fragment,d),M(E.$$.fragment,d),M(ie.$$.fragment,d),M(de.$$.fragment,d),Je=!0)},o(d){v(m.$$.fragment,d),v(E.$$.fragment,d),v(ie.$$.fragment,d),v(de.$$.fragment,d),Je=!1},d(d){$(m,d),d&&a(g),d&&a(u),d&&a(A),$(E,d),d&&a(R),d&&a(X),d&&a(N),d&&a(I),d&&a(re),$(ie,d),d&&a(K),d&&a(z),d&&a(Ye),$(de,d)}}}function yo(ee){let m,g;return m=new to({props:{$$slots:{default:[fo]},$$scope:{ctx:ee}}}),{c(){j(m.$$.fragment)},l(u){_(m.$$.fragment,u)},m(u,b){w(m,u,b),g=!0},p(u,b){const k={};b&2&&(k.$$scope={dirty:b,ctx:u}),m.$set(k)},i(u){g||(M(m.$$.fragment,u),g=!0)},o(u){v(m.$$.fragment,u),g=!1},d(u){$(m,u)}}}function go(ee){let m,g,u,b,k;return{c(){m=n("p"),g=t("For a more in-depth example of how to finetune a model for audio classification, take a look at the corresponding "),u=n("a"),b=t("PyTorch notebook"),k=t("."),this.h()},l(J){m=o(J,"P",{});var W=r(m);g=l(W,"For a more in-depth example of how to finetune a model for audio classification, take a look at the corresponding "),u=o(W,"A",{href:!0,rel:!0});var A=r(u);b=l(A,"PyTorch notebook"),A.forEach(a),k=l(W,"."),W.forEach(a),this.h()},h(){f(u,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/audio_classification.ipynb"),f(u,"rel","nofollow")},m(J,W){p(J,m,W),s(m,g),s(m,u),s(u,b),s(m,k)},d(J){J&&a(m)}}}function bo(ee){let m,g,u,b,k,J,W,A,E,R,X,V,N,I,U,L,q,F,se,C,G;return W=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9GZWF0dXJlRXh0cmFjdG9yJTBBJTBBZmVhdHVyZV9leHRyYWN0b3IlMjAlM0QlMjBBdXRvRmVhdHVyZUV4dHJhY3Rvci5mcm9tX3ByZXRyYWluZWQoJTIyc3RldmhsaXUlMkZteV9hd2Vzb21lX21pbmRzX21vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMGZlYXR1cmVfZXh0cmFjdG9yKGRhdGFzZXQlNUIwJTVEJTVCJTIyYXVkaW8lMjIlNUQlNUIlMjJhcnJheSUyMiU1RCUyQyUyMHNhbXBsaW5nX3JhdGUlM0RzYW1wbGluZ19yYXRlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoFeatureExtractor

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoFeatureExtractor.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_minds_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = feature_extractor(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>)`}}),V=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckF1ZGlvQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckF1ZGlvQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXZobGl1JTJGbXlfYXdlc29tZV9taW5kc19tb2RlbCUyMiklMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForAudioClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForAudioClassification.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_minds_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`}}),C=new Y({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFwcmVkaWN0ZWRfY2xhc3NfaWRzJTIwJTNEJTIwdG9yY2guYXJnbWF4KGxvZ2l0cykuaXRlbSgpJTBBcHJlZGljdGVkX2xhYmVsJTIwJTNEJTIwbW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCcHJlZGljdGVkX2NsYXNzX2lkcyU1RCUwQXByZWRpY3RlZF9sYWJlbA==",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_class_ids = torch.argmax(logits).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = model.config.id2label[predicted_class_ids]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label
<span class="hljs-string">&#x27;cash_deposit&#x27;</span>`}}),{c(){m=n("p"),g=t("Load a feature extractor to preprocess the audio file and return the "),u=n("code"),b=t("input"),k=t(" as PyTorch tensors:"),J=c(),j(W.$$.fragment),A=c(),E=n("p"),R=t("Pass your inputs to the model and return the logits:"),X=c(),j(V.$$.fragment),N=c(),I=n("p"),U=t("Get the class with the highest probability, and use the model\u2019s "),L=n("code"),q=t("id2label"),F=t(" mapping to convert it to a label:"),se=c(),j(C.$$.fragment)},l(y){m=o(y,"P",{});var Z=r(m);g=l(Z,"Load a feature extractor to preprocess the audio file and return the "),u=o(Z,"CODE",{});var B=r(u);b=l(B,"input"),B.forEach(a),k=l(Z," as PyTorch tensors:"),Z.forEach(a),J=h(y),_(W.$$.fragment,y),A=h(y),E=o(y,"P",{});var pe=r(E);R=l(pe,"Pass your inputs to the model and return the logits:"),pe.forEach(a),X=h(y),_(V.$$.fragment,y),N=h(y),I=o(y,"P",{});var H=r(I);U=l(H,"Get the class with the highest probability, and use the model\u2019s "),L=o(H,"CODE",{});var Q=r(L);q=l(Q,"id2label"),Q.forEach(a),F=l(H," mapping to convert it to a label:"),H.forEach(a),se=h(y),_(C.$$.fragment,y)},m(y,Z){p(y,m,Z),s(m,g),s(m,u),s(u,b),s(m,k),p(y,J,Z),w(W,y,Z),p(y,A,Z),p(y,E,Z),s(E,R),p(y,X,Z),w(V,y,Z),p(y,N,Z),p(y,I,Z),s(I,U),s(I,L),s(L,q),s(I,F),p(y,se,Z),w(C,y,Z),G=!0},p:po,i(y){G||(M(W.$$.fragment,y),M(V.$$.fragment,y),M(C.$$.fragment,y),G=!0)},o(y){v(W.$$.fragment,y),v(V.$$.fragment,y),v(C.$$.fragment,y),G=!1},d(y){y&&a(m),y&&a(J),$(W,y),y&&a(A),y&&a(E),y&&a(X),$(V,y),y&&a(N),y&&a(I),y&&a(se),$(C,y)}}}function jo(ee){let m,g;return m=new to({props:{$$slots:{default:[bo]},$$scope:{ctx:ee}}}),{c(){j(m.$$.fragment)},l(u){_(m.$$.fragment,u)},m(u,b){w(m,u,b),g=!0},p(u,b){const k={};b&2&&(k.$$scope={dirty:b,ctx:u}),m.$set(k)},i(u){g||(M(m.$$.fragment,u),g=!0)},o(u){v(m.$$.fragment,u),g=!1},d(u){$(m,u)}}}function _o(ee){let m,g,u,b,k,J,W,A,E,R,X,V,N,I,U,L,q,F,se,C,G,y,Z,B,pe,H,Q,_e,we,S,ue,ce,oe,ae,D,T,ke,Me,P,ve,te,Ee,$e,re,ie,K,z,xe,he,ss,Ae,Ye,de,Je,d,x,fe,as,O,me,Ce,xs,As,Ue,We,Rs,ts,ye,ls,Te,Xs,Ta,ns,ka,le,$t,Ks,Jt,Tt,Os,kt,Et,ea,Ut,Wt,sa,Zt,It,os,xt,At,Ea,rs,Ua,Vs,Rt,Wa,is,Za,Gs,Xt,Ia,Ne,Fe,aa,Vt,Gt,ta,Yt,Ct,Nt,Ys,la,Ft,Bt,xa,Cs,Qt,Aa,ps,Ra,Ns,St,Xa,cs,Va,Re,Be,na,hs,zt,oa,qt,Ga,Fs,Ht,Ya,ms,Ca,Qe,Dt,us,Pt,Lt,Na,fs,Fa,Bs,Kt,Ba,Ze,ds,Ot,ra,el,sl,al,ys,tl,gs,ll,nl,ol,ia,rl,Qa,bs,Sa,ne,il,js,pl,cl,pa,hl,ml,ca,ul,fl,ha,dl,yl,ma,gl,bl,za,_s,qa,Xe,Se,ua,ws,jl,fa,_l,Ha,ge,wl,Ms,Ml,vl,vs,$l,Jl,$s,Tl,kl,Da,Js,Pa,ze,El,Ts,Ul,Wl,La,ks,Ka,qe,Zl,da,Il,xl,Oa,Ve,He,ya,Es,Al,ga,Rl,et,De,st,Pe,at,Ge,Le,ba,Us,Xl,ja,Vl,tt,Qs,Gl,lt,Ss,Yl,nt,Ws,ot,Ie,Cl,zs,Nl,Fl,_a,Bl,Ql,rt,Zs,it,Ke,Sl,wa,zl,ql,pt,Oe,ct;return J=new Ls({}),X=new ho({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/audio_classification.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/audio_classification.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/audio_classification.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/audio_classification.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/audio_classification.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/audio_classification.ipynb"}]}}),N=new co({props:{id:"KWwzcmG98Ds"}}),ae=new Dl({props:{$$slots:{default:[mo]},$$scope:{ctx:ee}}}),P=new Y({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate"}}),re=new Y({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",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()`}}),he=new Ls({}),fe=new Y({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEFtaW5kcyUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJQb2x5QUklMkZtaW5kczE0JTIyJTJDJTIwbmFtZSUzRCUyMmVuLVVTJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiUyMik=",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&quot;</span>)`}}),ye=new Y({props:{code:"bWluZHMlMjAlM0QlMjBtaW5kcy50cmFpbl90ZXN0X3NwbGl0KHRlc3Rfc2l6ZSUzRDAuMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>minds = minds.train_test_split(test_size=<span class="hljs-number">0.2</span>)'}}),ns=new Y({props:{code:"bWluZHM=",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">450</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">113</span>
    })
})`}}),rs=new Y({props:{code:"bWluZHMlMjAlM0QlMjBtaW5kcy5yZW1vdmVfY29sdW1ucyglNUIlMjJwYXRoJTIyJTJDJTIwJTIydHJhbnNjcmlwdGlvbiUyMiUyQyUyMCUyMmVuZ2xpc2hfdHJhbnNjcmlwdGlvbiUyMiUyQyUyMCUyMmxhbmdfaWQlMjIlNUQp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>minds = minds.remove_columns([<span class="hljs-string">&quot;path&quot;</span>, <span class="hljs-string">&quot;transcription&quot;</span>, <span class="hljs-string">&quot;english_transcription&quot;</span>, <span class="hljs-string">&quot;lang_id&quot;</span>])'}}),is=new Y({props:{code:"bWluZHMlNUIlMjJ0cmFpbiUyMiU1RCU1QjAlNUQ=",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.</span>        ,  <span class="hljs-number">0.</span>        ,  <span class="hljs-number">0.</span>        , ..., -<span class="hljs-number">0.00048828</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/602b9a5fbb1e6d0fbce91f52.wav&#x27;</span>,
  <span class="hljs-string">&#x27;sampling_rate&#x27;</span>: <span class="hljs-number">8000</span>},
 <span class="hljs-string">&#x27;intent_class&#x27;</span>: <span class="hljs-number">2</span>}`}}),ps=new Y({props:{code:"bGFiZWxzJTIwJTNEJTIwbWluZHMlNUIlMjJ0cmFpbiUyMiU1RC5mZWF0dXJlcyU1QiUyMmludGVudF9jbGFzcyUyMiU1RC5uYW1lcyUwQWxhYmVsMmlkJTJDJTIwaWQybGFiZWwlMjAlM0QlMjBkaWN0KCklMkMlMjBkaWN0KCklMEFmb3IlMjBpJTJDJTIwbGFiZWwlMjBpbiUyMGVudW1lcmF0ZShsYWJlbHMpJTNBJTBBJTIwJTIwJTIwJTIwbGFiZWwyaWQlNUJsYWJlbCU1RCUyMCUzRCUyMHN0cihpKSUwQSUyMCUyMCUyMCUyMGlkMmxhYmVsJTVCc3RyKGkpJTVEJTIwJTNEJTIwbGFiZWw=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>labels = minds[<span class="hljs-string">&quot;train&quot;</span>].features[<span class="hljs-string">&quot;intent_class&quot;</span>].names
<span class="hljs-meta">&gt;&gt;&gt; </span>label2id, id2label = <span class="hljs-built_in">dict</span>(), <span class="hljs-built_in">dict</span>()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> i, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(labels):
<span class="hljs-meta">... </span>    label2id[label] = <span class="hljs-built_in">str</span>(i)
<span class="hljs-meta">... </span>    id2label[<span class="hljs-built_in">str</span>(i)] = label`}}),cs=new Y({props:{code:"aWQybGFiZWwlNUJzdHIoMiklNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>id2label[<span class="hljs-built_in">str</span>(<span class="hljs-number">2</span>)]
<span class="hljs-string">&#x27;app_error&#x27;</span>`}}),hs=new Ls({}),ms=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9GZWF0dXJlRXh0cmFjdG9yJTBBJTBBZmVhdHVyZV9leHRyYWN0b3IlMjAlM0QlMjBBdXRvRmVhdHVyZUV4dHJhY3Rvci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZ3YXYydmVjMi1iYXNlJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoFeatureExtractor

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoFeatureExtractor.from_pretrained(<span class="hljs-string">&quot;facebook/wav2vec2-base&quot;</span>)`}}),fs=new Y({props:{code:"bWluZHMlMjAlM0QlMjBtaW5kcy5jYXN0X2NvbHVtbiglMjJhdWRpbyUyMiUyQyUyMEF1ZGlvKHNhbXBsaW5nX3JhdGUlM0QxNl8wMDApKSUwQW1pbmRzJTVCJTIydHJhaW4lMjIlNUQlNUIwJTVE",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.2098757e-05</span>,  <span class="hljs-number">4.6582241e-05</span>, -<span class="hljs-number">2.2803260e-05</span>, ...,
         -<span class="hljs-number">2.8419291e-04</span>, -<span class="hljs-number">2.3305941e-04</span>, -<span class="hljs-number">1.1425107e-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/602b9a5fbb1e6d0fbce91f52.wav&#x27;</span>,
  <span class="hljs-string">&#x27;sampling_rate&#x27;</span>: <span class="hljs-number">16000</span>},
 <span class="hljs-string">&#x27;intent_class&#x27;</span>: <span class="hljs-number">2</span>}`}}),bs=new Y({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBhdWRpb19hcnJheXMlMjAlM0QlMjAlNUJ4JTVCJTIyYXJyYXklMjIlNUQlMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlcyU1QiUyMmF1ZGlvJTIyJTVEJTVEJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwZmVhdHVyZV9leHRyYWN0b3IoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXVkaW9fYXJyYXlzJTJDJTIwc2FtcGxpbmdfcmF0ZSUzRGZlYXR1cmVfZXh0cmFjdG9yLnNhbXBsaW5nX3JhdGUlMkMlMjBtYXhfbGVuZ3RoJTNEMTYwMDAlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSUwQSUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBpbnB1dHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    audio_arrays = [x[<span class="hljs-string">&quot;array&quot;</span>] <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;audio&quot;</span>]]
<span class="hljs-meta">... </span>    inputs = feature_extractor(
<span class="hljs-meta">... </span>        audio_arrays, sampling_rate=feature_extractor.sampling_rate, max_length=<span class="hljs-number">16000</span>, truncation=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs`}}),_s=new Y({props:{code:"ZW5jb2RlZF9taW5kcyUyMCUzRCUyMG1pbmRzLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwcmVtb3ZlX2NvbHVtbnMlM0QlMjJhdWRpbyUyMiUyQyUyMGJhdGNoZWQlM0RUcnVlKSUwQWVuY29kZWRfbWluZHMlMjAlM0QlMjBlbmNvZGVkX21pbmRzLnJlbmFtZV9jb2x1bW4oJTIyaW50ZW50X2NsYXNzJTIyJTJDJTIwJTIybGFiZWwlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_minds = minds.<span class="hljs-built_in">map</span>(preprocess_function, remove_columns=<span class="hljs-string">&quot;audio&quot;</span>, batched=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_minds = encoded_minds.rename_column(<span class="hljs-string">&quot;intent_class&quot;</span>, <span class="hljs-string">&quot;label&quot;</span>)`}}),ws=new Ls({}),Js=new Y({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFhY2N1cmFjeSUyMCUzRCUyMGV2YWx1YXRlLmxvYWQoJTIyYWNjdXJhY3klMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>accuracy = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)`}}),ks=new Y({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyMCUzRCUyMG5wLmFyZ21heChldmFsX3ByZWQucHJlZGljdGlvbnMlMkMlMjBheGlzJTNEMSklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBhY2N1cmFjeS5jb21wdXRlKHByZWRpY3Rpb25zJTNEcHJlZGljdGlvbnMlMkMlMjByZWZlcmVuY2VzJTNEZXZhbF9wcmVkLmxhYmVsX2lkcyk=",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">eval_pred</span>):
<span class="hljs-meta">... </span>    predictions = np.argmax(eval_pred.predictions, axis=<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> accuracy.compute(predictions=predictions, references=eval_pred.label_ids)`}}),Es=new Ls({}),De=new ao({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[yo]},$$scope:{ctx:ee}}}),Pe=new Dl({props:{$$slots:{default:[go]},$$scope:{ctx:ee}}}),Us=new Ls({}),Ws=new Y({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMlBvbHlBSSUyRm1pbmRzMTQlMjIlMkMlMjBuYW1lJTNEJTIyZW4tVVMlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKSUwQWRhdGFzZXQlMjAlM0QlMjBkYXRhc2V0LmNhc3RfY29sdW1uKCUyMmF1ZGlvJTIyJTJDJTIwQXVkaW8oc2FtcGxpbmdfcmF0ZSUzRDE2MDAwKSklMEFzYW1wbGluZ19yYXRlJTIwJTNEJTIwZGF0YXNldC5mZWF0dXJlcyU1QiUyMmF1ZGlvJTIyJTVELnNhbXBsaW5nX3JhdGUlMEFhdWRpb19maWxlJTIwJTNEJTIwZGF0YXNldCU1QjAlNUQlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMnBhdGglMjIlNUQ=",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>, name=<span class="hljs-string">&quot;en-US&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>sampling_rate = dataset.features[<span class="hljs-string">&quot;audio&quot;</span>].sampling_rate
<span class="hljs-meta">&gt;&gt;&gt; </span>audio_file = dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;path&quot;</span>]`}}),Zs=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMmF1ZGlvLWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfbWluZHNfbW9kZWwlMjIpJTBBY2xhc3NpZmllcihhdWRpb19maWxlKQ==",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>classifier = pipeline(<span class="hljs-string">&quot;audio-classification&quot;</span>, model=<span class="hljs-string">&quot;stevhliu/my_awesome_minds_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(audio_file)
[
    {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.09766869246959686</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;cash_deposit&#x27;</span>},
    {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.07998877018690109</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;app_error&#x27;</span>},
    {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0781070664525032</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;joint_account&#x27;</span>},
    {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.07667109370231628</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;pay_bill&#x27;</span>},
    {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0755252093076706</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;balance&#x27;</span>}
]`}}),Oe=new ao({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[jo]},$$scope:{ctx:ee}}}),{c(){m=n("meta"),g=c(),u=n("h1"),b=n("a"),k=n("span"),j(J.$$.fragment),W=c(),A=n("span"),E=t("Audio classification"),R=c(),j(X.$$.fragment),V=c(),j(N.$$.fragment),I=c(),U=n("p"),L=t("Audio classification - just like with text - assigns a class label output from the input data. The only difference is instead of text inputs, you have raw audio waveforms. Some practical applications of audio classification include identifying speaker intent, language classification, and even animal species by their sounds."),q=c(),F=n("p"),se=t("This guide will show you how to:"),C=c(),G=n("ol"),y=n("li"),Z=t("Finetune "),B=n("a"),pe=t("Wav2Vec2"),H=t(" on the "),Q=n("a"),_e=t("MInDS-14"),we=t(" dataset to classify speaker intent."),S=c(),ue=n("li"),ce=t("Use your finetuned model for inference."),oe=c(),j(ae.$$.fragment),D=c(),T=n("p"),ke=t("Before you begin, make sure you have all the necessary libraries installed:"),Me=c(),j(P.$$.fragment),ve=c(),te=n("p"),Ee=t("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:"),$e=c(),j(re.$$.fragment),ie=c(),K=n("h2"),z=n("a"),xe=n("span"),j(he.$$.fragment),ss=c(),Ae=n("span"),Ye=t("Load MInDS-14 dataset"),de=c(),Je=n("p"),d=t("Start by loading the MInDS-14 dataset from the \u{1F917} Datasets library:"),x=c(),j(fe.$$.fragment),as=c(),O=n("p"),me=t("Split the dataset\u2019s "),Ce=n("code"),xs=t("train"),As=t(" split into a smaller train and test set with the "),Ue=n("a"),We=t("train_test_split"),Rs=t(" method. This\u2019ll give you a chance to experiment and make sure everything works before spending more time on the full dataset."),ts=c(),j(ye.$$.fragment),ls=c(),Te=n("p"),Xs=t("Then take a look at the dataset:"),Ta=c(),j(ns.$$.fragment),ka=c(),le=n("p"),$t=t("While the dataset contains a lot of useful information, like "),Ks=n("code"),Jt=t("lang_id"),Tt=t(" and "),Os=n("code"),kt=t("english_transcription"),Et=t(", you\u2019ll focus on the "),ea=n("code"),Ut=t("audio"),Wt=t(" and "),sa=n("code"),Zt=t("intent_class"),It=t(" in this guide. Remove the other columns with the "),os=n("a"),xt=t("remove_columns"),At=t(" method:"),Ea=c(),j(rs.$$.fragment),Ua=c(),Vs=n("p"),Rt=t("Take a look at an example now:"),Wa=c(),j(is.$$.fragment),Za=c(),Gs=n("p"),Xt=t("There are two fields:"),Ia=c(),Ne=n("ul"),Fe=n("li"),aa=n("code"),Vt=t("audio"),Gt=t(": a 1-dimensional "),ta=n("code"),Yt=t("array"),Ct=t(" of the speech signal that must be called to load and resample the audio file."),Nt=c(),Ys=n("li"),la=n("code"),Ft=t("intent_class"),Bt=t(": represents the class id of the speaker\u2019s intent."),xa=c(),Cs=n("p"),Qt=t("To make it easier for the model to get the label name from the label id, create a dictionary that maps the label name to an integer and vice versa:"),Aa=c(),j(ps.$$.fragment),Ra=c(),Ns=n("p"),St=t("Now you can convert the label id to a label name:"),Xa=c(),j(cs.$$.fragment),Va=c(),Re=n("h2"),Be=n("a"),na=n("span"),j(hs.$$.fragment),zt=c(),oa=n("span"),qt=t("Preprocess"),Ga=c(),Fs=n("p"),Ht=t("The next step is to load a Wav2Vec2 feature extractor to process the audio signal:"),Ya=c(),j(ms.$$.fragment),Ca=c(),Qe=n("p"),Dt=t("The MInDS-14 dataset has a sampling rate of 8000khz (you can find this information in it\u2019s "),us=n("a"),Pt=t("dataset card"),Lt=t("), which means you\u2019ll need to resample the dataset to 16000kHz to use the pretrained Wav2Vec2 model:"),Na=c(),j(fs.$$.fragment),Fa=c(),Bs=n("p"),Kt=t("Now create a preprocessing function that:"),Ba=c(),Ze=n("ol"),ds=n("li"),Ot=t("Calls the "),ra=n("code"),el=t("audio"),sl=t(" column to load, and if necessary, resample the audio file."),al=c(),ys=n("li"),tl=t("Checks if the sampling rate of the audio file matches the sampling rate of the audio data a model was pretrained with. You can find this information in the Wav2Vec2 "),gs=n("a"),ll=t("model card"),nl=t("."),ol=c(),ia=n("li"),rl=t("Set a maximum input length to batch longer inputs without truncating them."),Qa=c(),j(bs.$$.fragment),Sa=c(),ne=n("p"),il=t("To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),js=n("a"),pl=t("map"),cl=t(" function. You can speed up "),pa=n("code"),hl=t("map"),ml=t(" by setting "),ca=n("code"),ul=t("batched=True"),fl=t(" to process multiple elements of the dataset at once. Remove the columns you don\u2019t need, and rename "),ha=n("code"),dl=t("intent_class"),yl=t(" to "),ma=n("code"),gl=t("label"),bl=t(" because that\u2019s the name the model expects:"),za=c(),j(_s.$$.fragment),qa=c(),Xe=n("h2"),Se=n("a"),ua=n("span"),j(ws.$$.fragment),jl=c(),fa=n("span"),_l=t("Evaluate"),Ha=c(),ge=n("p"),wl=t("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} "),Ms=n("a"),Ml=t("Evaluate"),vl=t(" library. For this task, load the "),vs=n("a"),$l=t("accuracy"),Jl=t(" metric (see the \u{1F917} Evaluate "),$s=n("a"),Tl=t("quick tour"),kl=t(" to learn more about how to load and compute a metric):"),Da=c(),j(Js.$$.fragment),Pa=c(),ze=n("p"),El=t("Then create a function that passes your predictions and labels to "),Ts=n("a"),Ul=t("compute"),Wl=t(" to calculate the accuracy:"),La=c(),j(ks.$$.fragment),Ka=c(),qe=n("p"),Zl=t("Your "),da=n("code"),Il=t("compute_metrics"),xl=t(" function is ready to go now, and you\u2019ll return to it when you setup your training."),Oa=c(),Ve=n("h2"),He=n("a"),ya=n("span"),j(Es.$$.fragment),Al=c(),ga=n("span"),Rl=t("Train"),et=c(),j(De.$$.fragment),st=c(),j(Pe.$$.fragment),at=c(),Ge=n("h2"),Le=n("a"),ba=n("span"),j(Us.$$.fragment),Xl=c(),ja=n("span"),Vl=t("Inference"),tt=c(),Qs=n("p"),Gl=t("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),lt=c(),Ss=n("p"),Yl=t("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!"),nt=c(),j(Ws.$$.fragment),ot=c(),Ie=n("p"),Cl=t("The simplest way to try out your finetuned model for inference is to use it in a "),zs=n("a"),Nl=t("pipeline()"),Fl=t(". Instantiate a "),_a=n("code"),Bl=t("pipeline"),Ql=t(" for audio classification with your model, and pass your audio file to it:"),rt=c(),j(Zs.$$.fragment),it=c(),Ke=n("p"),Sl=t("You can also manually replicate the results of the "),wa=n("code"),zl=t("pipeline"),ql=t(" if you\u2019d like:"),pt=c(),j(Oe.$$.fragment),this.h()},l(e){const i=ro('[data-svelte="svelte-1phssyn"]',document.head);m=o(i,"META",{name:!0,content:!0}),i.forEach(a),g=h(e),u=o(e,"H1",{class:!0});var Is=r(u);b=o(Is,"A",{id:!0,class:!0,href:!0});var Ma=r(b);k=o(Ma,"SPAN",{});var va=r(k);_(J.$$.fragment,va),va.forEach(a),Ma.forEach(a),W=h(Is),A=o(Is,"SPAN",{});var $a=r(A);E=l($a,"Audio classification"),$a.forEach(a),Is.forEach(a),R=h(e),_(X.$$.fragment,e),V=h(e),_(N.$$.fragment,e),I=h(e),U=o(e,"P",{});var Pl=r(U);L=l(Pl,"Audio classification - just like with text - assigns a class label output from the input data. The only difference is instead of text inputs, you have raw audio waveforms. Some practical applications of audio classification include identifying speaker intent, language classification, and even animal species by their sounds."),Pl.forEach(a),q=h(e),F=o(e,"P",{});var Ll=r(F);se=l(Ll,"This guide will show you how to:"),Ll.forEach(a),C=h(e),G=o(e,"OL",{});var ht=r(G);y=o(ht,"LI",{});var qs=r(y);Z=l(qs,"Finetune "),B=o(qs,"A",{href:!0,rel:!0});var Kl=r(B);pe=l(Kl,"Wav2Vec2"),Kl.forEach(a),H=l(qs," on the "),Q=o(qs,"A",{href:!0,rel:!0});var Ol=r(Q);_e=l(Ol,"MInDS-14"),Ol.forEach(a),we=l(qs," dataset to classify speaker intent."),qs.forEach(a),S=h(ht),ue=o(ht,"LI",{});var en=r(ue);ce=l(en,"Use your finetuned model for inference."),en.forEach(a),ht.forEach(a),oe=h(e),_(ae.$$.fragment,e),D=h(e),T=o(e,"P",{});var sn=r(T);ke=l(sn,"Before you begin, make sure you have all the necessary libraries installed:"),sn.forEach(a),Me=h(e),_(P.$$.fragment,e),ve=h(e),te=o(e,"P",{});var an=r(te);Ee=l(an,"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:"),an.forEach(a),$e=h(e),_(re.$$.fragment,e),ie=h(e),K=o(e,"H2",{class:!0});var mt=r(K);z=o(mt,"A",{id:!0,class:!0,href:!0});var tn=r(z);xe=o(tn,"SPAN",{});var ln=r(xe);_(he.$$.fragment,ln),ln.forEach(a),tn.forEach(a),ss=h(mt),Ae=o(mt,"SPAN",{});var nn=r(Ae);Ye=l(nn,"Load MInDS-14 dataset"),nn.forEach(a),mt.forEach(a),de=h(e),Je=o(e,"P",{});var on=r(Je);d=l(on,"Start by loading the MInDS-14 dataset from the \u{1F917} Datasets library:"),on.forEach(a),x=h(e),_(fe.$$.fragment,e),as=h(e),O=o(e,"P",{});var Hs=r(O);me=l(Hs,"Split the dataset\u2019s "),Ce=o(Hs,"CODE",{});var rn=r(Ce);xs=l(rn,"train"),rn.forEach(a),As=l(Hs," split into a smaller train and test set with the "),Ue=o(Hs,"A",{href:!0,rel:!0});var pn=r(Ue);We=l(pn,"train_test_split"),pn.forEach(a),Rs=l(Hs," method. This\u2019ll give you a chance to experiment and make sure everything works before spending more time on the full dataset."),Hs.forEach(a),ts=h(e),_(ye.$$.fragment,e),ls=h(e),Te=o(e,"P",{});var cn=r(Te);Xs=l(cn,"Then take a look at the dataset:"),cn.forEach(a),Ta=h(e),_(ns.$$.fragment,e),ka=h(e),le=o(e,"P",{});var be=r(le);$t=l(be,"While the dataset contains a lot of useful information, like "),Ks=o(be,"CODE",{});var hn=r(Ks);Jt=l(hn,"lang_id"),hn.forEach(a),Tt=l(be," and "),Os=o(be,"CODE",{});var mn=r(Os);kt=l(mn,"english_transcription"),mn.forEach(a),Et=l(be,", you\u2019ll focus on the "),ea=o(be,"CODE",{});var un=r(ea);Ut=l(un,"audio"),un.forEach(a),Wt=l(be," and "),sa=o(be,"CODE",{});var fn=r(sa);Zt=l(fn,"intent_class"),fn.forEach(a),It=l(be," in this guide. Remove the other columns with the "),os=o(be,"A",{href:!0,rel:!0});var dn=r(os);xt=l(dn,"remove_columns"),dn.forEach(a),At=l(be," method:"),be.forEach(a),Ea=h(e),_(rs.$$.fragment,e),Ua=h(e),Vs=o(e,"P",{});var yn=r(Vs);Rt=l(yn,"Take a look at an example now:"),yn.forEach(a),Wa=h(e),_(is.$$.fragment,e),Za=h(e),Gs=o(e,"P",{});var gn=r(Gs);Xt=l(gn,"There are two fields:"),gn.forEach(a),Ia=h(e),Ne=o(e,"UL",{});var ut=r(Ne);Fe=o(ut,"LI",{});var Ja=r(Fe);aa=o(Ja,"CODE",{});var bn=r(aa);Vt=l(bn,"audio"),bn.forEach(a),Gt=l(Ja,": a 1-dimensional "),ta=o(Ja,"CODE",{});var jn=r(ta);Yt=l(jn,"array"),jn.forEach(a),Ct=l(Ja," of the speech signal that must be called to load and resample the audio file."),Ja.forEach(a),Nt=h(ut),Ys=o(ut,"LI",{});var Hl=r(Ys);la=o(Hl,"CODE",{});var _n=r(la);Ft=l(_n,"intent_class"),_n.forEach(a),Bt=l(Hl,": represents the class id of the speaker\u2019s intent."),Hl.forEach(a),ut.forEach(a),xa=h(e),Cs=o(e,"P",{});var wn=r(Cs);Qt=l(wn,"To make it easier for the model to get the label name from the label id, create a dictionary that maps the label name to an integer and vice versa:"),wn.forEach(a),Aa=h(e),_(ps.$$.fragment,e),Ra=h(e),Ns=o(e,"P",{});var Mn=r(Ns);St=l(Mn,"Now you can convert the label id to a label name:"),Mn.forEach(a),Xa=h(e),_(cs.$$.fragment,e),Va=h(e),Re=o(e,"H2",{class:!0});var ft=r(Re);Be=o(ft,"A",{id:!0,class:!0,href:!0});var vn=r(Be);na=o(vn,"SPAN",{});var $n=r(na);_(hs.$$.fragment,$n),$n.forEach(a),vn.forEach(a),zt=h(ft),oa=o(ft,"SPAN",{});var Jn=r(oa);qt=l(Jn,"Preprocess"),Jn.forEach(a),ft.forEach(a),Ga=h(e),Fs=o(e,"P",{});var Tn=r(Fs);Ht=l(Tn,"The next step is to load a Wav2Vec2 feature extractor to process the audio signal:"),Tn.forEach(a),Ya=h(e),_(ms.$$.fragment,e),Ca=h(e),Qe=o(e,"P",{});var dt=r(Qe);Dt=l(dt,"The MInDS-14 dataset has a sampling rate of 8000khz (you can find this information in it\u2019s "),us=o(dt,"A",{href:!0,rel:!0});var kn=r(us);Pt=l(kn,"dataset card"),kn.forEach(a),Lt=l(dt,"), which means you\u2019ll need to resample the dataset to 16000kHz to use the pretrained Wav2Vec2 model:"),dt.forEach(a),Na=h(e),_(fs.$$.fragment,e),Fa=h(e),Bs=o(e,"P",{});var En=r(Bs);Kt=l(En,"Now create a preprocessing function that:"),En.forEach(a),Ba=h(e),Ze=o(e,"OL",{});var Ds=r(Ze);ds=o(Ds,"LI",{});var yt=r(ds);Ot=l(yt,"Calls the "),ra=o(yt,"CODE",{});var Un=r(ra);el=l(Un,"audio"),Un.forEach(a),sl=l(yt," column to load, and if necessary, resample the audio file."),yt.forEach(a),al=h(Ds),ys=o(Ds,"LI",{});var gt=r(ys);tl=l(gt,"Checks if the sampling rate of the audio file matches the sampling rate of the audio data a model was pretrained with. You can find this information in the Wav2Vec2 "),gs=o(gt,"A",{href:!0,rel:!0});var Wn=r(gs);ll=l(Wn,"model card"),Wn.forEach(a),nl=l(gt,"."),gt.forEach(a),ol=h(Ds),ia=o(Ds,"LI",{});var Zn=r(ia);rl=l(Zn,"Set a maximum input length to batch longer inputs without truncating them."),Zn.forEach(a),Ds.forEach(a),Qa=h(e),_(bs.$$.fragment,e),Sa=h(e),ne=o(e,"P",{});var je=r(ne);il=l(je,"To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),js=o(je,"A",{href:!0,rel:!0});var In=r(js);pl=l(In,"map"),In.forEach(a),cl=l(je," function. You can speed up "),pa=o(je,"CODE",{});var xn=r(pa);hl=l(xn,"map"),xn.forEach(a),ml=l(je," by setting "),ca=o(je,"CODE",{});var An=r(ca);ul=l(An,"batched=True"),An.forEach(a),fl=l(je," to process multiple elements of the dataset at once. Remove the columns you don\u2019t need, and rename "),ha=o(je,"CODE",{});var Rn=r(ha);dl=l(Rn,"intent_class"),Rn.forEach(a),yl=l(je," to "),ma=o(je,"CODE",{});var Xn=r(ma);gl=l(Xn,"label"),Xn.forEach(a),bl=l(je," because that\u2019s the name the model expects:"),je.forEach(a),za=h(e),_(_s.$$.fragment,e),qa=h(e),Xe=o(e,"H2",{class:!0});var bt=r(Xe);Se=o(bt,"A",{id:!0,class:!0,href:!0});var Vn=r(Se);ua=o(Vn,"SPAN",{});var Gn=r(ua);_(ws.$$.fragment,Gn),Gn.forEach(a),Vn.forEach(a),jl=h(bt),fa=o(bt,"SPAN",{});var Yn=r(fa);_l=l(Yn,"Evaluate"),Yn.forEach(a),bt.forEach(a),Ha=h(e),ge=o(e,"P",{});var es=r(ge);wl=l(es,"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} "),Ms=o(es,"A",{href:!0,rel:!0});var Cn=r(Ms);Ml=l(Cn,"Evaluate"),Cn.forEach(a),vl=l(es," library. For this task, load the "),vs=o(es,"A",{href:!0,rel:!0});var Nn=r(vs);$l=l(Nn,"accuracy"),Nn.forEach(a),Jl=l(es," metric (see the \u{1F917} Evaluate "),$s=o(es,"A",{href:!0,rel:!0});var Fn=r($s);Tl=l(Fn,"quick tour"),Fn.forEach(a),kl=l(es," to learn more about how to load and compute a metric):"),es.forEach(a),Da=h(e),_(Js.$$.fragment,e),Pa=h(e),ze=o(e,"P",{});var jt=r(ze);El=l(jt,"Then create a function that passes your predictions and labels to "),Ts=o(jt,"A",{href:!0,rel:!0});var Bn=r(Ts);Ul=l(Bn,"compute"),Bn.forEach(a),Wl=l(jt," to calculate the accuracy:"),jt.forEach(a),La=h(e),_(ks.$$.fragment,e),Ka=h(e),qe=o(e,"P",{});var _t=r(qe);Zl=l(_t,"Your "),da=o(_t,"CODE",{});var Qn=r(da);Il=l(Qn,"compute_metrics"),Qn.forEach(a),xl=l(_t," function is ready to go now, and you\u2019ll return to it when you setup your training."),_t.forEach(a),Oa=h(e),Ve=o(e,"H2",{class:!0});var wt=r(Ve);He=o(wt,"A",{id:!0,class:!0,href:!0});var Sn=r(He);ya=o(Sn,"SPAN",{});var zn=r(ya);_(Es.$$.fragment,zn),zn.forEach(a),Sn.forEach(a),Al=h(wt),ga=o(wt,"SPAN",{});var qn=r(ga);Rl=l(qn,"Train"),qn.forEach(a),wt.forEach(a),et=h(e),_(De.$$.fragment,e),st=h(e),_(Pe.$$.fragment,e),at=h(e),Ge=o(e,"H2",{class:!0});var Mt=r(Ge);Le=o(Mt,"A",{id:!0,class:!0,href:!0});var Hn=r(Le);ba=o(Hn,"SPAN",{});var Dn=r(ba);_(Us.$$.fragment,Dn),Dn.forEach(a),Hn.forEach(a),Xl=h(Mt),ja=o(Mt,"SPAN",{});var Pn=r(ja);Vl=l(Pn,"Inference"),Pn.forEach(a),Mt.forEach(a),tt=h(e),Qs=o(e,"P",{});var Ln=r(Qs);Gl=l(Ln,"Great, now that you\u2019ve finetuned a model, you can use it for inference!"),Ln.forEach(a),lt=h(e),Ss=o(e,"P",{});var Kn=r(Ss);Yl=l(Kn,"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!"),Kn.forEach(a),nt=h(e),_(Ws.$$.fragment,e),ot=h(e),Ie=o(e,"P",{});var Ps=r(Ie);Cl=l(Ps,"The simplest way to try out your finetuned model for inference is to use it in a "),zs=o(Ps,"A",{href:!0});var On=r(zs);Nl=l(On,"pipeline()"),On.forEach(a),Fl=l(Ps,". Instantiate a "),_a=o(Ps,"CODE",{});var eo=r(_a);Bl=l(eo,"pipeline"),eo.forEach(a),Ql=l(Ps," for audio classification with your model, and pass your audio file to it:"),Ps.forEach(a),rt=h(e),_(Zs.$$.fragment,e),it=h(e),Ke=o(e,"P",{});var vt=r(Ke);Sl=l(vt,"You can also manually replicate the results of the "),wa=o(vt,"CODE",{});var so=r(wa);zl=l(so,"pipeline"),so.forEach(a),ql=l(vt," if you\u2019d like:"),vt.forEach(a),pt=h(e),_(Oe.$$.fragment,e),this.h()},h(){f(m,"name","hf:doc:metadata"),f(m,"content",JSON.stringify(wo)),f(b,"id","audio-classification"),f(b,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(b,"href","#audio-classification"),f(u,"class","relative group"),f(B,"href","https://huggingface.co/facebook/wav2vec2-base"),f(B,"rel","nofollow"),f(Q,"href","https://huggingface.co/datasets/PolyAI/minds14"),f(Q,"rel","nofollow"),f(z,"id","load-minds14-dataset"),f(z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(z,"href","#load-minds14-dataset"),f(K,"class","relative group"),f(Ue,"href","https://huggingface.co/docs/datasets/v2.12.0/en/package_reference/main_classes#datasets.Dataset.train_test_split"),f(Ue,"rel","nofollow"),f(os,"href","https://huggingface.co/docs/datasets/v2.12.0/en/package_reference/main_classes#datasets.Dataset.remove_columns"),f(os,"rel","nofollow"),f(Be,"id","preprocess"),f(Be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(Be,"href","#preprocess"),f(Re,"class","relative group"),f(us,"href","https://huggingface.co/datasets/PolyAI/minds14"),f(us,"rel","nofollow"),f(gs,"href","https://huggingface.co/facebook/wav2vec2-base"),f(gs,"rel","nofollow"),f(js,"href","https://huggingface.co/docs/datasets/v2.12.0/en/package_reference/main_classes#datasets.Dataset.map"),f(js,"rel","nofollow"),f(Se,"id","evaluate"),f(Se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(Se,"href","#evaluate"),f(Xe,"class","relative group"),f(Ms,"href","https://huggingface.co/docs/evaluate/index"),f(Ms,"rel","nofollow"),f(vs,"href","https://huggingface.co/spaces/evaluate-metric/accuracy"),f(vs,"rel","nofollow"),f($s,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),f($s,"rel","nofollow"),f(Ts,"href","https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),f(Ts,"rel","nofollow"),f(He,"id","train"),f(He,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(He,"href","#train"),f(Ve,"class","relative group"),f(Le,"id","inference"),f(Le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(Le,"href","#inference"),f(Ge,"class","relative group"),f(zs,"href","/docs/transformers/v4.30.0/en/main_classes/pipelines#transformers.pipeline")},m(e,i){s(document.head,m),p(e,g,i),p(e,u,i),s(u,b),s(b,k),w(J,k,null),s(u,W),s(u,A),s(A,E),p(e,R,i),w(X,e,i),p(e,V,i),w(N,e,i),p(e,I,i),p(e,U,i),s(U,L),p(e,q,i),p(e,F,i),s(F,se),p(e,C,i),p(e,G,i),s(G,y),s(y,Z),s(y,B),s(B,pe),s(y,H),s(y,Q),s(Q,_e),s(y,we),s(G,S),s(G,ue),s(ue,ce),p(e,oe,i),w(ae,e,i),p(e,D,i),p(e,T,i),s(T,ke),p(e,Me,i),w(P,e,i),p(e,ve,i),p(e,te,i),s(te,Ee),p(e,$e,i),w(re,e,i),p(e,ie,i),p(e,K,i),s(K,z),s(z,xe),w(he,xe,null),s(K,ss),s(K,Ae),s(Ae,Ye),p(e,de,i),p(e,Je,i),s(Je,d),p(e,x,i),w(fe,e,i),p(e,as,i),p(e,O,i),s(O,me),s(O,Ce),s(Ce,xs),s(O,As),s(O,Ue),s(Ue,We),s(O,Rs),p(e,ts,i),w(ye,e,i),p(e,ls,i),p(e,Te,i),s(Te,Xs),p(e,Ta,i),w(ns,e,i),p(e,ka,i),p(e,le,i),s(le,$t),s(le,Ks),s(Ks,Jt),s(le,Tt),s(le,Os),s(Os,kt),s(le,Et),s(le,ea),s(ea,Ut),s(le,Wt),s(le,sa),s(sa,Zt),s(le,It),s(le,os),s(os,xt),s(le,At),p(e,Ea,i),w(rs,e,i),p(e,Ua,i),p(e,Vs,i),s(Vs,Rt),p(e,Wa,i),w(is,e,i),p(e,Za,i),p(e,Gs,i),s(Gs,Xt),p(e,Ia,i),p(e,Ne,i),s(Ne,Fe),s(Fe,aa),s(aa,Vt),s(Fe,Gt),s(Fe,ta),s(ta,Yt),s(Fe,Ct),s(Ne,Nt),s(Ne,Ys),s(Ys,la),s(la,Ft),s(Ys,Bt),p(e,xa,i),p(e,Cs,i),s(Cs,Qt),p(e,Aa,i),w(ps,e,i),p(e,Ra,i),p(e,Ns,i),s(Ns,St),p(e,Xa,i),w(cs,e,i),p(e,Va,i),p(e,Re,i),s(Re,Be),s(Be,na),w(hs,na,null),s(Re,zt),s(Re,oa),s(oa,qt),p(e,Ga,i),p(e,Fs,i),s(Fs,Ht),p(e,Ya,i),w(ms,e,i),p(e,Ca,i),p(e,Qe,i),s(Qe,Dt),s(Qe,us),s(us,Pt),s(Qe,Lt),p(e,Na,i),w(fs,e,i),p(e,Fa,i),p(e,Bs,i),s(Bs,Kt),p(e,Ba,i),p(e,Ze,i),s(Ze,ds),s(ds,Ot),s(ds,ra),s(ra,el),s(ds,sl),s(Ze,al),s(Ze,ys),s(ys,tl),s(ys,gs),s(gs,ll),s(ys,nl),s(Ze,ol),s(Ze,ia),s(ia,rl),p(e,Qa,i),w(bs,e,i),p(e,Sa,i),p(e,ne,i),s(ne,il),s(ne,js),s(js,pl),s(ne,cl),s(ne,pa),s(pa,hl),s(ne,ml),s(ne,ca),s(ca,ul),s(ne,fl),s(ne,ha),s(ha,dl),s(ne,yl),s(ne,ma),s(ma,gl),s(ne,bl),p(e,za,i),w(_s,e,i),p(e,qa,i),p(e,Xe,i),s(Xe,Se),s(Se,ua),w(ws,ua,null),s(Xe,jl),s(Xe,fa),s(fa,_l),p(e,Ha,i),p(e,ge,i),s(ge,wl),s(ge,Ms),s(Ms,Ml),s(ge,vl),s(ge,vs),s(vs,$l),s(ge,Jl),s(ge,$s),s($s,Tl),s(ge,kl),p(e,Da,i),w(Js,e,i),p(e,Pa,i),p(e,ze,i),s(ze,El),s(ze,Ts),s(Ts,Ul),s(ze,Wl),p(e,La,i),w(ks,e,i),p(e,Ka,i),p(e,qe,i),s(qe,Zl),s(qe,da),s(da,Il),s(qe,xl),p(e,Oa,i),p(e,Ve,i),s(Ve,He),s(He,ya),w(Es,ya,null),s(Ve,Al),s(Ve,ga),s(ga,Rl),p(e,et,i),w(De,e,i),p(e,st,i),w(Pe,e,i),p(e,at,i),p(e,Ge,i),s(Ge,Le),s(Le,ba),w(Us,ba,null),s(Ge,Xl),s(Ge,ja),s(ja,Vl),p(e,tt,i),p(e,Qs,i),s(Qs,Gl),p(e,lt,i),p(e,Ss,i),s(Ss,Yl),p(e,nt,i),w(Ws,e,i),p(e,ot,i),p(e,Ie,i),s(Ie,Cl),s(Ie,zs),s(zs,Nl),s(Ie,Fl),s(Ie,_a),s(_a,Bl),s(Ie,Ql),p(e,rt,i),w(Zs,e,i),p(e,it,i),p(e,Ke,i),s(Ke,Sl),s(Ke,wa),s(wa,zl),s(Ke,ql),p(e,pt,i),w(Oe,e,i),ct=!0},p(e,[i]){const Is={};i&2&&(Is.$$scope={dirty:i,ctx:e}),ae.$set(Is);const Ma={};i&2&&(Ma.$$scope={dirty:i,ctx:e}),De.$set(Ma);const va={};i&2&&(va.$$scope={dirty:i,ctx:e}),Pe.$set(va);const $a={};i&2&&($a.$$scope={dirty:i,ctx:e}),Oe.$set($a)},i(e){ct||(M(J.$$.fragment,e),M(X.$$.fragment,e),M(N.$$.fragment,e),M(ae.$$.fragment,e),M(P.$$.fragment,e),M(re.$$.fragment,e),M(he.$$.fragment,e),M(fe.$$.fragment,e),M(ye.$$.fragment,e),M(ns.$$.fragment,e),M(rs.$$.fragment,e),M(is.$$.fragment,e),M(ps.$$.fragment,e),M(cs.$$.fragment,e),M(hs.$$.fragment,e),M(ms.$$.fragment,e),M(fs.$$.fragment,e),M(bs.$$.fragment,e),M(_s.$$.fragment,e),M(ws.$$.fragment,e),M(Js.$$.fragment,e),M(ks.$$.fragment,e),M(Es.$$.fragment,e),M(De.$$.fragment,e),M(Pe.$$.fragment,e),M(Us.$$.fragment,e),M(Ws.$$.fragment,e),M(Zs.$$.fragment,e),M(Oe.$$.fragment,e),ct=!0)},o(e){v(J.$$.fragment,e),v(X.$$.fragment,e),v(N.$$.fragment,e),v(ae.$$.fragment,e),v(P.$$.fragment,e),v(re.$$.fragment,e),v(he.$$.fragment,e),v(fe.$$.fragment,e),v(ye.$$.fragment,e),v(ns.$$.fragment,e),v(rs.$$.fragment,e),v(is.$$.fragment,e),v(ps.$$.fragment,e),v(cs.$$.fragment,e),v(hs.$$.fragment,e),v(ms.$$.fragment,e),v(fs.$$.fragment,e),v(bs.$$.fragment,e),v(_s.$$.fragment,e),v(ws.$$.fragment,e),v(Js.$$.fragment,e),v(ks.$$.fragment,e),v(Es.$$.fragment,e),v(De.$$.fragment,e),v(Pe.$$.fragment,e),v(Us.$$.fragment,e),v(Ws.$$.fragment,e),v(Zs.$$.fragment,e),v(Oe.$$.fragment,e),ct=!1},d(e){a(m),e&&a(g),e&&a(u),$(J),e&&a(R),$(X,e),e&&a(V),$(N,e),e&&a(I),e&&a(U),e&&a(q),e&&a(F),e&&a(C),e&&a(G),e&&a(oe),$(ae,e),e&&a(D),e&&a(T),e&&a(Me),$(P,e),e&&a(ve),e&&a(te),e&&a($e),$(re,e),e&&a(ie),e&&a(K),$(he),e&&a(de),e&&a(Je),e&&a(x),$(fe,e),e&&a(as),e&&a(O),e&&a(ts),$(ye,e),e&&a(ls),e&&a(Te),e&&a(Ta),$(ns,e),e&&a(ka),e&&a(le),e&&a(Ea),$(rs,e),e&&a(Ua),e&&a(Vs),e&&a(Wa),$(is,e),e&&a(Za),e&&a(Gs),e&&a(Ia),e&&a(Ne),e&&a(xa),e&&a(Cs),e&&a(Aa),$(ps,e),e&&a(Ra),e&&a(Ns),e&&a(Xa),$(cs,e),e&&a(Va),e&&a(Re),$(hs),e&&a(Ga),e&&a(Fs),e&&a(Ya),$(ms,e),e&&a(Ca),e&&a(Qe),e&&a(Na),$(fs,e),e&&a(Fa),e&&a(Bs),e&&a(Ba),e&&a(Ze),e&&a(Qa),$(bs,e),e&&a(Sa),e&&a(ne),e&&a(za),$(_s,e),e&&a(qa),e&&a(Xe),$(ws),e&&a(Ha),e&&a(ge),e&&a(Da),$(Js,e),e&&a(Pa),e&&a(ze),e&&a(La),$(ks,e),e&&a(Ka),e&&a(qe),e&&a(Oa),e&&a(Ve),$(Es),e&&a(et),$(De,e),e&&a(st),$(Pe,e),e&&a(at),e&&a(Ge),$(Us),e&&a(tt),e&&a(Qs),e&&a(lt),e&&a(Ss),e&&a(nt),$(Ws,e),e&&a(ot),e&&a(Ie),e&&a(rt),$(Zs,e),e&&a(it),e&&a(Ke),e&&a(pt),$(Oe,e)}}}const wo={local:"audio-classification",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:"Audio classification"};function Mo(ee){return io(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Wo extends lo{constructor(m){super();no(this,m,Mo,_o,oo,{})}}export{Wo as default,wo as metadata};
