import{s as Bt,o as $t,n as Zt}from"../chunks/scheduler.f7e1785c.js";import{S as kt,i as xt,g as i,s as a,r,A as Wt,h as o,f as l,c as n,j as Ct,u as M,x as p,k as st,y as St,a as s,v as y,d as m,t as J,w as h,m as gt,n as Gt}from"../chunks/index.9f8f0838.js";import{T as vt}from"../chunks/Tip.4575d9cf.js";import{C as w}from"../chunks/CodeBlock.4baef5d7.js";import{H as lt,E as Qt}from"../chunks/getInferenceSnippets.ba5f4cd0.js";function Nt(me){let U,T,f="ASRDiarizationPipeline",u,c,j="<code>pipeline = ASRDiarizationPipeline.from_pretrained(&quot;openai/whisper-base&quot;)</code>";return{c(){U=gt("You can also instantiate the "),T=i("code"),T.textContent=f,u=gt(` directly from pre-trained by specifying the model id
    of an ASR model on the Hub:
    `),c=i("p"),c.innerHTML=j},l(d){U=Gt(d,"You can also instantiate the "),T=o(d,"CODE",{"data-svelte-h":!0}),p(T)!=="svelte-1613cio"&&(T.textContent=f),u=Gt(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}),p(c)!=="svelte-k598fh"&&(c.innerHTML=j)},m(d,C){s(d,U,C),s(d,T,C),s(d,u,C),s(d,c,C)},p:Zt,d(d){d&&(l(U),l(T),l(u),l(c))}}}function At(me){let U,T,f,u,c,j,d,C=`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:`,Je,I,at='<img src="https://huggingface.co/datasets/huggingface-course/audio-course-images/resolve/main/diarization_transcription.png"/>',he,g,de,G,nt=`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.`,we,B,it=`🤗 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:`,ce,$,Ue,Z,ot=`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>.`,Te,k,pt="Once complete, we can load the pre-trained speaker diarization pipeline locally on our device:",ue,x,fe,W,rt=`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:`,Ie,S,be,v,Mt="We can listen to the audio to see what it sounds like:",je,Q,Ce,N,yt=`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,A,Ge,R,Be,X,mt=`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!`,$e,H,Ze,E,Jt=`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:`,ke,V,xe,q,ht=`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:`,We,z,Se,_,ve,F,dt=`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.`,Qe,Y,Ne,D,wt=`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.`,Ae,L,ct=`Luckily for us, we can use the 🤗 Speechbox package to perform this alignment. First, let’s pip install <code>speechbox</code> from
main:`,Re,P,Xe,K,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:`,He,O,Ee,b,Ve,ee,Tt="Let’s pass the audio file to the composite pipeline and see what we get out:",qe,te,ze,le,_e,se,ut=`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.`,Fe,ae,ft=`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:`,Ye,ne,De,ie,It="Let’s re-run the pipeline, this time formatting the transcription according to the function we’ve just defined:",Le,oe,Pe,pe,Ke,re,bt=`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>`,Oe,Me,et,ye,tt;return c=new lt({props:{title:"Transcribe a meeting",local:"transcribe-a-meeting",headingTag:"h1"}}),g=new lt({props:{title:"Speaker Diarization",local:"speaker-diarization",headingTag:"h2"}}),$=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHB5YW5ub3RlLmF1ZGlv",highlighted:"pip install --upgrade pyannote.audio",wrap:!1}}),x=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}}),S=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}}),Q=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}}),A=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}}),R=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}}),H=new lt({props:{title:"Speech transcription",local:"speech-transcription",headingTag:"h2"}}),V=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}}),z=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}}),_=new w({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIydGV4dCUyMiUzQSUyMCUyMiUyMFRoZSUyMHNlY29uZCUyMGFuZCUyMGltcG9ydGFuY2UlMjBpcyU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JTIwb3dpbmclMjB0byUyMHRoZSUyMGJsaWdodCUyMGhpcyUyMHdpZmUncyUyMGFjdGlvbiUyMHRocmVhdGVuZWQlMjB0byUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnRpbWVzdGFtcCUyMiUzQSUyMCgxOS40NCUyQyUyMDIxLjI4KSUyQyUyMCUyMnRleHQlMjIlM0ElMjAlMjIlMjBjYXN0JTIwdXBvbiUyMGhpcyUyMGVudGlyZSUyMGZ1dHVyZS4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElN0Q=",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}}),Y=new lt({props:{title:"Speechbox",local:"speechbox",headingTag:"h2"}}),P=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGc3BlZWNoYm94",highlighted:"pip install git+https://github.com/huggingface/speechbox",wrap:!1}}),O=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}}),b=new vt({props:{$$slots:{default:[Nt]},$$scope:{ctx:me}}}),te=new w({props:{code:"cGlwZWxpbmUoc2FtcGxlJTVCJTIyYXVkaW8lMjIlNUQuY29weSgpKQ==",highlighted:'pipeline(sample[<span class="hljs-string">&quot;audio&quot;</span>].copy())',wrap:!1}}),le=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}}),ne=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}}),oe=new w({props:{code:"b3V0cHV0cyUyMCUzRCUyMHBpcGVsaW5lKHNhbXBsZSU1QiUyMmF1ZGlvJTIyJTVELmNvcHkoKSklMEElMEFmb3JtYXRfYXNfdHJhbnNjcmlwdGlvbihvdXRwdXRzKQ==",highlighted:`outputs = pipeline(sample[<span class="hljs-string">&quot;audio&quot;</span>].copy())

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