import{s as Zt,o as kt,n as xt}from"../chunks/scheduler.cd324960.js";import{S as Wt,i as St,e as i,s as n,c as p,h as vt,a as o,d as l,b as a,f as Gt,g as r,j as h,k as nt,l as Qt,m as s,n as M,t as y,o as m,p as J,q as Bt,r as $t}from"../chunks/index.d5c3adcc.js";import{T as Nt}from"../chunks/Tip.889bec11.js";import{C as At,H as st,E as Rt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.92ea4747.js";import{C as w}from"../chunks/CodeBlock.bef85339.js";function Xt(Je){let U,T,I="ASRDiarizationPipeline",u,c,g="<code>pipeline = ASRDiarizationPipeline.from_pretrained(&quot;openai/whisper-base&quot;)</code>";return{c(){U=Bt("You can also instantiate the "),T=i("code"),T.textContent=I,u=Bt(` directly from pre-trained by specifying the model id
    of an ASR model on the Hub:
    `),c=i("p"),c.innerHTML=g},l(d){U=$t(d,"You can also instantiate the "),T=o(d,"CODE",{"data-svelte-h":!0}),h(T)!=="svelte-1613cio"&&(T.textContent=I),u=$t(d,` directly from pre-trained by specifying the model id
    of an ASR model on the Hub:
    `),c=o(d,"P",{"data-svelte-h":!0}),h(c)!=="svelte-k598fh"&&(c.innerHTML=g)},m(d,f){s(d,U,f),s(d,T,f),s(d,u,f),s(d,c,f)},p:xt,d(d){d&&(l(U),l(T),l(u),l(c))}}}function Ht(Je){let U,T,I,u,c,g,d,f,C,at=`In this final section, we’ll use the Whisper model to generate a transcription for a conversation or meeting between
two or more speakers. We’ll then pair it with a <em>speaker diarization</em> model to predict “who spoke when”. By matching
the timestamps from the Whisper transcriptions with the timestamps from the speaker diarization model, we can predict an
end-to-end meeting transcription with fully formatted start / end times for each speaker. This is a basic version of
the meeting transcription services you might have seen online from the likes of <a href="https://otter.ai" rel="nofollow">Otter.ai</a> and co:`,he,b,it='<img src="https://huggingface.co/datasets/huggingface-course/audio-course-images/resolve/main/diarization_transcription.png"/>',de,G,we,B,ot=`Speaker diarization (or diarisation) is the task of taking an unlabelled audio input and predicting “who spoke when”.
In doing so, we can predict start / end timestamps for each speaker turn, corresponding to when each speaker starts
speaking and when they finish.`,ce,$,pt=`🤗 Transformers currently does not have a model for speaker diarization included in the library, but there are checkpoints
on the Hub that can be used with relative ease. In this example, we’ll use the pre-trained speaker diarization model from
<a href="https://github.com/pyannote/pyannote-audio" rel="nofollow">pyannote.audio</a>. Let’s get started and pip install the package:`,Ue,Z,Te,k,rt=`Great! The weights for this model are hosted on the Hugging Face Hub. To access them, we first have to agree to the speaker diarization model’s
terms of use: <a href="https://huggingface.co/pyannote/speaker-diarization" rel="nofollow">pyannote/speaker-diarization</a>. And subsequently the
segmentation model’s terms of use: <a href="https://huggingface.co/pyannote/segmentation" rel="nofollow">pyannote/segmentation</a>.`,ue,x,Mt="Once complete, we can load the pre-trained speaker diarization pipeline locally on our device:",fe,W,Ie,S,yt=`Let’s try it out on a sample audio file! For this, we’ll load a sample of the <a href="https://huggingface.co/datasets/librispeech_asr" rel="nofollow">LibriSpeech ASR</a>
dataset that consists of two different speakers that have been concatenated together to give a single audio file:`,be,v,je,Q,mt="We can listen to the audio to see what it sounds like:",ge,N,Ce,A,Jt=`Cool! We can clearly hear two different speakers, with a transition roughly 15s of the way through. Let’s pass this audio
file to the diarization model to get the speaker start / end times. Note that pyannote.audio expects the audio input to be a
PyTorch tensor of shape <code>(channels, seq_len)</code>, so we need to perform this conversion prior to running the model:`,Ge,R,Be,X,$e,H,ht=`This looks pretty good! We can see that the first speaker is predicted as speaking up until the 14.5 second mark, and the
second speaker from 15.4s onwards. Now we need to get our transcription!`,Ze,E,ke,V,dt=`For the third time in this Unit, we’ll use the Whisper model for our speech transcription system. Specifically, we’ll load the
<a href="https://huggingface.co/openai/whisper-base" rel="nofollow">Whisper Base</a> checkpoint, since it’s small enough to give good
inference speed with reasonable transcription accuracy. As before, feel free to use any speech recognition checkpoint
on <a href="https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&amp;library=transformers&amp;sort=trending" rel="nofollow">the Hub</a>,
including Wav2Vec2, MMS ASR or other Whisper checkpoints:`,xe,q,We,z,wt=`Let’s get the transcription for our sample audio, returning the segment level timestamps as well so that we know the
start / end times for each segment. You’ll remember from Unit 5 that we need to pass the argument
<code>return_timestamps=True</code> to activate the timestamp prediction task for Whisper:`,Se,_,ve,F,Qe,Y,ct=`Alright! We see that each segment of the transcript has a start and end time, with the speakers changing at the 15.48 second
mark. We can now pair this transcription with the speaker timestamps that we got from our diarization model to get our
final transcription.`,Ne,D,Ae,L,Ut=`To get the final transcription, we’ll align the timestamps from the diarization model with those from the Whisper model.
The diarization model predicted the first speaker to end at 14.5 seconds, and the second speaker to start at 15.4s, whereas Whisper predicted segment boundaries at
13.88, 15.48 and 19.44 seconds respectively. Since the timestamps from Whisper don’t match perfectly with those from the
diarization model, we need to find which of these boundaries are closest to 14.5 and 15.4 seconds, and segment the transcription by
speakers accordingly. Specifically, we’ll find the closest alignment between diarization and transcription timestamps by
minimising the absolute distance between both.`,Re,P,Tt=`Luckily for us, we can use the 🤗 Speechbox package to perform this alignment. First, let’s pip install <code>speechbox</code> from
main:`,Xe,K,He,O,ut=`We can now instantiate our combined diarization plus transcription pipeline, by passing the diarization model and
ASR model to the <a href="https://github.com/huggingface/speechbox/tree/main#asr-with-speaker-diarization" rel="nofollow"><code>ASRDiarizationPipeline</code></a> class:`,Ee,ee,Ve,j,qe,te,ft="Let’s pass the audio file to the composite pipeline and see what we get out:",ze,le,_e,se,Fe,ne,It=`Excellent! The first speaker is segmented as speaking from 0 to 15.48 seconds, and the second speaker from 15.48 to 21.28 seconds,
with the corresponding transcriptions for each.`,Ye,ae,bt=`We can format the timestamps a little more nicely by defining two helper functions. The first converts a tuple of
timestamps to a string, rounded to a set number of decimal places. The second combines the speaker id, timestamp and text
information onto one line, and splits each speaker onto their own line for ease of reading:`,De,ie,Le,oe,jt="Let’s re-run the pipeline, this time formatting the transcription according to the function we’ve just defined:",Pe,pe,Ke,re,Oe,Me,gt=`There we go! With that, we’ve both diarized and transcribe our input audio and returned speaker-segmented transcriptions.
While the minimum distance algoirthm to align the diarized timestamps and transcribed timestamps is simple, it
works well in practice. If you want to explore more advanced methods for combining the timestamps, the
source code for the <code>ASRDiarizationPipeline</code> is a good place to start: <a href="https://github.com/huggingface/speechbox/blob/96d2d1a180252d92263f862a1cd25a48860f1aed/src/speechbox/diarize.py#L12" rel="nofollow">speechbox/diarize.py</a>`,et,ye,tt,me,lt;return c=new At({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),d=new st({props:{title:"Transcribe a meeting",local:"transcribe-a-meeting",headingTag:"h1"}}),G=new st({props:{title:"Speaker Diarization",local:"speaker-diarization",headingTag:"h2"}}),Z=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHB5YW5ub3RlLmF1ZGlv",highlighted:"pip install --upgrade pyannote.audio",wrap:!1}}),W=new w({props:{code:"ZnJvbSUyMHB5YW5ub3RlLmF1ZGlvJTIwaW1wb3J0JTIwUGlwZWxpbmUlMEElMEFkaWFyaXphdGlvbl9waXBlbGluZSUyMCUzRCUyMFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJweWFubm90ZSUyRnNwZWFrZXItZGlhcml6YXRpb24lNDAyLjElMjIlMkMlMjB1c2VfYXV0aF90b2tlbiUzRFRydWUlMEEp",highlighted:`<span class="hljs-keyword">from</span> pyannote.audio <span class="hljs-keyword">import</span> Pipeline

diarization_pipeline = Pipeline.from_pretrained(
    <span class="hljs-string">&quot;pyannote/speaker-diarization@2.1&quot;</span>, use_auth_token=<span class="hljs-literal">True</span>
)`,wrap:!1}}),v=new w({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBY29uY2F0ZW5hdGVkX2xpYnJpc3BlZWNoJTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMCUyMnNhbmNoaXQtZ2FuZGhpJTJGY29uY2F0ZW5hdGVkX2xpYnJpc3BlZWNoJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiUyMiUyQyUyMHN0cmVhbWluZyUzRFRydWUlMEEpJTBBc2FtcGxlJTIwJTNEJTIwbmV4dChpdGVyKGNvbmNhdGVuYXRlZF9saWJyaXNwZWVjaCkp",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

concatenated_librispeech = load_dataset(
    <span class="hljs-string">&quot;sanchit-gandhi/concatenated_librispeech&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>, streaming=<span class="hljs-literal">True</span>
)
sample = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(concatenated_librispeech))`,wrap:!1}}),N=new w({props:{code:"ZnJvbSUyMElQeXRob24uZGlzcGxheSUyMGltcG9ydCUyMEF1ZGlvJTBBJTBBQXVkaW8oc2FtcGxlJTVCJTIyYXVkaW8lMjIlNUQlNUIlMjJhcnJheSUyMiU1RCUyQyUyMHJhdGUlM0RzYW1wbGUlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMnNhbXBsaW5nX3JhdGUlMjIlNUQp",highlighted:`<span class="hljs-keyword">from</span> IPython.display <span class="hljs-keyword">import</span> Audio

Audio(sample[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>], rate=sample[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;sampling_rate&quot;</span>])`,wrap:!1}}),R=new w({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFpbnB1dF90ZW5zb3IlMjAlM0QlMjB0b3JjaC5mcm9tX251bXB5KHNhbXBsZSU1QiUyMmF1ZGlvJTIyJTVEJTVCJTIyYXJyYXklMjIlNUQlNUJOb25lJTJDJTIwJTNBJTVEKS5mbG9hdCgpJTBBb3V0cHV0cyUyMCUzRCUyMGRpYXJpemF0aW9uX3BpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMCU3QiUyMndhdmVmb3JtJTIyJTNBJTIwaW5wdXRfdGVuc29yJTJDJTIwJTIyc2FtcGxlX3JhdGUlMjIlM0ElMjBzYW1wbGUlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMnNhbXBsaW5nX3JhdGUlMjIlNUQlN0QlMEEpJTBBJTBBb3V0cHV0cy5mb3JfanNvbigpJTVCJTIyY29udGVudCUyMiU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch

input_tensor = torch.from_numpy(sample[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>][<span class="hljs-literal">None</span>, :]).<span class="hljs-built_in">float</span>()
outputs = diarization_pipeline(
    {<span class="hljs-string">&quot;waveform&quot;</span>: input_tensor, <span class="hljs-string">&quot;sample_rate&quot;</span>: sample[<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;sampling_rate&quot;</span>]}
)

outputs.for_json()[<span class="hljs-string">&quot;content&quot;</span>]`,wrap:!1}}),X=new w({props:{code:"JTVCJTdCJ3NlZ21lbnQnJTNBJTIwJTdCJ3N0YXJ0JyUzQSUyMDAuNDk3ODEyNSUyQyUyMCdlbmQnJTNBJTIwMTQuNTIwOTM3NTAwMDAwMDAyJTdEJTJDJTBBJTIwJTIwJ3RyYWNrJyUzQSUyMCdCJyUyQyUwQSUyMCUyMCdsYWJlbCclM0ElMjAnU1BFQUtFUl8wMSclN0QlMkMlMEElMjAlN0Inc2VnbWVudCclM0ElMjAlN0Inc3RhcnQnJTNBJTIwMTUuMzY0Njg3NTAwMDAwMDAyJTJDJTIwJ2VuZCclM0ElMjAyMS4zNzIxODc1JTdEJTJDJTBBJTIwJTIwJ3RyYWNrJyUzQSUyMCdBJyUyQyUwQSUyMCUyMCdsYWJlbCclM0ElMjAnU1BFQUtFUl8wMCclN0QlNUQ=",highlighted:`[{&#x27;segment&#x27;: {&#x27;start&#x27;: 0.4978125, &#x27;end&#x27;: 14.520937500000002},
  &#x27;track&#x27;: &#x27;B&#x27;,
  &#x27;label&#x27;: &#x27;SPEAKER_01&#x27;},
 {&#x27;segment&#x27;: {&#x27;start&#x27;: 15.364687500000002, &#x27;end&#x27;: 21.3721875},
  &#x27;track&#x27;: &#x27;A&#x27;,
  &#x27;label&#x27;: &#x27;SPEAKER_00&#x27;}]`,wrap:!1}}),E=new st({props:{title:"Speech transcription",local:"speech-transcription",headingTag:"h2"}}),q=new w({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBYXNyX3BpcGVsaW5lJTIwJTNEJTIwcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwJTIyYXV0b21hdGljLXNwZWVjaC1yZWNvZ25pdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyb3BlbmFpJTJGd2hpc3Blci1iYXNlJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

asr_pipeline = pipeline(
    <span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>,
    model=<span class="hljs-string">&quot;openai/whisper-base&quot;</span>,
)`,wrap:!1}}),_=new w({props:{code:"YXNyX3BpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHNhbXBsZSU1QiUyMmF1ZGlvJTIyJTVELmNvcHkoKSUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRlX2t3YXJncyUzRCU3QiUyMm1heF9uZXdfdG9rZW5zJTIyJTNBJTIwMjU2JTdEJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RpbWVzdGFtcHMlM0RUcnVlJTJDJTBBKQ==",highlighted:`asr_pipeline(
    sample[<span class="hljs-string">&quot;audio&quot;</span>].copy(),
    generate_kwargs={<span class="hljs-string">&quot;max_new_tokens&quot;</span>: <span class="hljs-number">256</span>},
    return_timestamps=<span class="hljs-literal">True</span>,
)`,wrap:!1}}),F=new w({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIydGV4d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MEhlJTIwd2FzJTIwaW4lMjBhJTIwZmF2b3JlZCUyMHN0YXRlJTIwb2YlMjBtaW5kJTJDJTIwb3dpbmclMjB0byUyMHRoZSUyMGJsaWdodCUyMGhpcyUyMHdpZmUncyUyMGFjdGlvbiUyMHRocmVhdGVuZWQlMjB0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnRpbWVzdGFtcCUyMiUzQSUyMCgxOS40NCUyQyUyMDIxLjI4KSUyQyUyMCUyMnRleHQlMjIlM0ElMjAlMjIlMjBjYXN0JTIwdXBvbiUyMGhpcyUyMGVudGlyZSUyMGZ1dHVyZS4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElN0Q=",highlighted:`{
    &quot;text&quot;: &quot; The second and importance is as follows. Sovereignty may be defined to be the right of making laws. In France, the king really exercises a portion of the sovereign power, since the laws have no weight. He was in a favored state of mind, owing to the blight his wife&#x27;s action threatened to cast upon his entire future.&quot;,
    &quot;chunks&quot;: [
        {&quot;timestamp&quot;: (0.0, 3.56), &quot;text&quot;: &quot; The second and importance is as follows.&quot;},
        {
            &quot;timestamp&quot;: (3.56, 7.84),
            &quot;text&quot;: &quot; Sovereignty may be defined to be the right of making laws.&quot;,
        },
        {
            &quot;timestamp&quot;: (7.84, 13.88),
            &quot;text&quot;: &quot; In France, the king really exercises a portion of the sovereign power, since the laws have&quot;,
        },
        {&quot;timestamp&quot;: (13.88, 15.48), &quot;text&quot;: &quot; no weight.&quot;},
        {
            &quot;timestamp&quot;: (15.48, 19.44),
            &quot;text&quot;: &quot; He was in a favored state of mind, owing to the blight his wife&#x27;s action threatened to&quot;,
        },
        {&quot;timestamp&quot;: (19.44, 21.28), &quot;text&quot;: &quot; cast upon his entire future.&quot;},
    ],
}`,wrap:!1}}),D=new st({props:{title:"Speechbox",local:"speechbox",headingTag:"h2"}}),K=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGc3BlZWNoYm94",highlighted:"pip install git+https://github.com/huggingface/speechbox",wrap:!1}}),ee=new w({props:{code:"ZnJvbSUyMHNwZWVjaGJveCUyMGltcG9ydCUyMEFTUkRpYXJpemF0aW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMEFTUkRpYXJpemF0aW9uUGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwYXNyX3BpcGVsaW5lJTNEYXNyX3BpcGVsaW5lJTJDJTIwZGlhcml6YXRpb25fcGlwZWxpbmUlM0RkaWFyaXphdGlvbl9waXBlbGluZSUwQSk=",highlighted:`<span class="hljs-keyword">from</span> speechbox <span class="hljs-keyword">import</span> ASRDiarizationPipeline

pipeline = ASRDiarizationPipeline(
    asr_pipeline=asr_pipeline, diarization_pipeline=diarization_pipeline
)`,wrap:!1}}),j=new Nt({props:{$$slots:{default:[Xt]},$$scope:{ctx:Je}}}),le=new w({props:{code:"cGlwZWxpbmUoc2FtcGxlJTVCJTIyYXVkaW8lMjIlNUQuY29weSgpKQ==",highlighted:'pipeline(sample[<span class="hljs-string">&quot;audio&quot;</span>].copy())',wrap:!1}}),se=new w({props:{code:"JTVCJTdCJ3NwZWFrZXInJTNBJTIwJ1NQRUFLRVJfMDEnJTJDJTBBJTIwJTIwJ3RleHQnJTNBJTIwJyUyMFRoZSUyMHNlY29uZCUyMGFuZCUyMGltcG9ydGFuY2UlMjBpcyUyMGFzJTIwZm9sbG93cy4lMjBTb3ZlcmVpZ250eSUyMG1heSUyMGJlJTIwZGVmaW5lZCUyMHRvJTIwYmUlMjB0aGUlMjByaWdodCUyMG9mJTIwbWFraW5nJTIwbGF3cy4lMjBJbiUyMEZyYW5jZSUyQyUyMHRoZSUyMGtpbmclMjByZWFsbHklMjBleGVyY2lzZXMlMjBhJTIwcG9ydGlvbiUyMG9mJTIwdGhlJTIwc292ZXJlaWduJTIwcG93ZXIlMkMlMjBzaW5jZSUyMHRoZSUyMGxhd3MlMjBoYXZlJTIwbm8lMjB3ZWlnaHQuJyUyQyUwQSUyMCUyMCd0aW1lc3RhbXAnJTNBJTIwKDAuMCUyQyUyMDE1LjQ4KSU3RCUyQyUwQSUyMCU3QidzcGVha2VyJyUzQSUyMCdTUEVBS0VSXzAwJyUyQyUwQSUyMCUyMCd0ZXh0JyUzQSUyMCUyMiUyMEhlJTIwd2FzJTIwaW4lMjBhJTIwZmF2b3JlZCUyMHN0YXRlJTIwb2YlMjBtaW5kJTJDJTIwb3dpbmclMjB0byUyMHRoZSUyMGJsaWdodCUyMGhpcyUyMHdpZmUncyUyMGFjdGlvbiUyMHRocmVhdGVuZWQlMjB0byUyMGNhc3QlMjB1cG9uJTIwaGlzJTIwZW50aXJlJTIwZnV0dXJlLiUyMiUyQyUwQSUyMCUyMCd0aW1lc3RhbXAnJTNBJTIwKDE1LjQ4JTJDJTIwMjEuMjgpJTdEJTVE",highlighted:`[{&#x27;speaker&#x27;: &#x27;SPEAKER_01&#x27;,
  &#x27;text&#x27;: &#x27; The second and importance is as follows. Sovereignty may be defined to be the right of making laws. In France, the king really exercises a portion of the sovereign power, since the laws have no weight.&#x27;,
  &#x27;timestamp&#x27;: (0.0, 15.48)},
 {&#x27;speaker&#x27;: &#x27;SPEAKER_00&#x27;,
  &#x27;text&#x27;: &quot; He was in a favored state of mind, owing to the blight his wife&#x27;s action threatened to cast upon his entire future.&quot;,
  &#x27;timestamp&#x27;: (15.48, 21.28)}]`,wrap:!1}}),ie=new w({props:{code:"ZGVmJTIwdHVwbGVfdG9fc3RyaW5nKHN0YXJ0X2VuZF90dXBsZSUyQyUyMG5kaWdpdHMlM0QxKSUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHN0cigocm91bmQoc3RhcnRfZW5kX3R1cGxlJTVCMCU1RCUyQyUyMG5kaWdpdHMpJTJDJTIwcm91bmQoc3RhcnRfZW5kX3R1cGxlJTVCMSU1RCUyQyUyMG5kaWdpdHMpKSklMEElMEElMEFkZWYlMjBmb3JtYXRfYXNfdHJhbnNjcmlwdGlvbihyYXdfc2VnbWVudHMpJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyJTVDbiU1Q24lMjIuam9pbiglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjaHVuayU1QiUyMnNwZWFrZXIlMjIlNUQlMjAlMkIlMjAlMjIlMjAlMjIlMjAlMkIlMjB0dXBsZV90b19zdHJpbmcoY2h1bmslNUIlMjJ0aW1lc3RhbXAlMjIlNUQpJTIwJTJCJTIwY2h1bmslNUIlMjJ0ZXh0JTIyJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwY2h1bmslMjBpbiUyMHJhd19zZWdtZW50cyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCk=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">tuple_to_string</span>(<span class="hljs-params">start_end_tuple, ndigits=<span class="hljs-number">1</span></span>):
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">str</span>((<span class="hljs-built_in">round</span>(start_end_tuple[<span class="hljs-number">0</span>], ndigits), <span class="hljs-built_in">round</span>(start_end_tuple[<span class="hljs-number">1</span>], ndigits)))


<span class="hljs-keyword">def</span> <span class="hljs-title function_">format_as_transcription</span>(<span class="hljs-params">raw_segments</span>):
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;\\n\\n&quot;</span>.join(
        [
            chunk[<span class="hljs-string">&quot;speaker&quot;</span>] + <span class="hljs-string">&quot; &quot;</span> + tuple_to_string(chunk[<span class="hljs-string">&quot;timestamp&quot;</span>]) + chunk[<span class="hljs-string">&quot;text&quot;</span>]
            <span class="hljs-keyword">for</span> chunk <span class="hljs-keyword">in</span> raw_segments
        ]
    )`,wrap:!1}}),pe=new w({props:{code:"b3V0cHV0cyUyMCUzRCUyMHBpcGVsaW5lKHNhbXBsZSU1QiUyMmF1ZGlvJTIyJTVELmNvcHkoKSklMEElMEFmb3JtYXRfYXNfdHJhbnNjcmlwdGlvbihvdXRwdXRzKQ==",highlighted:`outputs = pipeline(sample[<span class="hljs-string">&quot;audio&quot;</span>].copy())

format_as_transcription(outputs)`,wrap:!1}}),re=new w({props:{code:"U1BFQUtFUl8wMSUyMCgwLjAlMkMlMjAxNS41KSUyMFRoZSUyMHNlY29uZCUyMGFuZCUyMGltcG9ydGFuY2UlMjBpcyUyMGFzJTIwZm9sbG93cy4lMjBTb3ZlcmVpZ250eSUyMG1heSUyMGJlJTIwZGVmaW5lZCUyMHRvJTIwYmUlMjB0aGUlMjByaWdodCUyMG9mJTIwbWFraW5nJTIwbGF3cy4lMEFJbiUyMEZyYW5jZSUyQyUyMHRoZSUyMGtpbmclMjByZWFsbHklMjBleGVyY2lzZXMlMjBhJTIwcG9ydGlvbiUyMG9mJTIwdGhlJTIwc292ZXJlaWduJTIwcG93ZXIlMkMlMjBzaW5jZSUyMHRoZSUyMGxhd3MlMjBoYXZlJTIwbm8lMjB3ZWlnaHQuJTBBJTBBU1BFQUtFUl8wMCUyMCgxNS41JTJDJTIwMjEuMyklMjBIZSUyMHdhcyUyMGluJTIwYSUyMGZhdm9yZWQlMjBzdGF0ZSUyMG9mJTIwbWluZCUyQyUyMG93aW5nJTIwdG8lMjB0aGUlMjBibGlnaHQlMjBoaXMlMjB3aWZlJ3MlMjBhY3Rpb24lMjB0aHJlYXRlbmVkJTIwdG8lMjBjYXN0JTIwdXBvbiUwQWhpcyUyMGVudGlyZSUyMGZ1dHVyZS4=",highlighted:`SPEAKER_01 (0.0, 15.5) The second and importance is as follows. Sovereignty may be defined to be the right of making laws.
In France, the king really exercises a portion of the sovereign power, since the laws have no weight.

SPEAKER_00 (15.5, 21.3) He was in a favored state of mind, owing to the blight his wife&#x27;s action threatened to cast upon
his entire future.`,wrap:!1}}),ye=new Rt({props:{source:"https://github.com/huggingface/audio-transformers-course/blob/main/chapters/en/chapter7/transcribe-meeting.mdx"}}),{c(){U=i("meta"),T=n(),I=i("p"),u=n(),p(c.$$.fragment),g=n(),p(d.$$.fragment),f=n(),C=i("p"),C.innerHTML=at,he=n(),b=i("div"),b.innerHTML=it,de=n(),p(G.$$.fragment),we=n(),B=i("p"),B.textContent=ot,ce=n(),$=i("p"),$.innerHTML=pt,Ue=n(),p(Z.$$.fragment),Te=n(),k=i("p"),k.innerHTML=rt,ue=n(),x=i("p"),x.textContent=Mt,fe=n(),p(W.$$.fragment),Ie=n(),S=i("p"),S.innerHTML=yt,be=n(),p(v.$$.fragment),je=n(),Q=i("p"),Q.textContent=mt,ge=n(),p(N.$$.fragment),Ce=n(),A=i("p"),A.innerHTML=Jt,Ge=n(),p(R.$$.fragment),Be=n(),p(X.$$.fragment),$e=n(),H=i("p"),H.textContent=ht,Ze=n(),p(E.$$.fragment),ke=n(),V=i("p"),V.innerHTML=dt,xe=n(),p(q.$$.fragment),We=n(),z=i("p"),z.innerHTML=wt,Se=n(),p(_.$$.fragment),ve=n(),p(F.$$.fragment),Qe=n(),Y=i("p"),Y.textContent=ct,Ne=n(),p(D.$$.fragment),Ae=n(),L=i("p"),L.textContent=Ut,Re=n(),P=i("p"),P.innerHTML=Tt,Xe=n(),p(K.$$.fragment),He=n(),O=i("p"),O.innerHTML=ut,Ee=n(),p(ee.$$.fragment),Ve=n(),p(j.$$.fragment),qe=n(),te=i("p"),te.textContent=ft,ze=n(),p(le.$$.fragment),_e=n(),p(se.$$.fragment),Fe=n(),ne=i("p"),ne.textContent=It,Ye=n(),ae=i("p"),ae.textContent=bt,De=n(),p(ie.$$.fragment),Le=n(),oe=i("p"),oe.textContent=jt,Pe=n(),p(pe.$$.fragment),Ke=n(),p(re.$$.fragment),Oe=n(),Me=i("p"),Me.innerHTML=gt,et=n(),p(ye.$$.fragment),tt=n(),me=i("p"),this.h()},l(e){const t=vt("svelte-u9bgzb",document.head);U=o(t,"META",{name:!0,content:!0}),t.forEach(l),T=a(e),I=o(e,"P",{}),Gt(I).forEach(l),u=a(e),r(c.$$.fragment,e),g=a(e),r(d.$$.fragment,e),f=a(e),C=o(e,"P",{"data-svelte-h":!0}),h(C)!=="svelte-1tqqmqr"&&(C.innerHTML=at),he=a(e),b=o(e,"DIV",{class:!0,"data-svelte-h":!0}),h(b)!=="svelte-9us2ce"&&(b.innerHTML=it),de=a(e),r(G.$$.fragment,e),we=a(e),B=o(e,"P",{"data-svelte-h":!0}),h(B)!=="svelte-t8p1z2"&&(B.textContent=ot),ce=a(e),$=o(e,"P",{"data-svelte-h":!0}),h($)!=="svelte-1kcbzau"&&($.innerHTML=pt),Ue=a(e),r(Z.$$.fragment,e),Te=a(e),k=o(e,"P",{"data-svelte-h":!0}),h(k)!=="svelte-5q49hx"&&(k.innerHTML=rt),ue=a(e),x=o(e,"P",{"data-svelte-h":!0}),h(x)!=="svelte-s5u7ly"&&(x.textContent=Mt),fe=a(e),r(W.$$.fragment,e),Ie=a(e),S=o(e,"P",{"data-svelte-h":!0}),h(S)!=="svelte-150e6pp"&&(S.innerHTML=yt),be=a(e),r(v.$$.fragment,e),je=a(e),Q=o(e,"P",{"data-svelte-h":!0}),h(Q)!=="svelte-qukzyh"&&(Q.textContent=mt),ge=a(e),r(N.$$.fragment,e),Ce=a(e),A=o(e,"P",{"data-svelte-h":!0}),h(A)!=="svelte-cjssv6"&&(A.innerHTML=Jt),Ge=a(e),r(R.$$.fragment,e),Be=a(e),r(X.$$.fragment,e),$e=a(e),H=o(e,"P",{"data-svelte-h":!0}),h(H)!=="svelte-137vsmb"&&(H.textContent=ht),Ze=a(e),r(E.$$.fragment,e),ke=a(e),V=o(e,"P",{"data-svelte-h":!0}),h(V)!=="svelte-1p4vlmp"&&(V.innerHTML=dt),xe=a(e),r(q.$$.fragment,e),We=a(e),z=o(e,"P",{"data-svelte-h":!0}),h(z)!=="svelte-1ykatvd"&&(z.innerHTML=wt),Se=a(e),r(_.$$.fragment,e),ve=a(e),r(F.$$.fragment,e),Qe=a(e),Y=o(e,"P",{"data-svelte-h":!0}),h(Y)!=="svelte-9e4lxz"&&(Y.textContent=ct),Ne=a(e),r(D.$$.fragment,e),Ae=a(e),L=o(e,"P",{"data-svelte-h":!0}),h(L)!=="svelte-15wht1d"&&(L.textContent=Ut),Re=a(e),P=o(e,"P",{"data-svelte-h":!0}),h(P)!=="svelte-1d1nesl"&&(P.innerHTML=Tt),Xe=a(e),r(K.$$.fragment,e),He=a(e),O=o(e,"P",{"data-svelte-h":!0}),h(O)!=="svelte-1sqyg35"&&(O.innerHTML=ut),Ee=a(e),r(ee.$$.fragment,e),Ve=a(e),r(j.$$.fragment,e),qe=a(e),te=o(e,"P",{"data-svelte-h":!0}),h(te)!=="svelte-1p2go7o"&&(te.textContent=ft),ze=a(e),r(le.$$.fragment,e),_e=a(e),r(se.$$.fragment,e),Fe=a(e),ne=o(e,"P",{"data-svelte-h":!0}),h(ne)!=="svelte-1uyv73y"&&(ne.textContent=It),Ye=a(e),ae=o(e,"P",{"data-svelte-h":!0}),h(ae)!=="svelte-yn88rk"&&(ae.textContent=bt),De=a(e),r(ie.$$.fragment,e),Le=a(e),oe=o(e,"P",{"data-svelte-h":!0}),h(oe)!=="svelte-1hp60dp"&&(oe.textContent=jt),Pe=a(e),r(pe.$$.fragment,e),Ke=a(e),r(re.$$.fragment,e),Oe=a(e),Me=o(e,"P",{"data-svelte-h":!0}),h(Me)!=="svelte-19dux4l"&&(Me.innerHTML=gt),et=a(e),r(ye.$$.fragment,e),tt=a(e),me=o(e,"P",{}),Gt(me).forEach(l),this.h()},h(){nt(U,"name","hf:doc:metadata"),nt(U,"content",Et),nt(b,"class","flex justify-center")},m(e,t){Qt(document.head,U),s(e,T,t),s(e,I,t),s(e,u,t),M(c,e,t),s(e,g,t),M(d,e,t),s(e,f,t),s(e,C,t),s(e,he,t),s(e,b,t),s(e,de,t),M(G,e,t),s(e,we,t),s(e,B,t),s(e,ce,t),s(e,$,t),s(e,Ue,t),M(Z,e,t),s(e,Te,t),s(e,k,t),s(e,ue,t),s(e,x,t),s(e,fe,t),M(W,e,t),s(e,Ie,t),s(e,S,t),s(e,be,t),M(v,e,t),s(e,je,t),s(e,Q,t),s(e,ge,t),M(N,e,t),s(e,Ce,t),s(e,A,t),s(e,Ge,t),M(R,e,t),s(e,Be,t),M(X,e,t),s(e,$e,t),s(e,H,t),s(e,Ze,t),M(E,e,t),s(e,ke,t),s(e,V,t),s(e,xe,t),M(q,e,t),s(e,We,t),s(e,z,t),s(e,Se,t),M(_,e,t),s(e,ve,t),M(F,e,t),s(e,Qe,t),s(e,Y,t),s(e,Ne,t),M(D,e,t),s(e,Ae,t),s(e,L,t),s(e,Re,t),s(e,P,t),s(e,Xe,t),M(K,e,t),s(e,He,t),s(e,O,t),s(e,Ee,t),M(ee,e,t),s(e,Ve,t),M(j,e,t),s(e,qe,t),s(e,te,t),s(e,ze,t),M(le,e,t),s(e,_e,t),M(se,e,t),s(e,Fe,t),s(e,ne,t),s(e,Ye,t),s(e,ae,t),s(e,De,t),M(ie,e,t),s(e,Le,t),s(e,oe,t),s(e,Pe,t),M(pe,e,t),s(e,Ke,t),M(re,e,t),s(e,Oe,t),s(e,Me,t),s(e,et,t),M(ye,e,t),s(e,tt,t),s(e,me,t),lt=!0},p(e,[t]){const Ct={};t&2&&(Ct.$$scope={dirty:t,ctx:e}),j.$set(Ct)},i(e){lt||(y(c.$$.fragment,e),y(d.$$.fragment,e),y(G.$$.fragment,e),y(Z.$$.fragment,e),y(W.$$.fragment,e),y(v.$$.fragment,e),y(N.$$.fragment,e),y(R.$$.fragment,e),y(X.$$.fragment,e),y(E.$$.fragment,e),y(q.$$.fragment,e),y(_.$$.fragment,e),y(F.$$.fragment,e),y(D.$$.fragment,e),y(K.$$.fragment,e),y(ee.$$.fragment,e),y(j.$$.fragment,e),y(le.$$.fragment,e),y(se.$$.fragment,e),y(ie.$$.fragment,e),y(pe.$$.fragment,e),y(re.$$.fragment,e),y(ye.$$.fragment,e),lt=!0)},o(e){m(c.$$.fragment,e),m(d.$$.fragment,e),m(G.$$.fragment,e),m(Z.$$.fragment,e),m(W.$$.fragment,e),m(v.$$.fragment,e),m(N.$$.fragment,e),m(R.$$.fragment,e),m(X.$$.fragment,e),m(E.$$.fragment,e),m(q.$$.fragment,e),m(_.$$.fragment,e),m(F.$$.fragment,e),m(D.$$.fragment,e),m(K.$$.fragment,e),m(ee.$$.fragment,e),m(j.$$.fragment,e),m(le.$$.fragment,e),m(se.$$.fragment,e),m(ie.$$.fragment,e),m(pe.$$.fragment,e),m(re.$$.fragment,e),m(ye.$$.fragment,e),lt=!1},d(e){e&&(l(T),l(I),l(u),l(g),l(f),l(C),l(he),l(b),l(de),l(we),l(B),l(ce),l($),l(Ue),l(Te),l(k),l(ue),l(x),l(fe),l(Ie),l(S),l(be),l(je),l(Q),l(ge),l(Ce),l(A),l(Ge),l(Be),l($e),l(H),l(Ze),l(ke),l(V),l(xe),l(We),l(z),l(Se),l(ve),l(Qe),l(Y),l(Ne),l(Ae),l(L),l(Re),l(P),l(Xe),l(He),l(O),l(Ee),l(Ve),l(qe),l(te),l(ze),l(_e),l(Fe),l(ne),l(Ye),l(ae),l(De),l(Le),l(oe),l(Pe),l(Ke),l(Oe),l(Me),l(et),l(tt),l(me)),l(U),J(c,e),J(d,e),J(G,e),J(Z,e),J(W,e),J(v,e),J(N,e),J(R,e),J(X,e),J(E,e),J(q,e),J(_,e),J(F,e),J(D,e),J(K,e),J(ee,e),J(j,e),J(le,e),J(se,e),J(ie,e),J(pe,e),J(re,e),J(ye,e)}}}const Et='{"title":"Transcribe a meeting","local":"transcribe-a-meeting","sections":[{"title":"Speaker Diarization","local":"speaker-diarization","sections":[],"depth":2},{"title":"Speech transcription","local":"speech-transcription","sections":[],"depth":2},{"title":"Speechbox","local":"speechbox","sections":[],"depth":2}],"depth":1}';function Vt(Je){return kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Dt extends Wt{constructor(U){super(),St(this,U,Vt,Ht,Zt,{})}}export{Dt as component};
