import{s as gs,n as qs,o as fs}from"../chunks/scheduler.f7e1785c.js";import{S as Es,i as Ss,g as n,s as a,r as b,A as bs,h as y,f as l,c as e,j as ds,u as Q,x as U,k as ms,y as Qs,a as t,v as D,d as B,t as N,w as k}from"../chunks/index.9f8f0838.js";import{C as V}from"../chunks/CodeBlock.b3510e34.js";import{H as Ds}from"../chunks/Heading.6643a2f7.js";function Bs(Us){let o,Z,v,_,T,z,J,os=`One of the biggest challenges faced with audio datasets is their sheer size. A single minute of uncompressed CD-quality audio (44.1kHz, 16-bit)
takes up  a bit more than 5 MB of storage. Typically, an audio dataset would contains hours of recordings.`,R,i,Ts=`In the previous sections we used a very small subset of MINDS-14 audio dataset, however, typical audio datasets are much larger.
For example, the <code>xs</code> (smallest) configuration of <a href="https://huggingface.co/datasets/speechcolab/gigaspeech" rel="nofollow">GigaSpeech from SpeechColab</a>
contains only 10 hours of training data, but takes over 13GB of storage space for download and preparation. So what
happens when we want to train on a larger split? The full <code>xl</code> configuration of the same dataset contains 10,000 hours of
training data, requiring over 1TB of storage space. For most of us, this well exceeds the specifications of a typical
hard drive disk. Do we need to fork out and buy additional storage? Or is there a way we can train on these datasets with no disk space constraints?`,F,w,Js=`🤗 Datasets comes to the rescue by offering the <a href="https://huggingface.co/docs/datasets/stream" rel="nofollow">streaming mode</a>. Streaming allows us to load the data progressively as
we iterate over the dataset. Rather than downloading the whole dataset at once, we load the dataset one example at a time.
We iterate over the dataset, loading and preparing examples on the fly when they are needed. This way, we only ever
load the examples that we’re using, and not the ones that we’re not!
Once we’re done with an example sample, we continue iterating over the dataset and load the next one.`,W,C,is="Streaming mode has three primary advantages over downloading the entire dataset at once:",Y,j,ws=`<li>Disk space: examples are loaded to memory one-by-one as we iterate over the dataset. Since the data is not downloaded
locally, there are no disk space requirements, so you can use datasets of arbitrary size.</li> <li>Download and processing time: audio datasets are large and need a significant amount of time to download and process.
With streaming, loading and processing is done on the fly, meaning you can start using the dataset as soon as the first
example is ready.</li> <li>Easy experimentation: you can experiment on a handful of examples to check that your script works without having to
download the entire dataset.</li>`,G,p,Cs=`There is one caveat to streaming mode. When downloading a full dataset without streaming, both the raw data and processed
data are saved locally to disk. If we want to re-use this dataset, we can directly load the processed data from disk,
skipping the download and processing steps.  Consequently, we only have to perform the downloading and processing
operations once, after which we can re-use the prepared data.`,X,u,js=`With streaming mode, the data is not downloaded to disk. Thus, neither the downloaded nor pre-processed data are cached.
If we want to re-use the dataset, the streaming steps must be repeated, with the audio files loaded and processed on
the fly again. For this reason, it is advised to download datasets that you are likely to use multiple times.`,L,r,ps=`How can you enable streaming mode? Easy! Just set <code>streaming=True</code> when you load your dataset. The rest will be taken
care for you:`,$,I,O,A,us=`Just like we applied preprocessing steps to a downloaded subset of MINDS-14, you can do the same preprocessing with a
streaming dataset in the exactly the same manner.`,H,h,rs=`The only difference is that you can no longer access individual samples using Python indexing (i.e. <code>gigaspeech[&quot;train&quot;][sample_idx]</code>).
Instead, you have to iterate over the dataset. Here’s how you can access an example when streaming a dataset:`,P,c,K,d,Is="<strong>Output:</strong>",ss,m,Ms,g,As=`If you’d like to preview several examples from a large dataset, use the <code>take()</code> to get the first n elements. Let’s grab
the first two examples in the gigaspeech dataset:`,ls,q,ts,f,hs="<strong>Output:</strong>",as,E,es,S,cs=`Streaming mode can take your research to the next level: not only are the biggest datasets accessible to you, but you
can easily evaluate systems over multiple datasets in one go without worrying about your disk space. Compared to
evaluating on a single dataset, multi-dataset evaluation gives a better metric for the generalisation abilities of a
speech recognition system (c.f. End-to-end Speech Benchmark (ESB)).`,ns,x,ys;return T=new Ds({props:{title:"Streaming audio data",local:"streaming-audio-data",headingTag:"h1"}}),I=new V({props:{code:"Z2lnYXNwZWVjaCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJzcGVlY2hjb2xhYiUyRmdpZ2FzcGVlY2glMjIlMkMlMjAlMjJ4cyUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUp",highlighted:'gigaspeech = load_dataset(<span class="hljs-string">&quot;speechcolab/gigaspeech&quot;</span>, <span class="hljs-string">&quot;xs&quot;</span>, streaming=<span class="hljs-literal">True</span>)',wrap:!1}}),c=new V({props:{code:"bmV4dChpdGVyKGdpZ2FzcGVlY2glNUIlMjJ0cmFpbiUyMiU1RCkp",highlighted:'<span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(gigaspeech[<span class="hljs-string">&quot;train&quot;</span>]))',wrap:!1}}),m=new V({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyc2VnbWVudF9pZCUyMiUzQSUyMCUyMllPVTAwMDAwMDAzMTVfUzAwMDA2NjAlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJzcGVha2VyJTIyJTNBJTIwJTIyTiUyRkElMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJ0ZXh0JTIyJTNBJTIwJTIyQVMlMjBUSEVZJ1JFJTIwTEVBVklORyUyMCUzQ0NPTU1BJTNFJTIwQ0FOJTIwS0FTSCUyMFBVTEwlMjBaQUhSQSUyMEFTSURFJTIwUkVBTExZJTIwUVVJQ0tMWSUyMCUzQ1FVRVNUSU9OTUFSSyUzRSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMmF1ZGlvJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycGF0aCUyMiUzQSUyMCUyMnhzX2NodW5rc18wMDAwJTJGWU9VMDAwMDAwMDMxNV9TMDAwMDY2MC53YXYlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJhcnJheSUyMiUzQSUyMGFycmF5KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1QjAuMDAwNTE4OCUyQyUyMDAuMDAwODU0NDklMkMlMjAwLjAwMDEyMjA3JTJDJTIwLi4uJTJDJTIwMC4wMDEyNTEyMiUyQyUyMDAuMDAwNzYyOTQlMkMlMjAwLjAwMDM2NjIxJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnNhbXBsaW5nX3JhdGUlMjIlM0ElMjAxNjAwMCUyQyUwQSUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMmJlZ2luX3RpbWUlMjIlM0ElMjAyOTQxLjg5JTJDJTBBJTIwJTIwJTIwJTIwJTIyZW5kX3RpbWUlMjIlM0ElMjAyOTQ1LjA3JTJDJTBBJTIwJTIwJTIwJTIwJTIyYXVkaW9faWQlMjIlM0ElMjAlMjJZT1UwMDAwMDAwMzE1JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIydGl0bGUlMjIlM0ElMjAlMjJSZXR1cm4lMjB0byUyMFZhc3NlbGhlaW0lMjAlN0MlMjBDcml0aWNhbCUyMFJvbGUlM0ElMjBWT1glMjBNQUNISU5BJTIwJTdDJTIwRXBpc29kZSUyMDQzJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIydXJsJTIyJTNBJTIwJTIyaHR0cHMlM0ElMkYlMkZ3d3cueW91dHViZS5jb20lMkZ3YXRjaCUzRnYlM0R6cjJuMWZMVmFzVSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMnNvdXJjZSUyMiUzQSUyMDIlMkMlMEElMjAlMjAlMjAlMjAlMjJjYXRlZ29yeSUyMiUzQSUyMDI0JTJDJTBBJTIwJTIwJTIwJTIwJTIyb3JpZ2luYWxfZnVsbF9wYXRoJTIyJTNBJTIwJTIyYXVkaW8lMkZ5b3V0dWJlJTJGUDAwMDQlMkZZT1UwMDAwMDAwMzE1Lm9wdXMlMjIlMkMlMEElN0Q=",highlighted:`{
    <span class="hljs-string">&quot;segment_id&quot;</span>: <span class="hljs-string">&quot;YOU0000000315_S0000660&quot;</span>,
    <span class="hljs-string">&quot;speaker&quot;</span>: <span class="hljs-string">&quot;N/A&quot;</span>,
    <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;AS THEY&#x27;RE LEAVING &lt;COMMA&gt; CAN KASH PULL ZAHRA ASIDE REALLY QUICKLY &lt;QUESTIONMARK&gt;&quot;</span>,
    <span class="hljs-string">&quot;audio&quot;</span>: {
        <span class="hljs-string">&quot;path&quot;</span>: <span class="hljs-string">&quot;xs_chunks_0000/YOU0000000315_S0000660.wav&quot;</span>,
        <span class="hljs-string">&quot;array&quot;</span>: <span class="hljs-built_in">array</span>(
            <span class="hljs-selector-attr">[0.0005188, 0.00085449, 0.00012207, ..., 0.00125122, 0.00076294, 0.00036621]</span>
        ),
        <span class="hljs-string">&quot;sampling_rate&quot;</span>: <span class="hljs-number">16000</span>,
    },
    <span class="hljs-string">&quot;begin_time&quot;</span>: <span class="hljs-number">2941.89</span>,
    <span class="hljs-string">&quot;end_time&quot;</span>: <span class="hljs-number">2945.07</span>,
    <span class="hljs-string">&quot;audio_id&quot;</span>: <span class="hljs-string">&quot;YOU0000000315&quot;</span>,
    <span class="hljs-string">&quot;title&quot;</span>: <span class="hljs-string">&quot;Return to Vasselheim | Critical Role: VOX MACHINA | Episode 43&quot;</span>,
    <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;https://www.youtube.com/watch?v=zr2n1fLVasU&quot;</span>,
    <span class="hljs-string">&quot;source&quot;</span>: <span class="hljs-number">2</span>,
    <span class="hljs-string">&quot;category&quot;</span>: <span class="hljs-number">24</span>,
    <span class="hljs-string">&quot;original_full_path&quot;</span>: <span class="hljs-string">&quot;audio/youtube/P0004/YOU0000000315.opus&quot;</span>,
}`,wrap:!1}}),q=new V({props:{code:"Z2lnYXNwZWVjaF9oZWFkJTIwJTNEJTIwZ2lnYXNwZWVjaCU1QiUyMnRyYWluJTIyJTVELnRha2UoMiklMEFsaXN0KGdpZ2FzcGVlY2hfaGVhZCk=",highlighted:`gigaspeech_head = gigaspeech[<span class="hljs-string">&quot;train&quot;</span>].take(<span class="hljs-number">2</span>)
<span class="hljs-built_in">list</span>(gigaspeech_head)`,wrap:!1}}),E=new V({props:{code:" ",highlighted:`[
    {
        <span class="hljs-string">&quot;segment_id&quot;</span>: <span class="hljs-string">&quot;YOU0000000315_S0000660&quot;</span>,
        <span class="hljs-string">&quot;speaker&quot;</span>: <span class="hljs-string">&quot;N/A&quot;</span>,
        <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;AS THEY&#x27;RE LEAVING &lt;COMMA&gt; CAN KASH PULL ZAHRA ASIDE REALLY QUICKLY &lt;QUESTIONMARK&gt;&quot;</span>,
        <span class="hljs-string">&quot;audio&quot;</span>: {
            <span class="hljs-string">&quot;path&quot;</span>: <span class="hljs-string">&quot;xs_chunks_0000/YOU0000000315_S0000660.wav&quot;</span>,
            <span class="hljs-string">&quot;array&quot;</span>: array(
                [
                    <span class="hljs-number">0.0005188</span>,
                    <span class="hljs-number">0.00085449</span>,
                    <span class="hljs-number">0.00012207</span>,
                    ...,
                    <span class="hljs-number">0.00125122</span>,
                    <span class="hljs-number">0.00076294</span>,
                    <span class="hljs-number">0.00036621</span>,
                ]
            ),
            <span class="hljs-string">&quot;sampling_rate&quot;</span>: <span class="hljs-number">16000</span>,
        },
        <span class="hljs-string">&quot;begin_time&quot;</span>: <span class="hljs-number">2941.89</span>,
        <span class="hljs-string">&quot;end_time&quot;</span>: <span class="hljs-number">2945.07</span>,
        <span class="hljs-string">&quot;audio_id&quot;</span>: <span class="hljs-string">&quot;YOU0000000315&quot;</span>,
        <span class="hljs-string">&quot;title&quot;</span>: <span class="hljs-string">&quot;Return to Vasselheim | Critical Role: VOX MACHINA | Episode 43&quot;</span>,
        <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;https://www.youtube.com/watch?v=zr2n1fLVasU&quot;</span>,
        <span class="hljs-string">&quot;source&quot;</span>: <span class="hljs-number">2</span>,
        <span class="hljs-string">&quot;category&quot;</span>: <span class="hljs-number">24</span>,
        <span class="hljs-string">&quot;original_full_path&quot;</span>: <span class="hljs-string">&quot;audio/youtube/P0004/YOU0000000315.opus&quot;</span>,
    },
    {
        <span class="hljs-string">&quot;segment_id&quot;</span>: <span class="hljs-string">&quot;AUD0000001043_S0000775&quot;</span>,
        <span class="hljs-string">&quot;speaker&quot;</span>: <span class="hljs-string">&quot;N/A&quot;</span>,
        <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;SIX TOMATOES &lt;PERIOD&gt;&quot;</span>,
        <span class="hljs-string">&quot;audio&quot;</span>: {
            <span class="hljs-string">&quot;path&quot;</span>: <span class="hljs-string">&quot;xs_chunks_0000/AUD0000001043_S0000775.wav&quot;</span>,
            <span class="hljs-string">&quot;array&quot;</span>: array(
                [
                    <span class="hljs-number">1.43432617</span>e-03,
                    <span class="hljs-number">1.37329102</span>e-03,
                    <span class="hljs-number">1.31225586</span>e-03,
                    ...,
                    <span class="hljs-number">-6.10351562</span>e-05,
                    <span class="hljs-number">-1.22070312</span>e-04,
                    <span class="hljs-number">-1.83105469</span>e-04,
                ]
            ),
            <span class="hljs-string">&quot;sampling_rate&quot;</span>: <span class="hljs-number">16000</span>,
        },
        <span class="hljs-string">&quot;begin_time&quot;</span>: <span class="hljs-number">3673.96</span>,
        <span class="hljs-string">&quot;end_time&quot;</span>: <span class="hljs-number">3675.26</span>,
        <span class="hljs-string">&quot;audio_id&quot;</span>: <span class="hljs-string">&quot;AUD0000001043&quot;</span>,
        <span class="hljs-string">&quot;title&quot;</span>: <span class="hljs-string">&quot;Asteroid of Fear&quot;</span>,
        <span class="hljs-string">&quot;url&quot;</span>: <span class="hljs-string">&quot;http//www.archive.org/download/asteroid_of_fear_1012_librivox/asteroid_of_fear_1012_librivox_64kb_mp3.zip&quot;</span>,
        <span class="hljs-string">&quot;source&quot;</span>: <span class="hljs-number">0</span>,
        <span class="hljs-string">&quot;category&quot;</span>: <span class="hljs-number">28</span>,
        <span class="hljs-string">&quot;original_full_path&quot;</span>: <span class="hljs-string">&quot;audio/audiobook/P0011/AUD0000001043.opus&quot;</span>,
    },
]`,wrap:!1}}),{c(){o=n("meta"),Z=a(),v=n("p"),_=a(),b(T.$$.fragment),z=a(),J=n("p"),J.textContent=os,R=a(),i=n("p"),i.innerHTML=Ts,F=a(),w=n("p"),w.innerHTML=Js,W=a(),C=n("p"),C.textContent=is,Y=a(),j=n("ul"),j.innerHTML=ws,G=a(),p=n("p"),p.textContent=Cs,X=a(),u=n("p"),u.textContent=js,L=a(),r=n("p"),r.innerHTML=ps,$=a(),b(I.$$.fragment),O=a(),A=n("p"),A.textContent=us,H=a(),h=n("p"),h.innerHTML=rs,P=a(),b(c.$$.fragment),K=a(),d=n("p"),d.innerHTML=Is,ss=a(),b(m.$$.fragment),Ms=a(),g=n("p"),g.innerHTML=As,ls=a(),b(q.$$.fragment),ts=a(),f=n("p"),f.innerHTML=hs,as=a(),b(E.$$.fragment),es=a(),S=n("p"),S.textContent=cs,ns=a(),x=n("p"),this.h()},l(s){const M=bs("svelte-u9bgzb",document.head);o=y(M,"META",{name:!0,content:!0}),M.forEach(l),Z=e(s),v=y(s,"P",{}),ds(v).forEach(l),_=e(s),Q(T.$$.fragment,s),z=e(s),J=y(s,"P",{"data-svelte-h":!0}),U(J)!=="svelte-n8v3tf"&&(J.textContent=os),R=e(s),i=y(s,"P",{"data-svelte-h":!0}),U(i)!=="svelte-nayksx"&&(i.innerHTML=Ts),F=e(s),w=y(s,"P",{"data-svelte-h":!0}),U(w)!=="svelte-1cmn14y"&&(w.innerHTML=Js),W=e(s),C=y(s,"P",{"data-svelte-h":!0}),U(C)!=="svelte-1doba0z"&&(C.textContent=is),Y=e(s),j=y(s,"UL",{"data-svelte-h":!0}),U(j)!=="svelte-dy12ia"&&(j.innerHTML=ws),G=e(s),p=y(s,"P",{"data-svelte-h":!0}),U(p)!=="svelte-dhhyuw"&&(p.textContent=Cs),X=e(s),u=y(s,"P",{"data-svelte-h":!0}),U(u)!=="svelte-1b0tiu9"&&(u.textContent=js),L=e(s),r=y(s,"P",{"data-svelte-h":!0}),U(r)!=="svelte-16vl0hj"&&(r.innerHTML=ps),$=e(s),Q(I.$$.fragment,s),O=e(s),A=y(s,"P",{"data-svelte-h":!0}),U(A)!=="svelte-182p0qe"&&(A.textContent=us),H=e(s),h=y(s,"P",{"data-svelte-h":!0}),U(h)!=="svelte-1e6b0ye"&&(h.innerHTML=rs),P=e(s),Q(c.$$.fragment,s),K=e(s),d=y(s,"P",{"data-svelte-h":!0}),U(d)!=="svelte-1mvdyro"&&(d.innerHTML=Is),ss=e(s),Q(m.$$.fragment,s),Ms=e(s),g=y(s,"P",{"data-svelte-h":!0}),U(g)!=="svelte-k3iau9"&&(g.innerHTML=As),ls=e(s),Q(q.$$.fragment,s),ts=e(s),f=y(s,"P",{"data-svelte-h":!0}),U(f)!=="svelte-1mvdyro"&&(f.innerHTML=hs),as=e(s),Q(E.$$.fragment,s),es=e(s),S=y(s,"P",{"data-svelte-h":!0}),U(S)!=="svelte-1jjur40"&&(S.textContent=cs),ns=e(s),x=y(s,"P",{}),ds(x).forEach(l),this.h()},h(){ms(o,"name","hf:doc:metadata"),ms(o,"content",Ns)},m(s,M){Qs(document.head,o),t(s,Z,M),t(s,v,M),t(s,_,M),D(T,s,M),t(s,z,M),t(s,J,M),t(s,R,M),t(s,i,M),t(s,F,M),t(s,w,M),t(s,W,M),t(s,C,M),t(s,Y,M),t(s,j,M),t(s,G,M),t(s,p,M),t(s,X,M),t(s,u,M),t(s,L,M),t(s,r,M),t(s,$,M),D(I,s,M),t(s,O,M),t(s,A,M),t(s,H,M),t(s,h,M),t(s,P,M),D(c,s,M),t(s,K,M),t(s,d,M),t(s,ss,M),D(m,s,M),t(s,Ms,M),t(s,g,M),t(s,ls,M),D(q,s,M),t(s,ts,M),t(s,f,M),t(s,as,M),D(E,s,M),t(s,es,M),t(s,S,M),t(s,ns,M),t(s,x,M),ys=!0},p:qs,i(s){ys||(B(T.$$.fragment,s),B(I.$$.fragment,s),B(c.$$.fragment,s),B(m.$$.fragment,s),B(q.$$.fragment,s),B(E.$$.fragment,s),ys=!0)},o(s){N(T.$$.fragment,s),N(I.$$.fragment,s),N(c.$$.fragment,s),N(m.$$.fragment,s),N(q.$$.fragment,s),N(E.$$.fragment,s),ys=!1},d(s){s&&(l(Z),l(v),l(_),l(z),l(J),l(R),l(i),l(F),l(w),l(W),l(C),l(Y),l(j),l(G),l(p),l(X),l(u),l(L),l(r),l($),l(O),l(A),l(H),l(h),l(P),l(K),l(d),l(ss),l(Ms),l(g),l(ls),l(ts),l(f),l(as),l(es),l(S),l(ns),l(x)),l(o),k(T,s),k(I,s),k(c,s),k(m,s),k(q,s),k(E,s)}}}const Ns='{"title":"Streaming audio data","local":"streaming-audio-data","sections":[],"depth":1}';function ks(Us){return fs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class _s extends Es{constructor(o){super(),Ss(this,o,ks,Bs,gs,{})}}export{_s as component};
