import{S as cs,i as ys,s as hs,e as i,k as p,w as f,t,M as fs,c as M,d as e,m as d,a as r,x as m,h as n,b as u,N as ms,G as a,g as o,y as j,L as js,q as w,o as U,B as J,v as ws}from"../../chunks/vendor-hf-doc-builder.js";import{I as Us}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as T}from"../../chunks/CodeBlock-hf-doc-builder.js";function Js(va){let I,Wl,E,C,ul,W,Ue,cl,Je,Bl,P,Te,Ql,L,be,Rl,B,Nl,v,Ae,yl,Ie,Ee,Yl,k,Ce,Q,ve,ke,xl,c,_e,hl,ge,Ge,fl,$e,qe,ml,Ze,We,Fl,R,Sl,K,jl,Be,Dl,N,zl,ll,Qe,Xl,Y,Vl,el,wl,Re,Hl,x,Ol,al,Ne,Pl,b,_,Ul,Ye,xe,Jl,Fe,Se,De,sl,Tl,ze,Xe,Ve,tl,bl,He,Oe,Ll,A,Pe,Al,Le,Ke,Il,la,ea,Kl,F,le,nl,El,aa,ee,S,ae,ol,sa,se,y,ta,Cl,na,oa,vl,ia,Ma,kl,ra,pa,te,g,da,_l,ua,ca,ne,D,oe,il,gl,ya,ie,z,Me,h,ha,Gl,fa,ma,$l,ja,wa,ql,Ua,Ja,re,X,pe,Ml,Ta,de,V,ue,H,rl,ka,ce,G,ba,O,Aa,Ia,ye;return W=new Us({}),B=new T({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRhdGFzZXRzJTVCYXVkaW8lNUQ=",highlighted:"pip install datasets[audio]"}}),R=new T({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBbWluZHMlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyUG9seUFJJTJGbWluZHMxNCUyMiUyQyUyMG5hbWUlM0QlMjJlbi1BVSUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIpJTBBbWluZHM=",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

minds = load_dataset(<span class="hljs-string">&quot;PolyAI/minds14&quot;</span>, name=<span class="hljs-string">&quot;en-AU&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
minds`}}),N=new T({props:{code:"RGF0YXNldCglMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnBhdGglMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJhdWRpbyUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnRyYW5zY3JpcHRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJlbmdsaXNoX3RyYW5zY3JpcHRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJpbnRlbnRfY2xhc3MlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsYW5nX2lkJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3Jvd3MlM0ElMjA2NTQlMkMlMEElMjAlMjAlMjAlMjAlN0QlMEEp",highlighted:`Dataset(
    <span class="hljs-punctuation">{</span>
<span class="hljs-symbol">        features:</span> [
            <span class="hljs-string">&quot;path&quot;</span>,
            <span class="hljs-string">&quot;audio&quot;</span>,
            <span class="hljs-string">&quot;transcription&quot;</span>,
            <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>,
        ],
<span class="hljs-symbol">        num_rows:</span> <span class="hljs-number">654</span>,
    <span class="hljs-punctuation">}</span>
)`}}),Y=new T({props:{code:"ZXhhbXBsZSUyMCUzRCUyMG1pbmRzJTVCMCU1RCUwQWV4YW1wbGU=",highlighted:`example = minds[<span class="hljs-number">0</span>]
example`}}),x=new T({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIycGF0aCUyMiUzQSUyMCUyMiUyRnJvb3QlMkYuY2FjaGUlMkZodWdnaW5nZmFjZSUyRmRhdGFzZXRzJTJGZG93bmxvYWRzJTJGZXh0cmFjdGVkJTJGZjE0OTQ4ZTBlODRiZTYzOGRkNzk0M2FjMzY1MThhNGNmMzMyNGU4YjdhYTMzMWM1YWIxMTU0MTUxOGU5MzY4YyUyRmVuLUFVflBBWV9CSUxMJTJGcmVzcG9uc2VfNC53YXYlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJhdWRpbyUyMiUzQSUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnBhdGglMjIlM0ElMjAlMjIlMkZyb290JTJGLmNhY2hlJTJGaHVnZ2luZ2ZhY2UlMkZkYXRhc2V0cyUyRmRvd25sb2FkcyUyRmV4dHJhY3RlZCUyRmYxNDk0OGUwZTg0YmU2MzhkZDc5NDNhYzM2NTE4YTRjZjMzMjRlOGI3YWEzMzFjNWFiMTE1NDE1MThlOTM2OGMlMkZlbi1BVX5QQVlfQklMTCUyRnJlc3BvbnNlXzQud2F2JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYXJyYXklMjIlM0ElMjBhcnJheSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUIwLjAlMkMlMjAwLjAwMDI0NDE0JTJDJTIwLTAuMDAwMjQ0MTQlMkMlMjAuLi4lMkMlMjAtMC4wMDAyNDQxNCUyQyUyMDAuMDAwMjQ0MTQlMkMlMjAwLjAwMTIyMDclNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBkdHlwZSUzRGZsb2F0MzIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc2FtcGxpbmdfcmF0ZSUyMiUzQSUyMDgwMDAlMkMlMEElMjAlMjAlMjAlMjAlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjJ0cmFuc2NyaXB0aW9uJTIyJTNBJTIwJTIySSUyMHdvdWxkJTIwbGlrZSUyMHRvJTIwcGF5JTIwbXklMjBlbGVjdHJpY2l0eSUyMGJpbGwlMjB1c2luZyUyMG15JTIwY2FyZCUyMGNhbiUyMHlvdSUyMHBsZWFzZSUyMGFzc2lzdCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMmVuZ2xpc2hfdHJhbnNjcmlwdGlvbiUyMiUzQSUyMCUyMkklMjB3b3VsZCUyMGxpa2UlMjB0byUyMHBheSUyMG15JTIwZWxlY3RyaWNpdHklMjBiaWxsJTIwdXNpbmclMjBteSUyMGNhcmQlMjBjYW4lMjB5b3UlMjBwbGVhc2UlMjBhc3Npc3QlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJpbnRlbnRfY2xhc3MlMjIlM0ElMjAxMyUyQyUwQSUyMCUyMCUyMCUyMCUyMmxhbmdfaWQlMjIlM0ElMjAyJTJDJTBBJTdE",highlighted:`{
    <span class="hljs-comment">&quot;path&quot;</span>: <span class="hljs-comment">&quot;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-AU~PAY_BILL/response_4.wav&quot;</span>,
    <span class="hljs-comment">&quot;audio&quot;</span>: {
        <span class="hljs-comment">&quot;path&quot;</span>: <span class="hljs-comment">&quot;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-AU~PAY_BILL/response_4.wav&quot;</span>,
        <span class="hljs-comment">&quot;array&quot;</span>: array(
            [<span class="hljs-number">0.0</span>, <span class="hljs-number">0.00024414</span>, <span class="hljs-number">-0.00024414</span>, ..., <span class="hljs-number">-0.00024414</span>, <span class="hljs-number">0.00024414</span>, <span class="hljs-number">0.0012207</span>],
            dtype=float32,
        ),
        <span class="hljs-comment">&quot;sampling_rate&quot;</span>: <span class="hljs-number">8000</span>,
    },
    <span class="hljs-comment">&quot;transcription&quot;</span>: <span class="hljs-comment">&quot;I would like to pay my electricity bill using my card can you please assist&quot;</span>,
    <span class="hljs-comment">&quot;english_transcription&quot;</span>: <span class="hljs-comment">&quot;I would like to pay my electricity bill using my card can you please assist&quot;</span>,
    <span class="hljs-comment">&quot;intent_class&quot;</span>: <span class="hljs-number">13</span>,
    <span class="hljs-comment">&quot;lang_id&quot;</span>: <span class="hljs-number">2</span>,
}`}}),F=new T({props:{code:"aWQybGFiZWwlMjAlM0QlMjBtaW5kcy5mZWF0dXJlcyU1QiUyMmludGVudF9jbGFzcyUyMiU1RC5pbnQyc3RyJTBBaWQybGFiZWwoZXhhbXBsZSU1QiUyMmludGVudF9jbGFzcyUyMiU1RCk=",highlighted:`id2label = minds.features[<span class="hljs-string">&quot;intent_class&quot;</span>].int2str
id2label(example[<span class="hljs-string">&quot;intent_class&quot;</span>])`}}),S=new T({props:{code:"JTIycGF5X2JpbGwlMjI=",highlighted:'<span class="hljs-string">&quot;pay_bill&quot;</span>'}}),D=new T({props:{code:"Y29sdW1uc190b19yZW1vdmUlMjAlM0QlMjAlNUIlMjJsYW5nX2lkJTIyJTJDJTIwJTIyZW5nbGlzaF90cmFuc2NyaXB0aW9uJTIyJTVEJTBBbWluZHMlMjAlM0QlMjBtaW5kcy5yZW1vdmVfY29sdW1ucyhjb2x1bW5zX3RvX3JlbW92ZSklMEFtaW5kcw==",highlighted:`columns_to_remove = [<span class="hljs-string">&quot;lang_id&quot;</span>, <span class="hljs-string">&quot;english_transcription&quot;</span>]
minds = minds.remove_columns(columns_to_remove)
minds`}}),z=new T({props:{code:"RGF0YXNldCglN0JmZWF0dXJlcyUzQSUyMCU1QiUyMnBhdGglMjIlMkMlMjAlMjJhdWRpbyUyMiUyQyUyMCUyMnRyYW5zY3JpcHRpb24lMjIlMkMlMjAlMjJpbnRlbnRfY2xhc3MlMjIlNUQlMkMlMjBudW1fcm93cyUzQSUyMDY1NCU3RCk=",highlighted:'<span class="hljs-constructor">Dataset({<span class="hljs-params">features</span>: [<span class="hljs-string">&quot;path&quot;</span>, <span class="hljs-string">&quot;audio&quot;</span>, <span class="hljs-string">&quot;transcription&quot;</span>, <span class="hljs-string">&quot;intent_class&quot;</span>], <span class="hljs-params">num_rows</span>: 654})</span>'}}),X=new T({props:{code:"aW1wb3J0JTIwZ3JhZGlvJTIwYXMlMjBnciUwQSUwQSUwQWRlZiUyMGdlbmVyYXRlX2F1ZGlvKCklM0ElMEElMjAlMjAlMjAlMjBleGFtcGxlJTIwJTNEJTIwbWluZHMuc2h1ZmZsZSgpJTVCMCU1RCUwQSUyMCUyMCUyMCUyMGF1ZGlvJTIwJTNEJTIwZXhhbXBsZSU1QiUyMmF1ZGlvJTIyJTVEJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGF1ZGlvJTVCJTIyc2FtcGxpbmdfcmF0ZSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGF1ZGlvJTVCJTIyYXJyYXklMjIlNUQlMkMlMEElMjAlMjAlMjAlMjApJTJDJTIwaWQybGFiZWwoZXhhbXBsZSU1QiUyMmludGVudF9jbGFzcyUyMiU1RCklMEElMEElMEF3aXRoJTIwZ3IuQmxvY2tzKCklMjBhcyUyMGRlbW8lM0ElMEElMjAlMjAlMjAlMjB3aXRoJTIwZ3IuQ29sdW1uKCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmb3IlMjBfJTIwaW4lMjByYW5nZSg0KSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGF1ZGlvJTJDJTIwbGFiZWwlMjAlM0QlMjBnZW5lcmF0ZV9hdWRpbygpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3V0cHV0JTIwJTNEJTIwZ3IuQXVkaW8oYXVkaW8lMkMlMjBsYWJlbCUzRGxhYmVsKSUwQSUwQWRlbW8ubGF1bmNoKGRlYnVnJTNEVHJ1ZSk=",highlighted:`<span class="hljs-keyword">import</span> gradio <span class="hljs-keyword">as</span> gr


<span class="hljs-keyword">def</span> <span class="hljs-title function_">generate_audio</span>():
    example = minds.shuffle()[<span class="hljs-number">0</span>]
    audio = example[<span class="hljs-string">&quot;audio&quot;</span>]
    <span class="hljs-keyword">return</span> (
        audio[<span class="hljs-string">&quot;sampling_rate&quot;</span>],
        audio[<span class="hljs-string">&quot;array&quot;</span>],
    ), id2label(example[<span class="hljs-string">&quot;intent_class&quot;</span>])


<span class="hljs-keyword">with</span> gr.Blocks() <span class="hljs-keyword">as</span> demo:
    <span class="hljs-keyword">with</span> gr.Column():
        <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">4</span>):
            audio, label = generate_audio()
            output = gr.Audio(audio, label=label)

demo.launch(debug=<span class="hljs-literal">True</span>)`}}),V=new T({props:{code:"aW1wb3J0JTIwbGlicm9zYSUwQWltcG9ydCUyMG1hdHBsb3RsaWIucHlwbG90JTIwYXMlMjBwbHQlMEFpbXBvcnQlMjBsaWJyb3NhLmRpc3BsYXklMEElMEFhcnJheSUyMCUzRCUyMGV4YW1wbGUlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVEJTBBc2FtcGxpbmdfcmF0ZSUyMCUzRCUyMGV4YW1wbGUlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMnNhbXBsaW5nX3JhdGUlMjIlNUQlMEElMEFwbHQuZmlndXJlKCkuc2V0X2ZpZ3dpZHRoKDEyKSUwQWxpYnJvc2EuZGlzcGxheS53YXZlc2hvdyhhcnJheSUyQyUyMHNyJTNEc2FtcGxpbmdfcmF0ZSk=",highlighted:`<span class="hljs-keyword">import</span> librosa
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
<span class="hljs-keyword">import</span> librosa.display

array = example[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>]
sampling_rate = example[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;sampling_rate&quot;</span>]

plt.figure().set_figwidth(<span class="hljs-number">12</span>)
librosa.display.waveshow(array, sr=sampling_rate)`}}),{c(){I=i("meta"),Wl=p(),E=i("h1"),C=i("a"),ul=i("span"),f(W.$$.fragment),Ue=p(),cl=i("span"),Je=t("Load and explore an audio dataset"),Bl=p(),P=i("p"),Te=t(`In this course we will use the \u{1F917} Datasets library to work with audio datasets. \u{1F917} Datasets is an open-source library for
downloading and preparing datasets from all modalities including audio. The library offers easy access to an unparalleled
selection of machine learning datasets publicly available on Hugging Face Hub. Moreover, \u{1F917} Datasets includes multiple
features tailored to audio datasets that simplify working with such datasets for both researchers and practitioners.`),Ql=p(),L=i("p"),be=t("To begin working with audio datasets, make sure you have the \u{1F917} Datasets library installed:"),Rl=p(),f(B.$$.fragment),Nl=p(),v=i("p"),Ae=t(`One of the key defining features of \u{1F917} Datasets is the ability to download and prepare a dataset in just one line of
Python code using the `),yl=i("code"),Ie=t("load_dataset()"),Ee=t(" function."),Yl=p(),k=i("p"),Ce=t("Let\u2019s load and explore and audio dataset called "),Q=i("a"),ve=t("MINDS-14"),ke=t(`, which contains
recordings of people asking an e-banking system questions in several languages and dialects.`),xl=p(),c=i("p"),_e=t("To load the MINDS-14 dataset, we need to copy the dataset\u2019s identifier on the Hub ("),hl=i("code"),ge=t("PolyAI/minds14"),Ge=t(`) and pass it
to the `),fl=i("code"),$e=t("load_dataset"),qe=t(" function. We\u2019ll also specify that we\u2019re only interested in the Australian subset ("),ml=i("code"),Ze=t("en-AU"),We=t(`) of
the data, and limit it to the training split:`),Fl=p(),f(R.$$.fragment),Sl=p(),K=i("p"),jl=i("strong"),Be=t("Output:"),Dl=p(),f(N.$$.fragment),zl=p(),ll=i("p"),Qe=t(`The dataset contains 654 audio files, each of which is accompanied by a transcription, an English translation, and a label
indicating the intent behind the person\u2019s query. The audio column contains the raw audio data. Let\u2019s take a closer look
at one of the examples:`),Xl=p(),f(Y.$$.fragment),Vl=p(),el=i("p"),wl=i("strong"),Re=t("Output:"),Hl=p(),f(x.$$.fragment),Ol=p(),al=i("p"),Ne=t("You may notice that the audio column contains several features. Here\u2019s what they are:"),Pl=p(),b=i("ul"),_=i("li"),Ul=i("code"),Ye=t("path"),xe=t(": the path to the audio file ("),Jl=i("code"),Fe=t("*.wav"),Se=t(" in this case)."),De=p(),sl=i("li"),Tl=i("code"),ze=t("array"),Xe=t(": The decoded audio data, represented as a 1-dimensional NumPy array."),Ve=p(),tl=i("li"),bl=i("code"),He=t("sampling_rate"),Oe=t(". The sampling rate of the audio file (8,000 Hz in this example)."),Ll=p(),A=i("p"),Pe=t("The "),Al=i("code"),Le=t("intent_class"),Ke=t(` is a classification category of the audio recording. To convert this number into a meaningful string,
we can use the `),Il=i("code"),la=t("int2str()"),ea=t(" method:"),Kl=p(),f(F.$$.fragment),le=p(),nl=i("p"),El=i("strong"),aa=t("Output:"),ee=p(),f(S.$$.fragment),ae=p(),ol=i("p"),sa=t(`If you look at the transcription feature, you can see that the audio file indeed has recorded a person asking a question
about paying a bill.`),se=p(),y=i("p"),ta=t(`If you plan to train an audio classifier on this subset of data, you may not necessarily need all of the features. For example,
the `),Cl=i("code"),na=t("lang_id"),oa=t(" is going to have the same value for all examples, and won\u2019t be useful. The "),vl=i("code"),ia=t("english_transcription"),Ma=t(` will likely
duplicate the `),kl=i("code"),ra=t("transcription"),pa=t(" in this subset, so we can safely remove them."),te=p(),g=i("p"),da=t("You can easily remove irrelevant features using \u{1F917} Datasets\u2019 "),_l=i("code"),ua=t("remove_columns"),ca=t(" method:"),ne=p(),f(D.$$.fragment),oe=p(),il=i("p"),gl=i("strong"),ya=t("Output:"),ie=p(),f(z.$$.fragment),Me=p(),h=i("p"),ha=t("Now that we\u2019ve loaded and inspected the raw contents of the dataset, let\u2019s listen to a few examples! We\u2019ll use the "),Gl=i("code"),fa=t("Blocks"),ma=t(`
and `),$l=i("code"),ja=t("Audio"),wa=t(" features from "),ql=i("code"),Ua=t("Gradio"),Ja=t(" to decode a few random samples from the dataset:"),re=p(),f(X.$$.fragment),pe=p(),Ml=i("p"),Ta=t("If you\u2019d like to, you can also visualize some of the examples. Let\u2019s plot the waveform for the first example."),de=p(),f(V.$$.fragment),ue=p(),H=i("div"),rl=i("img"),ce=p(),G=i("p"),ba=t(`Try it out! Download another dialect or language of the MINDS-14 dataset, listen and visualize some examples to get a sense
of the variation in the whole dataset. You can find the full list of available languages `),O=i("a"),Aa=t("here"),Ia=t("."),this.h()},l(l){const s=fs('[data-svelte="svelte-1phssyn"]',document.head);I=M(s,"META",{name:!0,content:!0}),s.forEach(e),Wl=d(l),E=M(l,"H1",{class:!0});var he=r(E);C=M(he,"A",{id:!0,class:!0,href:!0});var _a=r(C);ul=M(_a,"SPAN",{});var ga=r(ul);m(W.$$.fragment,ga),ga.forEach(e),_a.forEach(e),Ue=d(he),cl=M(he,"SPAN",{});var Ga=r(cl);Je=n(Ga,"Load and explore an audio dataset"),Ga.forEach(e),he.forEach(e),Bl=d(l),P=M(l,"P",{});var $a=r(P);Te=n($a,`In this course we will use the \u{1F917} Datasets library to work with audio datasets. \u{1F917} Datasets is an open-source library for
downloading and preparing datasets from all modalities including audio. The library offers easy access to an unparalleled
selection of machine learning datasets publicly available on Hugging Face Hub. Moreover, \u{1F917} Datasets includes multiple
features tailored to audio datasets that simplify working with such datasets for both researchers and practitioners.`),$a.forEach(e),Ql=d(l),L=M(l,"P",{});var qa=r(L);be=n(qa,"To begin working with audio datasets, make sure you have the \u{1F917} Datasets library installed:"),qa.forEach(e),Rl=d(l),m(B.$$.fragment,l),Nl=d(l),v=M(l,"P",{});var fe=r(v);Ae=n(fe,`One of the key defining features of \u{1F917} Datasets is the ability to download and prepare a dataset in just one line of
Python code using the `),yl=M(fe,"CODE",{});var Za=r(yl);Ie=n(Za,"load_dataset()"),Za.forEach(e),Ee=n(fe," function."),fe.forEach(e),Yl=d(l),k=M(l,"P",{});var me=r(k);Ce=n(me,"Let\u2019s load and explore and audio dataset called "),Q=M(me,"A",{href:!0,rel:!0});var Wa=r(Q);ve=n(Wa,"MINDS-14"),Wa.forEach(e),ke=n(me,`, which contains
recordings of people asking an e-banking system questions in several languages and dialects.`),me.forEach(e),xl=d(l),c=M(l,"P",{});var $=r(c);_e=n($,"To load the MINDS-14 dataset, we need to copy the dataset\u2019s identifier on the Hub ("),hl=M($,"CODE",{});var Ba=r(hl);ge=n(Ba,"PolyAI/minds14"),Ba.forEach(e),Ge=n($,`) and pass it
to the `),fl=M($,"CODE",{});var Qa=r(fl);$e=n(Qa,"load_dataset"),Qa.forEach(e),qe=n($," function. We\u2019ll also specify that we\u2019re only interested in the Australian subset ("),ml=M($,"CODE",{});var Ra=r(ml);Ze=n(Ra,"en-AU"),Ra.forEach(e),We=n($,`) of
the data, and limit it to the training split:`),$.forEach(e),Fl=d(l),m(R.$$.fragment,l),Sl=d(l),K=M(l,"P",{});var Na=r(K);jl=M(Na,"STRONG",{});var Ya=r(jl);Be=n(Ya,"Output:"),Ya.forEach(e),Na.forEach(e),Dl=d(l),m(N.$$.fragment,l),zl=d(l),ll=M(l,"P",{});var xa=r(ll);Qe=n(xa,`The dataset contains 654 audio files, each of which is accompanied by a transcription, an English translation, and a label
indicating the intent behind the person\u2019s query. The audio column contains the raw audio data. Let\u2019s take a closer look
at one of the examples:`),xa.forEach(e),Xl=d(l),m(Y.$$.fragment,l),Vl=d(l),el=M(l,"P",{});var Fa=r(el);wl=M(Fa,"STRONG",{});var Sa=r(wl);Re=n(Sa,"Output:"),Sa.forEach(e),Fa.forEach(e),Hl=d(l),m(x.$$.fragment,l),Ol=d(l),al=M(l,"P",{});var Da=r(al);Ne=n(Da,"You may notice that the audio column contains several features. Here\u2019s what they are:"),Da.forEach(e),Pl=d(l),b=M(l,"UL",{});var pl=r(b);_=M(pl,"LI",{});var Zl=r(_);Ul=M(Zl,"CODE",{});var za=r(Ul);Ye=n(za,"path"),za.forEach(e),xe=n(Zl,": the path to the audio file ("),Jl=M(Zl,"CODE",{});var Xa=r(Jl);Fe=n(Xa,"*.wav"),Xa.forEach(e),Se=n(Zl," in this case)."),Zl.forEach(e),De=d(pl),sl=M(pl,"LI",{});var Ea=r(sl);Tl=M(Ea,"CODE",{});var Va=r(Tl);ze=n(Va,"array"),Va.forEach(e),Xe=n(Ea,": The decoded audio data, represented as a 1-dimensional NumPy array."),Ea.forEach(e),Ve=d(pl),tl=M(pl,"LI",{});var Ca=r(tl);bl=M(Ca,"CODE",{});var Ha=r(bl);He=n(Ha,"sampling_rate"),Ha.forEach(e),Oe=n(Ca,". The sampling rate of the audio file (8,000 Hz in this example)."),Ca.forEach(e),pl.forEach(e),Ll=d(l),A=M(l,"P",{});var dl=r(A);Pe=n(dl,"The "),Al=M(dl,"CODE",{});var Oa=r(Al);Le=n(Oa,"intent_class"),Oa.forEach(e),Ke=n(dl,` is a classification category of the audio recording. To convert this number into a meaningful string,
we can use the `),Il=M(dl,"CODE",{});var Pa=r(Il);la=n(Pa,"int2str()"),Pa.forEach(e),ea=n(dl," method:"),dl.forEach(e),Kl=d(l),m(F.$$.fragment,l),le=d(l),nl=M(l,"P",{});var La=r(nl);El=M(La,"STRONG",{});var Ka=r(El);aa=n(Ka,"Output:"),Ka.forEach(e),La.forEach(e),ee=d(l),m(S.$$.fragment,l),ae=d(l),ol=M(l,"P",{});var ls=r(ol);sa=n(ls,`If you look at the transcription feature, you can see that the audio file indeed has recorded a person asking a question
about paying a bill.`),ls.forEach(e),se=d(l),y=M(l,"P",{});var q=r(y);ta=n(q,`If you plan to train an audio classifier on this subset of data, you may not necessarily need all of the features. For example,
the `),Cl=M(q,"CODE",{});var es=r(Cl);na=n(es,"lang_id"),es.forEach(e),oa=n(q," is going to have the same value for all examples, and won\u2019t be useful. The "),vl=M(q,"CODE",{});var as=r(vl);ia=n(as,"english_transcription"),as.forEach(e),Ma=n(q,` will likely
duplicate the `),kl=M(q,"CODE",{});var ss=r(kl);ra=n(ss,"transcription"),ss.forEach(e),pa=n(q," in this subset, so we can safely remove them."),q.forEach(e),te=d(l),g=M(l,"P",{});var je=r(g);da=n(je,"You can easily remove irrelevant features using \u{1F917} Datasets\u2019 "),_l=M(je,"CODE",{});var ts=r(_l);ua=n(ts,"remove_columns"),ts.forEach(e),ca=n(je," method:"),je.forEach(e),ne=d(l),m(D.$$.fragment,l),oe=d(l),il=M(l,"P",{});var ns=r(il);gl=M(ns,"STRONG",{});var os=r(gl);ya=n(os,"Output:"),os.forEach(e),ns.forEach(e),ie=d(l),m(z.$$.fragment,l),Me=d(l),h=M(l,"P",{});var Z=r(h);ha=n(Z,"Now that we\u2019ve loaded and inspected the raw contents of the dataset, let\u2019s listen to a few examples! We\u2019ll use the "),Gl=M(Z,"CODE",{});var is=r(Gl);fa=n(is,"Blocks"),is.forEach(e),ma=n(Z,`
and `),$l=M(Z,"CODE",{});var Ms=r($l);ja=n(Ms,"Audio"),Ms.forEach(e),wa=n(Z," features from "),ql=M(Z,"CODE",{});var rs=r(ql);Ua=n(rs,"Gradio"),rs.forEach(e),Ja=n(Z," to decode a few random samples from the dataset:"),Z.forEach(e),re=d(l),m(X.$$.fragment,l),pe=d(l),Ml=M(l,"P",{});var ps=r(Ml);Ta=n(ps,"If you\u2019d like to, you can also visualize some of the examples. Let\u2019s plot the waveform for the first example."),ps.forEach(e),de=d(l),m(V.$$.fragment,l),ue=d(l),H=M(l,"DIV",{class:!0});var ds=r(H);rl=M(ds,"IMG",{src:!0,alt:!0}),ds.forEach(e),ce=d(l),G=M(l,"P",{});var we=r(G);ba=n(we,`Try it out! Download another dialect or language of the MINDS-14 dataset, listen and visualize some examples to get a sense
of the variation in the whole dataset. You can find the full list of available languages `),O=M(we,"A",{href:!0,rel:!0});var us=r(O);Aa=n(us,"here"),us.forEach(e),Ia=n(we,"."),we.forEach(e),this.h()},h(){u(I,"name","hf:doc:metadata"),u(I,"content",JSON.stringify(Ts)),u(C,"id","load-and-explore-an-audio-dataset"),u(C,"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"),u(C,"href","#load-and-explore-an-audio-dataset"),u(E,"class","relative group"),u(Q,"href","https://huggingface.co/datasets/PolyAI/minds14"),u(Q,"rel","nofollow"),ms(rl.src,ka="https://huggingface.co/datasets/huggingface-course/audio-course-images/resolve/main/waveform_unit1.png")||u(rl,"src",ka),u(rl,"alt","Waveform plot"),u(H,"class","flex justify-center"),u(O,"href","https://huggingface.co/datasets/PolyAI/minds14"),u(O,"rel","nofollow")},m(l,s){a(document.head,I),o(l,Wl,s),o(l,E,s),a(E,C),a(C,ul),j(W,ul,null),a(E,Ue),a(E,cl),a(cl,Je),o(l,Bl,s),o(l,P,s),a(P,Te),o(l,Ql,s),o(l,L,s),a(L,be),o(l,Rl,s),j(B,l,s),o(l,Nl,s),o(l,v,s),a(v,Ae),a(v,yl),a(yl,Ie),a(v,Ee),o(l,Yl,s),o(l,k,s),a(k,Ce),a(k,Q),a(Q,ve),a(k,ke),o(l,xl,s),o(l,c,s),a(c,_e),a(c,hl),a(hl,ge),a(c,Ge),a(c,fl),a(fl,$e),a(c,qe),a(c,ml),a(ml,Ze),a(c,We),o(l,Fl,s),j(R,l,s),o(l,Sl,s),o(l,K,s),a(K,jl),a(jl,Be),o(l,Dl,s),j(N,l,s),o(l,zl,s),o(l,ll,s),a(ll,Qe),o(l,Xl,s),j(Y,l,s),o(l,Vl,s),o(l,el,s),a(el,wl),a(wl,Re),o(l,Hl,s),j(x,l,s),o(l,Ol,s),o(l,al,s),a(al,Ne),o(l,Pl,s),o(l,b,s),a(b,_),a(_,Ul),a(Ul,Ye),a(_,xe),a(_,Jl),a(Jl,Fe),a(_,Se),a(b,De),a(b,sl),a(sl,Tl),a(Tl,ze),a(sl,Xe),a(b,Ve),a(b,tl),a(tl,bl),a(bl,He),a(tl,Oe),o(l,Ll,s),o(l,A,s),a(A,Pe),a(A,Al),a(Al,Le),a(A,Ke),a(A,Il),a(Il,la),a(A,ea),o(l,Kl,s),j(F,l,s),o(l,le,s),o(l,nl,s),a(nl,El),a(El,aa),o(l,ee,s),j(S,l,s),o(l,ae,s),o(l,ol,s),a(ol,sa),o(l,se,s),o(l,y,s),a(y,ta),a(y,Cl),a(Cl,na),a(y,oa),a(y,vl),a(vl,ia),a(y,Ma),a(y,kl),a(kl,ra),a(y,pa),o(l,te,s),o(l,g,s),a(g,da),a(g,_l),a(_l,ua),a(g,ca),o(l,ne,s),j(D,l,s),o(l,oe,s),o(l,il,s),a(il,gl),a(gl,ya),o(l,ie,s),j(z,l,s),o(l,Me,s),o(l,h,s),a(h,ha),a(h,Gl),a(Gl,fa),a(h,ma),a(h,$l),a($l,ja),a(h,wa),a(h,ql),a(ql,Ua),a(h,Ja),o(l,re,s),j(X,l,s),o(l,pe,s),o(l,Ml,s),a(Ml,Ta),o(l,de,s),j(V,l,s),o(l,ue,s),o(l,H,s),a(H,rl),o(l,ce,s),o(l,G,s),a(G,ba),a(G,O),a(O,Aa),a(G,Ia),ye=!0},p:js,i(l){ye||(w(W.$$.fragment,l),w(B.$$.fragment,l),w(R.$$.fragment,l),w(N.$$.fragment,l),w(Y.$$.fragment,l),w(x.$$.fragment,l),w(F.$$.fragment,l),w(S.$$.fragment,l),w(D.$$.fragment,l),w(z.$$.fragment,l),w(X.$$.fragment,l),w(V.$$.fragment,l),ye=!0)},o(l){U(W.$$.fragment,l),U(B.$$.fragment,l),U(R.$$.fragment,l),U(N.$$.fragment,l),U(Y.$$.fragment,l),U(x.$$.fragment,l),U(F.$$.fragment,l),U(S.$$.fragment,l),U(D.$$.fragment,l),U(z.$$.fragment,l),U(X.$$.fragment,l),U(V.$$.fragment,l),ye=!1},d(l){e(I),l&&e(Wl),l&&e(E),J(W),l&&e(Bl),l&&e(P),l&&e(Ql),l&&e(L),l&&e(Rl),J(B,l),l&&e(Nl),l&&e(v),l&&e(Yl),l&&e(k),l&&e(xl),l&&e(c),l&&e(Fl),J(R,l),l&&e(Sl),l&&e(K),l&&e(Dl),J(N,l),l&&e(zl),l&&e(ll),l&&e(Xl),J(Y,l),l&&e(Vl),l&&e(el),l&&e(Hl),J(x,l),l&&e(Ol),l&&e(al),l&&e(Pl),l&&e(b),l&&e(Ll),l&&e(A),l&&e(Kl),J(F,l),l&&e(le),l&&e(nl),l&&e(ee),J(S,l),l&&e(ae),l&&e(ol),l&&e(se),l&&e(y),l&&e(te),l&&e(g),l&&e(ne),J(D,l),l&&e(oe),l&&e(il),l&&e(ie),J(z,l),l&&e(Me),l&&e(h),l&&e(re),J(X,l),l&&e(pe),l&&e(Ml),l&&e(de),J(V,l),l&&e(ue),l&&e(H),l&&e(ce),l&&e(G)}}}const Ts={local:"load-and-explore-an-audio-dataset",title:"Load and explore an audio dataset"};function bs(va){return ws(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Cs extends cs{constructor(I){super();ys(this,I,bs,Js,hs,{})}}export{Cs as default,Ts as metadata};
