import{S as Wh,i as Nh,s as Rh,e as n,k as i,w as m,t as h,M as Ah,c as o,d as t,m as p,a as r,x as d,h as c,b as u,N as Bh,G as l,g as a,y as f,q as M,o as y,B as w,v as Xh}from"../../chunks/vendor-hf-doc-builder.js";import{T as Yh}from"../../chunks/Tip-hf-doc-builder.js";import{I as $}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as J}from"../../chunks/CodeBlock-hf-doc-builder.js";function Qh(Ml){let T,Y;return{c(){T=n("p"),Y=h(`In our example we will be using approximately 40 hours of training data. If you\u2019d like to follow along using the Google Colab free tier GPU,
you will need to reduce the amount of training data to approximately 10-15 hours, and reduce the number of training steps.`)},l(U){T=o(U,"P",{});var k=r(T);Y=c(k,`In our example we will be using approximately 40 hours of training data. If you\u2019d like to follow along using the Google Colab free tier GPU,
you will need to reduce the amount of training data to approximately 10-15 hours, and reduce the number of training steps.`),k.forEach(t)},m(U,k){a(U,T,k),l(T,Y)},d(U){U&&t(T)}}}function zh(Ml){let T,Y,U,k,Ms,ce,Dn,ys,Pn,yl,bt,On,wl,E,Q,ws,ue,Kn,Js,Ln,Jl,me,Tl,z,bl,Ut,eo,Ul,de,jl,jt,to,kl,fe,Il,x,F,Ts,Me,so,bs,lo,gl,I,ao,Us,no,oo,ye,ro,io,we,po,ho,vl,kt,co,$l,It,uo,_l,Je,Cl,gt,js,mo,Zl,Te,El,vt,fo,xl,be,Gl,G,S,ks,Ue,Mo,Is,yo,Vl,$t,wo,Bl,je,Wl,V,q,gs,ke,Jo,vs,To,Nl,_t,bo,Rl,Ie,Al,Ct,Uo,Xl,ge,Yl,Zt,$s,jo,Ql,ve,zl,j,ko,_s,Io,go,Cs,vo,$o,Zs,_o,Co,Es,Zo,Eo,Fl,g,xo,xs,Go,Vo,Gs,Bo,Wo,Vs,No,Ro,Sl,b,Ao,Bs,Xo,Yo,Ws,Qo,zo,Ns,Fo,So,Rs,qo,Ho,As,Do,Po,ql,$e,Hl,Et,Oo,Dl,_e,Pl,xt,X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$slots:{default:[Qh]},$$scope:{ctx:Ml}}}),de=new J({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwc291bmRmaWxlJTIwc3BlZWNoYnJhaW4lMjBhY2NlbGVyYXRl",highlighted:"pip install transformers datasets soundfile speechbrain accelerate"}}),fe=new J({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

notebook_login()`}}),Me=new $({}),Je=new J({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmZhY2Vib29rJTJGdm94cG9wdWxpJTIyJTJDJTIwJTIybmwlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKSUwQWxlbihkYXRhc2V0KQ==",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

dataset = load_dataset(<span class="hljs-string">&quot;facebook/voxpopuli&quot;</span>, <span class="hljs-string">&quot;nl&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
<span class="hljs-built_in">len</span>(dataset)`}}),Te=new J({props:{code:"MjA5Njg=",highlighted:"20968"}}),be=new J({props:{code:"ZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQuY2FzdF9jb2x1bW4oJTIyYXVkaW8lMjIlMkMlMjBBdWRpbyhzYW1wbGluZ19yYXRlJTNEMTYwMDApKQ==",highlighted:'dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))'}}),Ue=new $({}),je=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNwZWVjaFQ1UHJvY2Vzc29yJTBBJTBBY2hlY2twb2ludCUyMCUzRCUyMCUyMm1pY3Jvc29mdCUyRnNwZWVjaHQ1X3R0cyUyMiUwQXByb2Nlc3NvciUyMCUzRCUyMFNwZWVjaFQ1UHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SpeechT5Processor

checkpoint = <span class="hljs-string">&quot;microsoft/speecht5_tts&quot;</span>
processor = SpeechT5Processor.from_pretrained(checkpoint)`}}),ke=new $({}),Ie=new J({props:{code:"dG9rZW5pemVyJTIwJTNEJTIwcHJvY2Vzc29yLnRva2VuaXplcg==",highlighted:"tokenizer = processor.tokenizer"}}),ge=new J({props:{code:"ZGF0YXNldCU1QjAlNUQ=",highlighted:'dataset[<span class="hljs-number">0</span>]'}}),ve=new J({props:{code:"JTdCJ2F1ZGlvX2lkJyUzQSUyMCcyMDEwMDIxMC0wOTAwLVBMRU5BUlktMy1ubF8yMDEwMDIxMC0wOSUzQTA2JTNBNDNfNCclMkMlMEElMjAnbGFuZ3VhZ2UnJTNBJTIwOSUyQyUwQSUyMCdhdWRpbyclM0ElMjAlN0IncGF0aCclM0ElMjAnJTJGcm9vdCUyRi5jYWNoZSUyRmh1Z2dpbmdmYWNlJTJGZGF0YXNldHMlMkZkb3dubG9hZHMlMkZleHRyYWN0ZWQlMkYwMmVjNmExOWQ1Yjk3YzAzZTEzNzkyNTAzNzg0NTRkYmYzZmEyOTcyOTQzNTA0YTkxYzdkYTUwNDVhYTI2YTg5JTJGdHJhaW5fcGFydF8wJTJGMjAxMDAyMTAtMDkwMC1QTEVOQVJZLTMtbmxfMjAxMDAyMTAtMDklM0EwNiUzQTQzXzQud2F2JyUyQyUwQSUyMCUyMCdhcnJheSclM0ElMjBhcnJheSglNUIlMjA0LjI3MjQ2MDk0ZS0wNCUyQyUyMCUyMDEuMzEyMjU1ODZlLTAzJTJDJTIwJTIwMS4wMzc1OTc2NmUtMDMlMkMlMjAuLi4lMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtOS4xNTUyNzM0NGUtMDUlMkMlMjAlMjA3LjYyOTM5NDUzZS0wNCUyQyUyMC0yLjQ0MTQwNjI1ZS0wNCU1RCklMkMlMEElMjAlMjAnc2FtcGxpbmdfcmF0ZSclM0ElMjAxNjAwMCU3RCUyQyUwQSUyMCdyYXdfdGV4dCclM0ElMjAnRGF0JTIwa2FuJTIwbmFhciUyMG1pam4lMjBnZXZvZWwlMjBhbGxlZW4lMjBtZXQlMjBlZW4lMjBicmVkZSUyMG1lZXJkZXJoZWlkJTIwZGllJTIwd2lqJTIwc2FtZW4lMjB6b2VrZW4uJyUyQyUwQSUyMCdub3JtYWxpemVkX3RleHQnJTNBJTIwJ2RhdCUyMGthbiUyMG5hYXIlMjBtaWpuJTIwZ2V2b2VsJTIwYWxsZWVuJTIwbWV0JTIwZWVuJTIwYnJlZGUlMjBtZWVyZGVyaGVpZCUyMGRpZSUyMHdpaiUyMHNhbWVuJTIwem9la2VuLiclMkMlMEElMjAnZ2VuZGVyJyUzQSUyMCdmZW1hbGUnJTJDJTBBJTIwJ3NwZWFrZXJfaWQnJTNBJTIwJzExMjInJTJDJTBBJTIwJ2lzX2dvbGRfdHJhbnNjcmlwdCclM0ElMjBUcnVlJTJDJTBBJTIwJ2FjY2VudCclM0ElMjAnTm9uZSclN0Q=",highlighted:`{&#x27;audio_id&#x27;: &#x27;<span class="hljs-number">20100210-0900</span>-PLENARY-3-nl_<span class="hljs-number">20100210-09:06:43</span>_4&#x27;,
 &#x27;language&#x27;: <span class="hljs-number">9</span>,
 &#x27;audio&#x27;: {&#x27;path&#x27;: &#x27;/root/.cache/huggingface/datasets/downloads/extracted/02ec6a19d5b97c03e<span class="hljs-number">137925037845</span>4dbf3fa<span class="hljs-number">2972943504</span>a91c7da<span class="hljs-number">5045</span>aa26a89/train_part_0/<span class="hljs-number">20100210-0900</span>-PLENARY-3-nl_<span class="hljs-number">20100210-09:06:43</span>_4.wav&#x27;,
  &#x27;array&#x27;: array([ <span class="hljs-number">4.27246094</span>e-<span class="hljs-number">04</span>,  <span class="hljs-number">1.31225586</span>e-<span class="hljs-number">03</span>,  <span class="hljs-number">1.03759766</span>e-<span class="hljs-number">03</span>, ...,
         -<span class="hljs-number">9.15527344</span>e-<span class="hljs-number">05</span>,  <span class="hljs-number">7.62939453</span>e-<span class="hljs-number">04</span>, -<span class="hljs-number">2.44140625</span>e-<span class="hljs-number">04</span>]),
  &#x27;sampling_rate&#x27;: <span class="hljs-number">16000</span>},
 &#x27;raw_text&#x27;: &#x27;Dat kan naar mijn gevoel alleen met een brede meerderheid die wij samen zoeken.&#x27;,
 &#x27;normalized_text&#x27;: &#x27;dat kan naar mijn gevoel alleen met een brede meerderheid die wij samen zoeken.&#x27;,
 &#x27;gender&#x27;: &#x27;female&#x27;,
 &#x27;speaker_id&#x27;: &#x27;<span class="hljs-number">1122</span>&#x27;,
 &#x27;is_gold_transcript&#x27;: True,
 &#x27;accent&#x27;: &#x27;None&#x27;}`}}),$e=new J({props:{code:"ZGVmJTIwZXh0cmFjdF9hbGxfY2hhcnMoYmF0Y2gpJTNBJTBBJTIwJTIwJTIwJTIwYWxsX3RleHQlMjAlM0QlMjAlMjIlMjAlMjIuam9pbihiYXRjaCU1QiUyMm5vcm1hbGl6ZWRfdGV4dCUyMiU1RCklMEElMjAlMjAlMjAlMjB2b2NhYiUyMCUzRCUyMGxpc3Qoc2V0KGFsbF90ZXh0KSklMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlN0IlMjJ2b2NhYiUyMiUzQSUyMCU1QnZvY2FiJTVEJTJDJTIwJTIyYWxsX3RleHQlMjIlM0ElMjAlNUJhbGxfdGV4dCU1RCU3RCUwQSUwQSUwQXZvY2FicyUyMCUzRCUyMGRhdGFzZXQubWFwKCUwQSUyMCUyMCUyMCUyMGV4dHJhY3RfYWxsX2NoYXJzJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hlZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNELTElMkMlMEElMjAlMjAlMjAlMjBrZWVwX2luX21lbW9yeSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZW1vdmVfY29sdW1ucyUzRGRhdGFzZXQuY29sdW1uX25hbWVzJTJDJTBBKSUwQSUwQWRhdGFzZXRfdm9jYWIlMjAlM0QlMjBzZXQodm9jYWJzJTVCJTIydm9jYWIlMjIlNUQlNUIwJTVEKSUwQXRva2VuaXplcl92b2NhYiUyMCUzRCUyMCU3QmslMjBmb3IlMjBrJTJDJTIwXyUyMGluJTIwdG9rZW5pemVyLmdldF92b2NhYigpLml0ZW1zKCklN0Q=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">extract_all_chars</span>(<span class="hljs-params">batch</span>):
    all_text = <span class="hljs-string">&quot; &quot;</span>.join(batch[<span class="hljs-string">&quot;normalized_text&quot;</span>])
    vocab = <span class="hljs-built_in">list</span>(<span class="hljs-built_in">set</span>(all_text))
    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;vocab&quot;</span>: [vocab], <span class="hljs-string">&quot;all_text&quot;</span>: [all_text]}


vocabs = dataset.<span class="hljs-built_in">map</span>(
    extract_all_chars,
    batched=<span class="hljs-literal">True</span>,
    batch_size=-<span class="hljs-number">1</span>,
    keep_in_memory=<span class="hljs-literal">True</span>,
    remove_columns=dataset.column_names,
)

dataset_vocab = <span class="hljs-built_in">set</span>(vocabs[<span class="hljs-string">&quot;vocab&quot;</span>][<span class="hljs-number">0</span>])
tokenizer_vocab = {k <span class="hljs-keyword">for</span> k, _ <span class="hljs-keyword">in</span> tokenizer.get_vocab().items()}`}}),_e=new J({props:{code:"ZGF0YXNldF92b2NhYiUyMC0lMjB0b2tlbml6ZXJfdm9jYWI=",highlighted:"dataset_vocab - tokenizer_vocab"}}),Ce=new J({props:{code:"JTdC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1RCUyMCUzRCUyMGlucHV0cyU1QiUyMm5vcm1hbGl6ZWRfdGV4dCUyMiU1RC5yZXBsYWNlKHNyYyUyQyUyMGRzdCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBpbnB1dHMlMEElMEElMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldC5tYXAoY2xlYW51cF90ZXh0KQ==",highlighted:`replacements = [
    (<span class="hljs-string">&quot;\xE0&quot;</span>, <span class="hljs-string">&quot;a&quot;</span>),
    (<span class="hljs-string">&quot;\xE7&quot;</span>, <span class="hljs-string">&quot;c&quot;</span>),
    (<span class="hljs-string">&quot;\xE8&quot;</span>, <span class="hljs-string">&quot;e&quot;</span>),
    (<span class="hljs-string">&quot;\xEB&quot;</span>, <span class="hljs-string">&quot;e&quot;</span>),
    (<span class="hljs-string">&quot;\xED&quot;</span>, <span class="hljs-string">&quot;i&quot;</span>),
    (<span class="hljs-string">&quot;\xEF&quot;</span>, <span class="hljs-string">&quot;i&quot;</span>),
    (<span class="hljs-string">&quot;\xF6&quot;</span>, <span class="hljs-string">&quot;o&quot;</span>),
    (<span class="hljs-string">&quot;\xFC&quot;</span>, <span class="hljs-string">&quot;u&quot;</span>),
]


<span class="hljs-keyword">def</span> <span class="hljs-title function_">cleanup_text</span>(<span class="hljs-params">inputs</span>):
    <span class="hljs-keyword">for</span> src, dst <span class="hljs-keyword">in</span> replacements:
        inputs[<span class="hljs-string">&quot;normalized_text&quot;</span>] = inputs[<span class="hljs-string">&quot;normalized_text&quot;</span>].replace(src, dst)
    <span class="hljs-keyword">return</span> inputs


dataset = dataset.<span class="hljs-built_in">map</span>(cleanup_text)`}}),Ee=new $({}),xe=new J({props:{code:"ZnJvbSUyMGNvbGxlY3Rpb25zJTIwaW1wb3J0JTIwZGVmYXVsdGRpY3QlMEElMEFzcGVha2VyX2NvdW50cyUyMCUzRCUyMGRlZmF1bHRkaWN0KGludCklMEElMEFmb3IlMjBzcGVha2VyX2lkJTIwaW4lMjBkYXRhc2V0JTVCJTIyc3BlYWtlcl9pZCUyMiU1RCUzQSUwQSUyMCUyMCUyMCUyMHNwZWFrZXJfY291bnRzJTVCc3BlYWtlcl9pZCU1RCUyMCUyQiUzRCUyMDE=",highlighted:`<span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> defaultdict

speaker_counts = defaultdict(<span class="hljs-built_in">int</span>)

<span class="hljs-keyword">for</span> speaker_id <span class="hljs-keyword">in</span> dataset[<span class="hljs-string">&quot;speaker_id&quot;</span>]:
    speaker_counts[speaker_id] += <span class="hljs-number">1</span>`}}),Ge=new J({props:{code:"aW1wb3J0JTIwbWF0cGxvdGxpYi5weXBsb3QlMjBhcyUyMHBsdCUwQSUwQXBsdC5maWd1cmUoKSUwQXBsdC5oaXN0KHNwZWFrZXJfY291bnRzLnZhbHVlcygpJTJDJTIwYmlucyUzRDIwKSUwQXBsdC55bGFiZWwoJTIyU3BlYWtlcnMlMjIpJTBBcGx0LnhsYWJlbCglMjJFeGFtcGxlcyUyMiklMEFwbHQuc2hvdygp",highlighted:`<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

plt.figure()
plt.hist(speaker_counts.values(), bins=<span class="hljs-number">20</span>)
plt.ylabel(<span class="hljs-string">&quot;Speakers&quot;</span>)
plt.xlabel(<span class="hljs-string">&quot;Examples&quot;</span>)
plt.show()`}}),Be=new J({props:{code:"ZGVmJTIwc2VsZWN0X3NwZWFrZXIoc3BlYWtlcl9pZCklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjAxMDAlMjAlM0MlM0QlMjBzcGVha2VyX2NvdW50cyU1QnNwZWFrZXJfaWQlNUQlMjAlM0MlM0QlMjA0MDAlMEElMEElMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldC5maWx0ZXIoc2VsZWN0X3NwZWFrZXIlMkMlMjBpbnB1dF9jb2x1bW5zJTNEJTVCJTIyc3BlYWtlcl9pZCUyMiU1RCk=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">select_speaker</span>(<span class="hljs-params">speaker_id</span>):
    <span class="hljs-keyword">return</span> <span class="hljs-number">100</span> &lt;= speaker_counts[speaker_id] &lt;= <span class="hljs-number">400</span>


dataset = dataset.<span class="hljs-built_in">filter</span>(select_speaker, input_columns=[<span class="hljs-string">&quot;speaker_id&quot;</span>])`}}),We=new J({props:{code:"bGVuKHNldChkYXRhc2V0JTVCJTIyc3BlYWtlcl9pZCUyMiU1RCkp",highlighted:'<span class="hljs-built_in">len</span>(<span class="hljs-built_in">set</span>(dataset[<span class="hljs-string">&quot;speaker_id&quot;</span>]))'}}),Ne=new J({props:{code:"NDI=",highlighted:"42"}}),Re=new J({props:{code:"bGVuKGRhdGFzZXQp",highlighted:'<span class="hljs-built_in">len</span>(dataset)'}}),Ae=new J({props:{code:"OTk3Mw==",highlighted:'<span class="hljs-number">9973</span>'}}),Xe=new $({}),Qe=new J({props:{code:"aW1wb3J0JTIwb3MlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBzcGVlY2hicmFpbi5wcmV0cmFpbmVkJTIwaW1wb3J0JTIwRW5jb2RlckNsYXNzaWZpZXIlMEElMEFzcGtfbW9kZWxfbmFtZSUyMCUzRCUyMCUyMnNwZWVjaGJyYWluJTJGc3BrcmVjLXh2ZWN0LXZveGNlbGViJTIyJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUyMGlmJTIwdG9yY2guY3VkYS5pc19hdmFpbGFibGUoKSUyMGVsc2UlMjAlMjJjcHUlMjIlMEFzcGVha2VyX21vZGVsJTIwJTNEJTIwRW5jb2RlckNsYXNzaWZpZXIuZnJvbV9ocGFyYW1zKCUwQSUyMCUyMCUyMCUyMHNvdXJjZSUzRHNwa19tb2RlbF9uYW1lJTJDJTBBJTIwJTIwJTIwJTIwcnVuX29wdHMlM0QlN0IlMjJkZXZpY2UlMjIlM0ElMjBkZXZpY2UlN0QlMkMlMEElMjAlMjAlMjAlMjBzYXZlZGlyJTNEb3MucGF0aC5qb2luKCUyMiUyRnRtcCUyMiUyQyUyMHNwa19tb2RlbF9uYW1lKSUyQyUwQSklMEElMEElMEFkZWYlMjBjcmVhdGVfc3BlYWtlcl9lbWJlZGRpbmcod2F2ZWZvcm0pJTNBJTBBJTIwJTIwJTIwJTIwd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNwZWFrZXJfZW1iZWRkaW5ncyUyMCUzRCUyMHNwZWFrZXJfbW9kZWwuZW5jb2RlX2JhdGNoKHRvcmNoLnRlbnNvcih3YXZlZm9ybSkpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc3BlYWtlcl9lbWJlZGRpbmdzJTIwJTNEJTIwdG9yY2gubm4uZnVuY3Rpb25hbC5ub3JtYWxpemUoc3BlYWtlcl9lbWJlZGRpbmdzJTJDJTIwZGltJTNEMiklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzcGVha2VyX2VtYmVkZGluZ3MlMjAlM0QlMjBzcGVha2VyX2VtYmVkZGluZ3Muc3F1ZWV6ZSgpLmNwdSgpLm51bXB5KCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBzcGVha2VyX2VtYmVkZGluZ3M=",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> speechbrain.pretrained <span class="hljs-keyword">import</span> EncoderClassifier

spk_model_name = <span class="hljs-string">&quot;speechbrain/spkrec-xvect-voxceleb&quot;</span>

device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
speaker_model = EncoderClassifier.from_hparams(
    source=spk_model_name,
    run_opts={<span class="hljs-string">&quot;device&quot;</span>: device},
    savedir=os.path.join(<span class="hljs-string">&quot;/tmp&quot;</span>, spk_model_name),
)


<span class="hljs-keyword">def</span> <span class="hljs-title function_">create_speaker_embedding</span>(<span class="hljs-params">waveform</span>):
    <span class="hljs-keyword">with</span> torch.no_grad():
        speaker_embeddings = speaker_model.encode_batch(torch.tensor(waveform))
        speaker_embeddings = torch.nn.functional.normalize(speaker_embeddings, dim=<span class="hljs-number">2</span>)
        speaker_embeddings = speaker_embeddings.squeeze().cpu().numpy()
    <span class="hljs-keyword">return</span> speaker_embeddings`}}),Fe=new $({}),Se=new J({props:{code:"ZGVmJTIwcHJlcGFyZV9kYXRhc2V0KGV4YW1wbGUpJTNBJTBBJTIwJTIwJTIwJTIwYXVkaW8lMjAlM0QlMjBleGFtcGxlJTVCJTIyYXVkaW8lMjIlNUQlMEElMEElMjAlMjAlMjAlMjBleGFtcGxlJTIwJTNEJTIwcHJvY2Vzc29yKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRleHQlM0RleGFtcGxlJTVCJTIybm9ybWFsaXplZF90ZXh0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXVkaW9fdGFyZ2V0JTNEYXVkaW8lNUIlMjJhcnJheSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNhbXBsaW5nX3JhdGUlM0RhdWRpbyU1QiUyMnNhbXBsaW5nX3JhdGUlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm5fYXR0ZW50aW9uX21hc2slM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMCklMEElMEElMjAlMjAlMjAlMjAlMjMlMjBzdHJpcCUyMG9mZiUyMHRoZSUyMGJhdGNoJTIwZGltZW5zaW9uJTBBJTIwJTIwJTIwJTIwZXhhbXBsZSU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMGV4YW1wbGUlNUIlMjJsYWJlbHMlMjIlNUQlNUIwJTVEJTBBJTBBJTIwJTIwJTIwJTIwJTIzJTIwdXNlJTIwU3BlZWNoQnJhaW4lMjB0byUyMG9idGFpbiUyMHgtdmVjdG9yJTBBJTIwJTIwJTIwJTIwZXhhbXBsZSU1QiUyMnNwZWFrZXJfZW1iZWRkaW5ncyUyMiU1RCUyMCUzRCUyMGNyZWF0ZV9zcGVha2VyX2VtYmVkZGluZyhhdWRpbyU1QiUyMmFycmF5JTIyJTVEKSUwQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGV4YW1wbGU=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">prepare_dataset</span>(<span class="hljs-params">example</span>):
    audio = example[<span class="hljs-string">&quot;audio&quot;</span>]

    example = processor(
        text=example[<span class="hljs-string">&quot;normalized_text&quot;</span>],
        audio_target=audio[<span class="hljs-string">&quot;array&quot;</span>],
        sampling_rate=audio[<span class="hljs-string">&quot;sampling_rate&quot;</span>],
        return_attention_mask=<span class="hljs-literal">False</span>,
    )

    <span class="hljs-comment"># strip off the batch dimension</span>
    example[<span class="hljs-string">&quot;labels&quot;</span>] = example[<span class="hljs-string">&quot;labels&quot;</span>][<span class="hljs-number">0</span>]

    <span class="hljs-comment"># use SpeechBrain to obtain x-vector</span>
    example[<span class="hljs-string">&quot;speaker_embeddings&quot;</span>] = create_speaker_embedding(audio[<span class="hljs-string">&quot;array&quot;</span>])

    <span class="hljs-keyword">return</span> example`}}),qe=new J({props:{code:"cHJvY2Vzc2VkX2V4YW1wbGUlMjAlM0QlMjBwcmVwYXJlX2RhdGFzZXQoZGF0YXNldCU1QjAlNUQpJTBBbGlzdChwcm9jZXNzZWRfZXhhbXBsZS5rZXlzKCkp",highlighted:`processed_example = prepare_dataset(dataset[<span class="hljs-number">0</span>])
<span class="hljs-built_in">list</span>(processed_example.keys())`}}),He=new J({props:{code:"JTVCJ2lucHV0X2lkcyclMkMlMjAnbGFiZWxzJyUyQyUyMCdzdG9wX2xhYmVscyclMkMlMjAnc3BlYWtlcl9lbWJlZGRpbmdzJyU1RA==",highlighted:'[<span class="hljs-symbol">&#x27;input_ids</span>&#x27;, <span class="hljs-symbol">&#x27;labels</span>&#x27;, <span class="hljs-symbol">&#x27;stop_labels</span>&#x27;, <span class="hljs-symbol">&#x27;speaker_embeddings</span>&#x27;]'}}),De=new J({props:{code:"cHJvY2Vzc2VkX2V4YW1wbGUlNUIlMjJzcGVha2VyX2VtYmVkZGluZ3MlMjIlNUQuc2hhcGU=",highlighted:'processed_example[<span class="hljs-string">&quot;speaker_embeddings&quot;</span>].shape'}}),Pe=new J({props:{code:"KDUxMiUyQyk=",highlighted:'(<span class="hljs-number">512</span><span class="hljs-punctuation">,</span>)'}}),Oe=new J({props:{code:"aW1wb3J0JTIwbWF0cGxvdGxpYi5weXBsb3QlMjBhcyUyMHBsdCUwQSUwQXBsdC5maWd1cmUoKSUwQXBsdC5pbXNob3cocHJvY2Vzc2VkX2V4YW1wbGUlNUIlMjJsYWJlbHMlMjIlNUQuVCklMEFwbHQuc2hvdygp",highlighted:`<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

plt.figure()
plt.imshow(processed_example[<span class="hljs-string">&quot;labels&quot;</span>].T)
plt.show()`}}),Le=new J({props:{code:"ZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQubWFwKHByZXBhcmVfZGF0YXNldCUyQyUyMHJlbW92ZV9jb2x1bW5zJTNEZGF0YXNldC5jb2x1bW5fbmFtZXMp",highlighted:'dataset = dataset.<span class="hljs-built_in">map</span>(prepare_dataset, remove_columns=dataset.column_names)'}}),et=new J({props:{code:"ZGVmJTIwaXNfbm90X3Rvb19sb25nKGlucHV0X2lkcyklM0ElMEElMjAlMjAlMjAlMjBpbnB1dF9sZW5ndGglMjAlM0QlMjBsZW4oaW5wdXRfaWRzKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGlucHV0X2xlbmd0aCUyMCUzQyUyMDIwMCUwQSUwQSUwQWRhdGFzZXQlMjAlM0QlMjBkYXRhc2V0LmZpbHRlcihpc19ub3RfdG9vX2xvbmclMkMlMjBpbnB1dF9jb2x1bW5zJTNEJTVCJTIyaW5wdXRfaWRzJTIyJTVEKSUwQWxlbihkYXRhc2V0KQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">is_not_too_long</span>(<span class="hljs-params">input_ids</span>):
    input_length = <span class="hljs-built_in">len</span>(input_ids)
    <span class="hljs-keyword">return</span> input_length &lt; <span class="hljs-number">200</span>


dataset = dataset.<span class="hljs-built_in">filter</span>(is_not_too_long, input_columns=[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-built_in">len</span>(dataset)`}}),tt=new J({props:{code:"ODI1OQ==",highlighted:'<span class="hljs-number">8259</span>'}}),st=new J({props:{code:"ZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQudHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjEp",highlighted:'dataset = dataset.train_test_split(test_size=<span class="hljs-number">0.1</span>)'}}),lt=new $({}),at=new J({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyMEFueSUyQyUyMERpY3QlMkMlMjBMaXN0JTJDJTIwVW5pb24lMEElMEElMEElNDBkYXRhY2xhc3MlMEFjbGFzcyUyMFRUU0RhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTNBJTBBJTIwJTIwJTIwJTIwcHJvY2Vzc29yJTNBJTIwQW55JTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwX19jYWxsX18oJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2VsZiUyQyUyMGZlYXR1cmVzJTNBJTIwTGlzdCU1QkRpY3QlNUJzdHIlMkMlMjBVbmlvbiU1Qkxpc3QlNUJpbnQlNUQlMkMlMjB0b3JjaC5UZW5zb3IlNUQlNUQlNUQlMEElMjAlMjAlMjAlMjApJTIwLSUzRSUyMERpY3QlNUJzdHIlMkMlMjB0b3JjaC5UZW5zb3IlNUQlM0ElMEElMjAlMjA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jAlMjAlMjAlMjBiYXRjaCU1QiUyMnNwZWFrZXJfZW1iZWRkaW5ncyUyMiU1RCUyMCUzRCUyMHRvcmNoLnRlbnNvcihzcGVha2VyX2ZlYXR1cmVzKSUwQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMGJhdGNo",highlighted:`<span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Any</span>, <span class="hljs-type">Dict</span>, <span class="hljs-type">List</span>, <span class="hljs-type">Union</span>


<span class="hljs-meta">@dataclass</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">TTSDataCollatorWithPadding</span>:
    processor: <span class="hljs-type">Any</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">
        self, features: <span class="hljs-type">List</span>[<span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, <span class="hljs-type">Union</span>[<span class="hljs-type">List</span>[<span class="hljs-built_in">int</span>], torch.Tensor]]]
    </span>) -&gt; <span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, torch.Tensor]:
        input_ids = [{<span class="hljs-string">&quot;input_ids&quot;</span>: feature[<span class="hljs-string">&quot;input_ids&quot;</span>]} <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
        label_features = [{<span class="hljs-string">&quot;input_values&quot;</span>: feature[<span class="hljs-string">&quot;labels&quot;</span>]} <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
        speaker_features = [feature[<span class="hljs-string">&quot;speaker_embeddings&quot;</span>] <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]

        <span class="hljs-comment"># collate the inputs and targets into a batch</span>
        batch = processor.pad(
            input_ids=input_ids, labels=label_features, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
        )

        <span class="hljs-comment"># replace padding with -100 to ignore loss correctly</span>
        batch[<span class="hljs-string">&quot;labels&quot;</span>] = batch[<span class="hljs-string">&quot;labels&quot;</span>].masked_fill(
            batch.decoder_attention_mask.unsqueeze(-<span class="hljs-number">1</span>).ne(<span class="hljs-number">1</span>), -<span class="hljs-number">100</span>
        )

        <span class="hljs-comment"># not used during fine-tuning</span>
        <span class="hljs-keyword">del</span> batch[<span class="hljs-string">&quot;decoder_attention_mask&quot;</span>]

        <span class="hljs-comment"># round down target lengths to multiple of reduction factor</span>
        <span class="hljs-keyword">if</span> model.config.reduction_factor &gt; <span class="hljs-number">1</span>:
            target_lengths = torch.tensor(
                [<span class="hljs-built_in">len</span>(feature[<span class="hljs-string">&quot;input_values&quot;</span>]) <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> label_features]
            )
            target_lengths = target_lengths.new(
                [
                    length - length % model.config.reduction_factor
                    <span class="hljs-keyword">for</span> length <span class="hljs-keyword">in</span> target_lengths
                ]
            )
            max_length = <span class="hljs-built_in">max</span>(target_lengths)
            batch[<span class="hljs-string">&quot;labels&quot;</span>] = batch[<span class="hljs-string">&quot;labels&quot;</span>][:, :max_length]

        <span class="hljs-comment"># also add in the speaker embeddings</span>
        batch[<span class="hljs-string">&quot;speaker_embeddings&quot;</span>] = torch.tensor(speaker_features)

        <span class="hljs-keyword">return</span> batch`}}),nt=new J({props:{code:"ZGF0YV9jb2xsYXRvciUyMCUzRCUyMFRUU0RhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHByb2Nlc3NvciUzRHByb2Nlc3Nvcik=",highlighted:"data_collator = TTSDataCollatorWithPadding(processor=processor)"}}),ot=new $({}),rt=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNwZWVjaFQ1Rm9yVGV4dFRvU3BlZWNoJTBBJTBBbW9kZWwlMjAlM0QlMjBTcGVlY2hUNUZvclRleHRUb1NwZWVjaC5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SpeechT5ForTextToSpeech

model = SpeechT5ForTextToSpeech.from_pretrained(checkpoint)`}}),it=new J({props:{code:"ZnJvbSUyMGZ1bmN0b29scyUyMGltcG9ydCUyMHBhcnRpYWwlMEElMEElMjMlMjBkaXNhYmxlJTIwY2FjaGUlMjBkdXJpbmclMjB0cmFpbmluZyUyMHNpbmNlJTIwaXQncyUyMGluY29tcGF0aWJsZSUyMHdpdGglMjBncmFkaWVudCUyMGNoZWNrcG9pbnRpbmclMEFtb2RlbC5jb25maWcudXNlX2NhY2hlJTIwJTNEJTIwRmFsc2UlMEElMEElMjMlMjBzZXQlMjBsYW5ndWFnZSUyMGFuZCUyMHRhc2slMjBmb3IlMjBnZW5lcmF0aW9uJTIwYW5kJTIwcmUtZW5hYmxlJTIwY2FjaGUlMEFtb2RlbC5nZW5lcmF0ZSUyMCUzRCUyMHBhcnRpYWwobW9kZWwuZ2VuZXJhdGUlMkMlMjB1c2VfY2FjaGUlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> partial

<span class="hljs-comment"># disable cache during training since it&#x27;s incompatible with gradient checkpointing</span>
model.config.use_cache = <span class="hljs-literal">False</span>

<span class="hljs-comment"># set language and task for generation and re-enable cache</span>
model.generate = partial(model.generate, use_cache=<span class="hljs-literal">True</span>)`}}),pt=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBTZXEyU2VxVHJhaW5pbmdBcmd1bWVudHMoJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMnNwZWVjaHQ1X2ZpbmV0dW5lZF92b3hwb3B1bGlfbmwlMjIlMkMlMjAlMjAlMjMlMjBjaGFuZ2UlMjB0byUyMGElMjByZXBvJTIwbmFtZSUyMG9mJTIweW91ciUyMGNob2ljZSUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfdHJhaW5fYmF0Y2hfc2l6ZSUzRDQlMkMlMEElMjAlMjAlMjAlMjBncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0Q4JTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDFlLTUlMkMlMEElMjAlMjAlMjAlMjB3YXJtdXBfc3RlcHMlM0Q1MDAlMkMlMEElMjAlMjAlMjAlMjBtYXhfc3RlcHMlM0Q0MDAwJTJDJTBBJTIwJTIwJTIwJTIwZ3JhZGllbnRfY2hlY2twb2ludGluZyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBmcDE2JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGV2YWx1YXRpb25fc3RyYXRlZ3klM0QlMjJzdGVwcyUyMiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMiUyQyUwQSUyMCUyMCUyMCUyMHNhdmVfc3RlcHMlM0QxMDAwJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdGVwcyUzRDEwMDAlMkMlMEElMjAlMjAlMjAlMjBsb2dnaW5nX3N0ZXBzJTNEMjUlMkMlMEElMjAlMjAlMjAlMjByZXBvcnRfdG8lM0QlNUIlMjJ0ZW5zb3Jib2FyZCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGxvYWRfYmVzdF9tb2RlbF9hdF9lbmQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZ3JlYXRlcl9pc19iZXR0ZXIlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMGxhYmVsX25hbWVzJTNEJTVCJTIybGFiZWxzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcHVzaF90b19odWIlM0RUcnVlJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainingArguments

training_args = Seq2SeqTrainingArguments(
    output_dir=<span class="hljs-string">&quot;speecht5_finetuned_voxpopuli_nl&quot;</span>,  <span class="hljs-comment"># change to a repo name of your choice</span>
    per_device_train_batch_size=<span class="hljs-number">4</span>,
    gradient_accumulation_steps=<span class="hljs-number">8</span>,
    learning_rate=<span class="hljs-number">1e-5</span>,
    warmup_steps=<span class="hljs-number">500</span>,
    max_steps=<span class="hljs-number">4000</span>,
    gradient_checkpointing=<span class="hljs-literal">True</span>,
    fp16=<span class="hljs-literal">True</span>,
    evaluation_strategy=<span class="hljs-string">&quot;steps&quot;</span>,
    per_device_eval_batch_size=<span class="hljs-number">2</span>,
    save_steps=<span class="hljs-number">1000</span>,
    eval_steps=<span class="hljs-number">1000</span>,
    logging_steps=<span class="hljs-number">25</span>,
    report_to=[<span class="hljs-string">&quot;tensorboard&quot;</span>],
    load_best_model_at_end=<span class="hljs-literal">True</span>,
    greater_is_better=<span class="hljs-literal">False</span>,
    label_names=[<span class="hljs-string">&quot;labels&quot;</span>],
    push_to_hub=<span class="hljs-literal">True</span>,
)`}}),ht=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlcTJTZXFUcmFpbmVyJTBBJTBBdHJhaW5lciUyMCUzRCUyMFNlcTJTZXFUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0RkYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEcHJvY2Vzc29yJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainer

trainer = Seq2SeqTrainer(
    args=training_args,
    model=model,
    train_dataset=dataset[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=dataset[<span class="hljs-string">&quot;test&quot;</span>],
    data_collator=data_collator,
    tokenizer=processor,
)`}}),ct=new J({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:"trainer.train()"}}),ut=new J({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:"trainer.push_to_hub()"}}),mt=new $({}),dt=new J({props:{code:"bW9kZWwlMjAlM0QlMjBTcGVlY2hUNUZvclRleHRUb1NwZWVjaC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyWU9VUl9BQ0NPVU5UJTJGc3BlZWNodDVfZmluZXR1bmVkX3ZveHBvcHVsaV9ubCUyMiUwQSk=",highlighted:`model = SpeechT5ForTextToSpeech.from_pretrained(
    <span class="hljs-string">&quot;YOUR_ACCOUNT/speecht5_finetuned_voxpopuli_nl&quot;</span>
)`}}),ft=new J({props:{code:"ZXhhbXBsZSUyMCUzRCUyMGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTVCMzA0JTVEJTBBc3BlYWtlcl9lbWJlZGRpbmdzJTIwJTNEJTIwdG9yY2gudGVuc29yKGV4YW1wbGUlNUIlMjJzcGVha2VyX2VtYmVkZGluZ3MlMjIlNUQpLnVuc3F1ZWV6ZSgwKQ==",highlighted:`example = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">304</span>]
speaker_embeddings = torch.tensor(example[<span class="hljs-string">&quot;speaker_embeddings&quot;</span>]).unsqueeze(<span class="hljs-number">0</span>)`}}),Mt=new J({props:{code:"dGV4dCUyMCUzRCUyMCUyMmhhbGxvJTIwYWxsZW1hYWwlMkMlMjBpayUyMHByYWF0JTIwbmVkZXJsYW5kcy4lMjBncm9ldGplcyUyMGFhbiUyMGllZGVyZWVuISUyMg==",highlighted:'text = <span class="hljs-string">&quot;hallo allemaal, ik praat nederlands. groetjes aan iedereen!&quot;</span>'}}),yt=new J({props:{code:"aW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0R0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMik=",highlighted:'inputs = processor(text=text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)'}}),wt=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNwZWVjaFQ1SGlmaUdhbiUwQSUwQXZvY29kZXIlMjAlM0QlMjBTcGVlY2hUNUhpZmlHYW4uZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnNwZWVjaHQ1X2hpZmlnYW4lMjIpJTBBc3BlZWNoJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGVfc3BlZWNoKGlucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RCUyQyUyMHNwZWFrZXJfZW1iZWRkaW5ncyUyQyUyMHZvY29kZXIlM0R2b2NvZGVyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SpeechT5HifiGan

vocoder = SpeechT5HifiGan.from_pretrained(<span class="hljs-string">&quot;microsoft/speecht5_hifigan&quot;</span>)
speech = model.generate_speech(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>], speaker_embeddings, vocoder=vocoder)`}}),Jt=new J({props:{code:"ZnJvbSUyMElQeXRob24uZGlzcGxheSUyMGltcG9ydCUyMEF1ZGlvJTBBJTBBQXVkaW8oc3BlZWNoLm51bXB5KCklMkMlMjByYXRlJTNEMTYwMDAp",highlighted:`<span class="hljs-keyword">from</span> IPython.display <span class="hljs-keyword">import</span> Audio

Audio(speech.numpy(), rate=<span class="hljs-number">16000</span>)`}}),{c(){T=n("meta"),Y=i(),U=n("h1"),k=n("a"),Ms=n("span"),m(ce.$$.fragment),Dn=i(),ys=n("span"),Pn=h("Fine-tuning SpeechT5"),yl=i(),bt=n("p"),On=h(`Now that you are familiar with the text-to-speech task and internal workings of the SpeechT5 model that was pre-trained
on English language data, let\u2019s see how we can fine-tune it to another language.`),wl=i(),E=n("h2"),Q=n("a"),ws=n("span"),m(ue.$$.fragment),Kn=i(),Js=n("span"),Ln=h("House-keeping"),Jl=h(`

Make sure that you have a GPU if you want to reproduce this example. In a notebook, you can check with the following command:

	`),m(me.$$.fragment),Tl=i(),m(z.$$.fragment),bl=i(),Ut=n("p"),eo=h("You\u2019ll also need some additional dependencies:"),Ul=i(),m(de.$$.fragment),jl=i(),jt=n("p"),to=h("Finally, don\u2019t forget to log in to your Hugging Face account so that you could upload and share your model with the community:"),kl=i(),m(fe.$$.fragment),Il=i(),x=n("h2"),F=n("a"),Ts=n("span"),m(Me.$$.fragment),so=i(),bs=n("span"),lo=h("The dataset"),gl=i(),I=n("p"),ao=h("For this example we\u2019ll take the Dutch ("),Us=n("code"),no=h("nl"),oo=h(") language subset of the "),ye=n("a"),ro=h("VoxPopuli"),io=h(` dataset.
`),we=n("a"),po=h("VoxPopuli"),ho=h(` is a large-scale multilingual speech corpus consisting of
data sourced from 2009-2020 European Parliament event recordings. It contains labelled audio-transcription data for 15
European languages. While we will be using the Dutch language subset, feel free to pick another subset.`),vl=i(),kt=n("p"),co=h(`This is an automated speech recognition (ASR) dataset, so, as mentioned before, it is not the most suitable
option for training TTS models. However, it will be good enough for this exercise.`),$l=i(),It=n("p"),uo=h("Let\u2019s load the data:"),_l=i(),m(Je.$$.fragment),Cl=i(),gt=n("p"),js=n("strong"),mo=h("Output:"),Zl=i(),m(Te.$$.fragment),El=i(),vt=n("p"),fo=h(`20968 examples should be sufficient for fine-tuning. SpeechT5 expects audio data to have a sampling rate of 16 kHz, so
make sure the examples in the dataset meet this requirement:`),xl=i(),m(be.$$.fragment),Gl=i(),G=n("h2"),S=n("a"),ks=n("span"),m(Ue.$$.fragment),Mo=i(),Is=n("span"),yo=h("Preprocessing the data"),Vl=i(),$t=n("p"),wo=h(`Let\u2019s begin by defining the model checkpoint to use and loading the appropriate processor that contains both tokenizer,
and feature extractor that we will need to prepare the data for training:`),Bl=i(),m(je.$$.fragment),Wl=i(),V=n("h3"),q=n("a"),gs=n("span"),m(ke.$$.fragment),Jo=i(),vs=n("span"),To=h("Text cleanup for SpeechT5 tokenization"),Nl=i(),_t=n("p"),bo=h("First, for preparing the text, we\u2019ll need the tokenizer part of the processor, so let\u2019s get it:"),Rl=i(),m(Ie.$$.fragment),Al=i(),Ct=n("p"),Uo=h("Let\u2019s take a look at an example:"),Xl=i(),m(ge.$$.fragment),Yl=i(),Zt=n("p"),$s=n("strong"),jo=h("Output:"),Ql=i(),m(ve.$$.fragment),zl=i(),j=n("p"),ko=h("What you may notice is that the dataset examples contain "),_s=n("code"),Io=h("raw_text"),go=h(" and "),Cs=n("code"),vo=h("normalized_text"),$o=h(` features. When deciding which
feature to use as the text input, it will be important to know that the SpeechT5 tokenizer doesn\u2019t have any tokens for
numbers. In `),Zs=n("code"),_o=h("normalized_text"),Co=h(" the numbers are written out as text. Thus, it is a better fit, and we should use "),Es=n("code"),Zo=h("normalized_text"),Eo=h(`
as input text.`),Fl=i(),g=n("p"),xo=h(`Because SpeechT5 was trained on the English language, it may not recognize certain characters in the Dutch dataset. If
left as is, these characters will be converted to `),xs=n("code"),Go=h("<unk>"),Vo=h(" tokens. However, in Dutch, certain characters like "),Gs=n("code"),Bo=h("\xE0"),Wo=h(` are
used to stress syllables. In order to preserve the meaning of the text, we can replace this character with a regular `),Vs=n("code"),No=h("a"),Ro=h("."),Sl=i(),b=n("p"),Ao=h("To identify unsupported tokens, extract all unique characters in the dataset using the "),Bs=n("code"),Xo=h("SpeechT5Tokenizer"),Yo=h(` which
works with characters as tokens. To do this, we\u2019ll write the `),Ws=n("code"),Qo=h("extract_all_chars"),zo=h(` mapping function that concatenates
the transcriptions from all examples into one string and converts it to a set of characters.
Make sure to set `),Ns=n("code"),Fo=h("batched=True"),So=h(" and "),Rs=n("code"),qo=h("batch_size=-1"),Ho=h(" in "),As=n("code"),Do=h("dataset.map()"),Po=h(` so that all transcriptions are available at once for
the mapping function.`),ql=i(),m($e.$$.fragment),Hl=i(),Et=n("p"),Oo=h(`Now you have two sets of characters: one with the vocabulary from the dataset and one with the vocabulary from the tokenizer.
To identify any unsupported characters in the dataset, you can take the difference between these two sets. The resulting
set will contain the characters that are in the dataset but not in the tokenizer.`),Dl=i(),m(_e.$$.fragment),Pl=i(),xt=n("p"),Xs=n("strong"),Ko=h("Output:"),Ol=i(),m(Ce.$$.fragment),Kl=i(),H=n("p"),Lo=h(`To handle the unsupported characters identified in the previous step, we can define a function that maps these characters to
valid tokens. Note that spaces are already replaced by `),Ys=n("code"),er=h("\u2581"),tr=h(" in the tokenizer and don\u2019t need to be handled separately."),Ll=i(),m(Ze.$$.fragment),ea=i(),Gt=n("p"),sr=h("Now that we have dealt with special characters in the text, it\u2019s time to shift the focus to the audio data."),ta=i(),B=n("h3"),D=n("a"),Qs=n("span"),m(Ee.$$.fragment),lr=i(),zs=n("span"),ar=h("Speakers"),sa=i(),Vt=n("p"),nr=h(`The VoxPopuli dataset includes speech from multiple speakers, but how many speakers are represented in the dataset? To
determine this, we can count the number of unique speakers and the number of examples each speaker contributes to the dataset.
With a total of 20,968 examples in the dataset, this information will give us a better understanding of the distribution of
speakers and examples in the data.`),la=i(),m(xe.$$.fragment),aa=i(),Bt=n("p"),or=h("By plotting a histogram you can get a sense of how much data there is for each speaker."),na=i(),m(Ge.$$.fragment),oa=i(),Ve=n("div"),Wt=n("img"),ra=i(),Nt=n("p"),rr=h(`The histogram reveals that approximately one-third of the speakers in the dataset have fewer than 100 examples, while
around ten speakers have more than 500 examples. To improve training efficiency and balance the dataset, we can limit
the data to speakers with between 100 and 400 examples.`),ia=i(),m(Be.$$.fragment),pa=i(),Rt=n("p"),ir=h("Let\u2019s check how many speakers remain:"),ha=i(),m(We.$$.fragment),ca=i(),At=n("p"),Fs=n("strong"),pr=h("Output:"),ua=i(),m(Ne.$$.fragment),ma=i(),Xt=n("p"),hr=h("Let\u2019s see how many examples are left:"),da=i(),m(Re.$$.fragment),fa=i(),Yt=n("p"),Ss=n("strong"),cr=h("Output:"),Ma=i(),m(Ae.$$.fragment),ya=i(),Qt=n("p"),ur=h("You are left with just under 10,000 examples from approximately 40 unique speakers, which should be sufficient."),wa=i(),zt=n("p"),mr=h(`Note that some speakers with few examples may actually have more audio available if the examples are long. However,
determining the total amount of audio for each speaker requires scanning through the entire dataset, which is a
time-consuming process that involves loading and decoding each audio file. As such, we have chosen to skip this step here.`),Ja=i(),W=n("h3"),P=n("a"),qs=n("span"),m(Xe.$$.fragment),dr=i(),Hs=n("span"),fr=h("Speaker embeddings"),Ta=i(),O=n("p"),Mr=h(`To enable the TTS model to differentiate between multiple speakers, you\u2019ll need to create a speaker embedding for each example.
The speaker embedding is an additional input into the model that captures a particular speaker\u2019s voice characteristics.
To generate these speaker embeddings, use the pre-trained `),Ye=n("a"),yr=h("spkrec-xvect-voxceleb"),wr=h(`
model from SpeechBrain.`),ba=i(),K=n("p"),Jr=h("Create a function "),Ds=n("code"),Tr=h("create_speaker_embedding()"),br=h(` that takes an input audio waveform and outputs a 512-element vector
containing the corresponding speaker embedding.`),Ua=i(),m(Qe.$$.fragment),ja=i(),L=n("p"),Ur=h("It\u2019s important to note that the "),Ps=n("code"),jr=h("speechbrain/spkrec-xvect-voxceleb"),kr=h(` model was trained on English speech from the VoxCeleb
dataset, whereas the training examples in this guide are in Dutch. While we believe that this model will still generate
reasonable speaker embeddings for our Dutch dataset, this assumption may not hold true in all cases.`),ka=i(),ee=n("p"),Ir=h(`For optimal results, we would need to train an X-vector model on the target speech first. This will ensure that the model
is better able to capture the unique voice characteristics present in the Dutch language. If you\u2019d like to train your own
X-vector model, you can use `),ze=n("a"),gr=h("this script"),vr=h(`
as an example.`),Ia=i(),N=n("h3"),te=n("a"),Os=n("span"),m(Fe.$$.fragment),$r=i(),Ks=n("span"),_r=h("Processing the dataset"),ga=i(),_=n("p"),Cr=h("Finally, let\u2019s process the data into the format the model expects. Create a "),Ls=n("code"),Zr=h("prepare_dataset"),Er=h(` function that takes in a
single example and uses the `),el=n("code"),xr=h("SpeechT5Processor"),Gr=h(` object to tokenize the input text and load the target audio into a log-mel spectrogram.
It should also add the speaker embeddings as an additional input.`),va=i(),m(Se.$$.fragment),$a=i(),Ft=n("p"),Vr=h("Verify the processing is correct by looking at a single example:"),_a=i(),m(qe.$$.fragment),Ca=i(),St=n("p"),tl=n("strong"),Br=h("Output:"),Za=i(),m(He.$$.fragment),Ea=i(),qt=n("p"),Wr=h("Speaker embeddings should be a 512-element vector:"),xa=i(),m(De.$$.fragment),Ga=i(),Ht=n("p"),sl=n("strong"),Nr=h("Output:"),Va=i(),m(Pe.$$.fragment),Ba=i(),Dt=n("p"),Rr=h("The labels should be a log-mel spectrogram with 80 mel bins."),Wa=i(),m(Oe.$$.fragment),Na=i(),Ke=n("div"),Pt=n("img"),Ra=i(),Ot=n("p"),Ar=h(`Side note: If you find this spectrogram confusing, it may be due to your familiarity with the convention of placing low frequencies
at the bottom and high frequencies at the top of a plot. However, when plotting spectrograms as an image using the matplotlib library,
the y-axis is flipped and the spectrograms appear upside down.`),Aa=i(),Kt=n("p"),Xr=h("Now we need to apply the processing function to the entire dataset. This will take between 5 and 10 minutes."),Xa=i(),m(Le.$$.fragment),Ya=i(),Lt=n("p"),Yr=h(`You\u2019ll see a warning saying that some examples in the dataset are longer than the maximum input length the model can handle (600 tokens).
Remove those examples from the dataset. Here we go even further and to allow for larger batch sizes we remove anything over 200 tokens.`),Qa=i(),m(et.$$.fragment),za=i(),es=n("p"),ll=n("strong"),Qr=h("Output:"),Fa=i(),m(tt.$$.fragment),Sa=i(),ts=n("p"),zr=h("Next, create a basic train/test split:"),qa=i(),m(st.$$.fragment),Ha=i(),R=n("h3"),se=n("a"),al=n("span"),m(lt.$$.fragment),Fr=i(),nl=n("span"),Sr=h("Data collator"),Da=i(),le=n("p"),qr=h(`In order to combine multiple examples into a batch, you need to define a custom data collator. This collator will pad shorter sequences with padding
tokens, ensuring that all examples have the same length. For the spectrogram labels, the padded portions are replaced with
the special value `),ol=n("code"),Hr=h("-100"),Dr=h(". This special value instructs the model to ignore that part of the spectrogram when calculating the spectrogram loss."),Pa=i(),m(at.$$.fragment),Oa=i(),ss=n("p"),Pr=h(`In SpeechT5, the input to the decoder part of the model is reduced by a factor 2. In other words, it throws away every
other timestep from the target sequence. The decoder then predicts a sequence that is twice as long. Since the original
target sequence length may be odd, the data collator makes sure to round the maximum length of the batch down to be a
multiple of 2.`),Ka=i(),m(nt.$$.fragment),La=i(),A=n("h2"),ae=n("a"),rl=n("span"),m(ot.$$.fragment),Or=i(),il=n("span"),Kr=h("Train the model"),en=i(),ls=n("p"),Lr=h("Load the pre-trained model from the same checkpoint as you used for loading the processor:"),tn=i(),m(rt.$$.fragment),sn=i(),ne=n("p"),ei=h("The "),pl=n("code"),ti=h("use_cache=True"),si=h(` option is incompatible with gradient checkpointing. Disable it for training, and re-enable cache for
generation to speed-up inference time:`),ln=i(),m(it.$$.fragment),an=i(),as=n("p"),li=h(`Define the training arguments. Here we are not computing any evaluation metrics during the training process,
we\u2019ll talk about evaluation later in this chapter. Instead, we\u2019ll only look at the loss:`),nn=i(),m(pt.$$.fragment),on=i(),oe=n("p"),ai=h("Instantiate the "),hl=n("code"),ni=h("Trainer"),oi=h(" object  and pass the model, dataset, and data collator to it."),rn=i(),m(ht.$$.fragment),pn=i(),C=n("p"),ri=h(`And with that, we\u2019re ready to start training! Training will take several hours. Depending on your GPU,
it is possible that you will encounter a CUDA \u201Cout-of-memory\u201D error when you start training. In this case, you can reduce
the `),cl=n("code"),ii=h("per_device_train_batch_size"),pi=h(" incrementally by factors of 2 and increase "),ul=n("code"),hi=h("gradient_accumulation_steps"),ci=h(" by 2x to compensate."),hn=i(),m(ct.$$.fragment),cn=i(),ns=n("p"),ui=h("Push the final model to the \u{1F917} Hub:"),un=i(),m(ut.$$.fragment),mn=i(),X=n("h2"),re=n("a"),ml=n("span"),m(mt.$$.fragment),mi=i(),dl=n("span"),di=h("Inference"),dn=i(),os=n("p"),fi=h(`Once you have fine-tuned a model, you can use it for inference! Load the model from the \u{1F917} Hub (make sure to use your
account name in the following code snippet):`),fn=i(),m(dt.$$.fragment),Mn=i(),rs=n("p"),Mi=h("Pick an example, here we\u2019ll take one from the test dataset. Obtain a speaker embedding."),yn=i(),m(ft.$$.fragment),wn=i(),is=n("p"),yi=h("Define some input text and tokenize it."),Jn=i(),m(Mt.$$.fragment),Tn=i(),ps=n("p"),wi=h("Preprocess the input text:"),bn=i(),m(yt.$$.fragment),Un=i(),hs=n("p"),Ji=h("Instantiate a vocoder and generate speech:"),jn=i(),m(wt.$$.fragment),kn=i(),cs=n("p"),Ti=h("Ready to listen to the result?"),In=i(),m(Jt.$$.fragment),gn=i(),us=n("p"),bi=h(`Obtaining satisfactory results from this model on a new language can be challenging. The quality of the speaker
embeddings can be a significant factor. Since SpeechT5 was pre-trained with English x-vectors, it performs best
when using English speaker embeddings. If the synthesized speech sounds poor, try using a different speaker embedding.`),vn=i(),ie=n("p"),Ui=h(`Increasing the training duration is also likely to enhance the quality of the results. Even so, the speech clearly is Dutch instead of English, and it does
capture the voice characteristics of the speaker (compare to the original audio in the example).
Another thing to experiment with is the model\u2019s configuration. For example, try using `),fl=n("code"),ji=h("config.reduction_factor = 1"),ki=h(` to
see if this improves the results.`),$n=i(),ms=n("p"),Ii=h("In the next section, we\u2019ll talk about how we evaluate text-to-speech models."),this.h()},l(e){const s=Ah('[data-svelte="svelte-1phssyn"]',document.head);T=o(s,"META",{name:!0,content:!0}),s.forEach(t),Y=p(e),U=o(e,"H1",{class:!0});var Tt=r(U);k=o(Tt,"A",{id:!0,class:!0,href:!0});var $i=r(k);Ms=o($i,"SPAN",{});var _i=r(Ms);d(ce.$$.fragment,_i),_i.forEach(t),$i.forEach(t),Dn=p(Tt),ys=o(Tt,"SPAN",{});var Ci=r(ys);Pn=c(Ci,"Fine-tuning SpeechT5"),Ci.forEach(t),Tt.forEach(t),yl=p(e),bt=o(e,"P",{});var Zi=r(bt);On=c(Zi,`Now that you are familiar with the text-to-speech task and internal workings of the SpeechT5 model that was pre-trained
on English language data, let\u2019s see how we can fine-tune it to another language.`),Zi.forEach(t),wl=p(e),E=o(e,"H2",{class:!0});var Cn=r(E);Q=o(Cn,"A",{id:!0,class:!0,href:!0});var Ei=r(Q);ws=o(Ei,"SPAN",{});var xi=r(ws);d(ue.$$.fragment,xi),xi.forEach(t),Ei.forEach(t),Kn=p(Cn),Js=o(Cn,"SPAN",{});var Gi=r(Js);Ln=c(Gi,"House-keeping"),Gi.forEach(t),Cn.forEach(t),Jl=c(e,`

Make sure that you have a GPU if you want to reproduce this example. In a notebook, you can check with the following command:

	`),d(me.$$.fragment,e),Tl=p(e),d(z.$$.fragment,e),bl=p(e),Ut=o(e,"P",{});var Vi=r(Ut);eo=c(Vi,"You\u2019ll also need some additional dependencies:"),Vi.forEach(t),Ul=p(e),d(de.$$.fragment,e),jl=p(e),jt=o(e,"P",{});var Bi=r(jt);to=c(Bi,"Finally, don\u2019t forget to log in to your Hugging Face account so that you could upload and share your model with the community:"),Bi.forEach(t),kl=p(e),d(fe.$$.fragment,e),Il=p(e),x=o(e,"H2",{class:!0});var Zn=r(x);F=o(Zn,"A",{id:!0,class:!0,href:!0});var Wi=r(F);Ts=o(Wi,"SPAN",{});var Ni=r(Ts);d(Me.$$.fragment,Ni),Ni.forEach(t),Wi.forEach(t),so=p(Zn),bs=o(Zn,"SPAN",{});var Ri=r(bs);lo=c(Ri,"The dataset"),Ri.forEach(t),Zn.forEach(t),gl=p(e),I=o(e,"P",{});var pe=r(I);ao=c(pe,"For this example we\u2019ll take the Dutch ("),Us=o(pe,"CODE",{});var Ai=r(Us);no=c(Ai,"nl"),Ai.forEach(t),oo=c(pe,") language subset of the "),ye=o(pe,"A",{href:!0,rel:!0});var Xi=r(ye);ro=c(Xi,"VoxPopuli"),Xi.forEach(t),io=c(pe,` dataset.
`),we=o(pe,"A",{href:!0,rel:!0});var Yi=r(we);po=c(Yi,"VoxPopuli"),Yi.forEach(t),ho=c(pe,` is a large-scale multilingual speech corpus consisting of
data sourced from 2009-2020 European Parliament event recordings. It contains labelled audio-transcription data for 15
European languages. While we will be using the Dutch language subset, feel free to pick another subset.`),pe.forEach(t),vl=p(e),kt=o(e,"P",{});var Qi=r(kt);co=c(Qi,`This is an automated speech recognition (ASR) dataset, so, as mentioned before, it is not the most suitable
option for training TTS models. However, it will be good enough for this exercise.`),Qi.forEach(t),$l=p(e),It=o(e,"P",{});var zi=r(It);uo=c(zi,"Let\u2019s load the data:"),zi.forEach(t),_l=p(e),d(Je.$$.fragment,e),Cl=p(e),gt=o(e,"P",{});var Fi=r(gt);js=o(Fi,"STRONG",{});var Si=r(js);mo=c(Si,"Output:"),Si.forEach(t),Fi.forEach(t),Zl=p(e),d(Te.$$.fragment,e),El=p(e),vt=o(e,"P",{});var qi=r(vt);fo=c(qi,`20968 examples should be sufficient for fine-tuning. SpeechT5 expects audio data to have a sampling rate of 16 kHz, so
make sure the examples in the dataset meet this requirement:`),qi.forEach(t),xl=p(e),d(be.$$.fragment,e),Gl=p(e),G=o(e,"H2",{class:!0});var En=r(G);S=o(En,"A",{id:!0,class:!0,href:!0});var Hi=r(S);ks=o(Hi,"SPAN",{});var Di=r(ks);d(Ue.$$.fragment,Di),Di.forEach(t),Hi.forEach(t),Mo=p(En),Is=o(En,"SPAN",{});var Pi=r(Is);yo=c(Pi,"Preprocessing the data"),Pi.forEach(t),En.forEach(t),Vl=p(e),$t=o(e,"P",{});var Oi=r($t);wo=c(Oi,`Let\u2019s begin by defining the model checkpoint to use and loading the appropriate processor that contains both tokenizer,
and feature extractor that we will need to prepare the data for training:`),Oi.forEach(t),Bl=p(e),d(je.$$.fragment,e),Wl=p(e),V=o(e,"H3",{class:!0});var xn=r(V);q=o(xn,"A",{id:!0,class:!0,href:!0});var Ki=r(q);gs=o(Ki,"SPAN",{});var Li=r(gs);d(ke.$$.fragment,Li),Li.forEach(t),Ki.forEach(t),Jo=p(xn),vs=o(xn,"SPAN",{});var ep=r(vs);To=c(ep,"Text cleanup for SpeechT5 tokenization"),ep.forEach(t),xn.forEach(t),Nl=p(e),_t=o(e,"P",{});var tp=r(_t);bo=c(tp,"First, for preparing the text, we\u2019ll need the tokenizer part of the processor, so let\u2019s get it:"),tp.forEach(t),Rl=p(e),d(Ie.$$.fragment,e),Al=p(e),Ct=o(e,"P",{});var sp=r(Ct);Uo=c(sp,"Let\u2019s take a look at an example:"),sp.forEach(t),Xl=p(e),d(ge.$$.fragment,e),Yl=p(e),Zt=o(e,"P",{});var lp=r(Zt);$s=o(lp,"STRONG",{});var ap=r($s);jo=c(ap,"Output:"),ap.forEach(t),lp.forEach(t),Ql=p(e),d(ve.$$.fragment,e),zl=p(e),j=o(e,"P",{});var Z=r(j);ko=c(Z,"What you may notice is that the dataset examples contain "),_s=o(Z,"CODE",{});var np=r(_s);Io=c(np,"raw_text"),np.forEach(t),go=c(Z," and "),Cs=o(Z,"CODE",{});var op=r(Cs);vo=c(op,"normalized_text"),op.forEach(t),$o=c(Z,` features. When deciding which
feature to use as the text input, it will be important to know that the SpeechT5 tokenizer doesn\u2019t have any tokens for
numbers. In `),Zs=o(Z,"CODE",{});var rp=r(Zs);_o=c(rp,"normalized_text"),rp.forEach(t),Co=c(Z," the numbers are written out as text. Thus, it is a better fit, and we should use "),Es=o(Z,"CODE",{});var ip=r(Es);Zo=c(ip,"normalized_text"),ip.forEach(t),Eo=c(Z,`
as input text.`),Z.forEach(t),Fl=p(e),g=o(e,"P",{});var he=r(g);xo=c(he,`Because SpeechT5 was trained on the English language, it may not recognize certain characters in the Dutch dataset. If
left as is, these characters will be converted to `),xs=o(he,"CODE",{});var pp=r(xs);Go=c(pp,"<unk>"),pp.forEach(t),Vo=c(he," tokens. However, in Dutch, certain characters like "),Gs=o(he,"CODE",{});var hp=r(Gs);Bo=c(hp,"\xE0"),hp.forEach(t),Wo=c(he,` are
used to stress syllables. In order to preserve the meaning of the text, we can replace this character with a regular `),Vs=o(he,"CODE",{});var cp=r(Vs);No=c(cp,"a"),cp.forEach(t),Ro=c(he,"."),he.forEach(t),Sl=p(e),b=o(e,"P",{});var v=r(b);Ao=c(v,"To identify unsupported tokens, extract all unique characters in the dataset using the "),Bs=o(v,"CODE",{});var up=r(Bs);Xo=c(up,"SpeechT5Tokenizer"),up.forEach(t),Yo=c(v,` which
works with characters as tokens. To do this, we\u2019ll write the `),Ws=o(v,"CODE",{});var mp=r(Ws);Qo=c(mp,"extract_all_chars"),mp.forEach(t),zo=c(v,` mapping function that concatenates
the transcriptions from all examples into one string and converts it to a set of characters.
Make sure to set `),Ns=o(v,"CODE",{});var dp=r(Ns);Fo=c(dp,"batched=True"),dp.forEach(t),So=c(v," and "),Rs=o(v,"CODE",{});var fp=r(Rs);qo=c(fp,"batch_size=-1"),fp.forEach(t),Ho=c(v," in "),As=o(v,"CODE",{});var Mp=r(As);Do=c(Mp,"dataset.map()"),Mp.forEach(t),Po=c(v,` so that all transcriptions are available at once for
the mapping function.`),v.forEach(t),ql=p(e),d($e.$$.fragment,e),Hl=p(e),Et=o(e,"P",{});var yp=r(Et);Oo=c(yp,`Now you have two sets of characters: one with the vocabulary from the dataset and one with the vocabulary from the tokenizer.
To identify any unsupported characters in the dataset, you can take the difference between these two sets. The resulting
set will contain the characters that are in the dataset but not in the tokenizer.`),yp.forEach(t),Dl=p(e),d(_e.$$.fragment,e),Pl=p(e),xt=o(e,"P",{});var wp=r(xt);Xs=o(wp,"STRONG",{});var Jp=r(Xs);Ko=c(Jp,"Output:"),Jp.forEach(t),wp.forEach(t),Ol=p(e),d(Ce.$$.fragment,e),Kl=p(e),H=o(e,"P",{});var Gn=r(H);Lo=c(Gn,`To handle the unsupported characters identified in the previous step, we can define a function that maps these characters to
valid tokens. Note that spaces are already replaced by `),Ys=o(Gn,"CODE",{});var Tp=r(Ys);er=c(Tp,"\u2581"),Tp.forEach(t),tr=c(Gn," in the tokenizer and don\u2019t need to be handled separately."),Gn.forEach(t),Ll=p(e),d(Ze.$$.fragment,e),ea=p(e),Gt=o(e,"P",{});var bp=r(Gt);sr=c(bp,"Now that we have dealt with special characters in the text, it\u2019s time to shift the focus to the audio data."),bp.forEach(t),ta=p(e),B=o(e,"H3",{class:!0});var Vn=r(B);D=o(Vn,"A",{id:!0,class:!0,href:!0});var Up=r(D);Qs=o(Up,"SPAN",{});var jp=r(Qs);d(Ee.$$.fragment,jp),jp.forEach(t),Up.forEach(t),lr=p(Vn),zs=o(Vn,"SPAN",{});var kp=r(zs);ar=c(kp,"Speakers"),kp.forEach(t),Vn.forEach(t),sa=p(e),Vt=o(e,"P",{});var Ip=r(Vt);nr=c(Ip,`The VoxPopuli dataset includes speech from multiple speakers, but how many speakers are represented in the dataset? To
determine this, we can count the number of unique speakers and the number of examples each speaker contributes to the dataset.
With a total of 20,968 examples in the dataset, this information will give us a better understanding of the distribution of
speakers and examples in the data.`),Ip.forEach(t),la=p(e),d(xe.$$.fragment,e),aa=p(e),Bt=o(e,"P",{});var gp=r(Bt);or=c(gp,"By plotting a histogram you can get a sense of how much data there is for each speaker."),gp.forEach(t),na=p(e),d(Ge.$$.fragment,e),oa=p(e),Ve=o(e,"DIV",{class:!0});var vp=r(Ve);Wt=o(vp,"IMG",{src:!0,alt:!0}),vp.forEach(t),ra=p(e),Nt=o(e,"P",{});var $p=r(Nt);rr=c($p,`The histogram reveals that approximately one-third of the speakers in the dataset have fewer than 100 examples, while
around ten speakers have more than 500 examples. To improve training efficiency and balance the dataset, we can limit
the data to speakers with between 100 and 400 examples.`),$p.forEach(t),ia=p(e),d(Be.$$.fragment,e),pa=p(e),Rt=o(e,"P",{});var _p=r(Rt);ir=c(_p,"Let\u2019s check how many speakers remain:"),_p.forEach(t),ha=p(e),d(We.$$.fragment,e),ca=p(e),At=o(e,"P",{});var Cp=r(At);Fs=o(Cp,"STRONG",{});var Zp=r(Fs);pr=c(Zp,"Output:"),Zp.forEach(t),Cp.forEach(t),ua=p(e),d(Ne.$$.fragment,e),ma=p(e),Xt=o(e,"P",{});var Ep=r(Xt);hr=c(Ep,"Let\u2019s see how many examples are left:"),Ep.forEach(t),da=p(e),d(Re.$$.fragment,e),fa=p(e),Yt=o(e,"P",{});var xp=r(Yt);Ss=o(xp,"STRONG",{});var Gp=r(Ss);cr=c(Gp,"Output:"),Gp.forEach(t),xp.forEach(t),Ma=p(e),d(Ae.$$.fragment,e),ya=p(e),Qt=o(e,"P",{});var Vp=r(Qt);ur=c(Vp,"You are left with just under 10,000 examples from approximately 40 unique speakers, which should be sufficient."),Vp.forEach(t),wa=p(e),zt=o(e,"P",{});var Bp=r(zt);mr=c(Bp,`Note that some speakers with few examples may actually have more audio available if the examples are long. However,
determining the total amount of audio for each speaker requires scanning through the entire dataset, which is a
time-consuming process that involves loading and decoding each audio file. As such, we have chosen to skip this step here.`),Bp.forEach(t),Ja=p(e),W=o(e,"H3",{class:!0});var Bn=r(W);P=o(Bn,"A",{id:!0,class:!0,href:!0});var Wp=r(P);qs=o(Wp,"SPAN",{});var Np=r(qs);d(Xe.$$.fragment,Np),Np.forEach(t),Wp.forEach(t),dr=p(Bn),Hs=o(Bn,"SPAN",{});var Rp=r(Hs);fr=c(Rp,"Speaker embeddings"),Rp.forEach(t),Bn.forEach(t),Ta=p(e),O=o(e,"P",{});var Wn=r(O);Mr=c(Wn,`To enable the TTS model to differentiate between multiple speakers, you\u2019ll need to create a speaker embedding for each example.
The speaker embedding is an additional input into the model that captures a particular speaker\u2019s voice characteristics.
To generate these speaker embeddings, use the pre-trained `),Ye=o(Wn,"A",{href:!0,rel:!0});var Ap=r(Ye);yr=c(Ap,"spkrec-xvect-voxceleb"),Ap.forEach(t),wr=c(Wn,`
model from SpeechBrain.`),Wn.forEach(t),ba=p(e),K=o(e,"P",{});var Nn=r(K);Jr=c(Nn,"Create a function "),Ds=o(Nn,"CODE",{});var Xp=r(Ds);Tr=c(Xp,"create_speaker_embedding()"),Xp.forEach(t),br=c(Nn,` that takes an input audio waveform and outputs a 512-element vector
containing the corresponding speaker embedding.`),Nn.forEach(t),Ua=p(e),d(Qe.$$.fragment,e),ja=p(e),L=o(e,"P",{});var Rn=r(L);Ur=c(Rn,"It\u2019s important to note that the "),Ps=o(Rn,"CODE",{});var Yp=r(Ps);jr=c(Yp,"speechbrain/spkrec-xvect-voxceleb"),Yp.forEach(t),kr=c(Rn,` model was trained on English speech from the VoxCeleb
dataset, whereas the training examples in this guide are in Dutch. While we believe that this model will still generate
reasonable speaker embeddings for our Dutch dataset, this assumption may not hold true in all cases.`),Rn.forEach(t),ka=p(e),ee=o(e,"P",{});var An=r(ee);Ir=c(An,`For optimal results, we would need to train an X-vector model on the target speech first. This will ensure that the model
is better able to capture the unique voice characteristics present in the Dutch language. If you\u2019d like to train your own
X-vector model, you can use `),ze=o(An,"A",{href:!0,rel:!0});var Qp=r(ze);gr=c(Qp,"this script"),Qp.forEach(t),vr=c(An,`
as an example.`),An.forEach(t),Ia=p(e),N=o(e,"H3",{class:!0});var Xn=r(N);te=o(Xn,"A",{id:!0,class:!0,href:!0});var zp=r(te);Os=o(zp,"SPAN",{});var Fp=r(Os);d(Fe.$$.fragment,Fp),Fp.forEach(t),zp.forEach(t),$r=p(Xn),Ks=o(Xn,"SPAN",{});var Sp=r(Ks);_r=c(Sp,"Processing the dataset"),Sp.forEach(t),Xn.forEach(t),ga=p(e),_=o(e,"P",{});var ds=r(_);Cr=c(ds,"Finally, let\u2019s process the data into the format the model expects. Create a "),Ls=o(ds,"CODE",{});var qp=r(Ls);Zr=c(qp,"prepare_dataset"),qp.forEach(t),Er=c(ds,` function that takes in a
single example and uses the `),el=o(ds,"CODE",{});var Hp=r(el);xr=c(Hp,"SpeechT5Processor"),Hp.forEach(t),Gr=c(ds,` object to tokenize the input text and load the target audio into a log-mel spectrogram.
It should also add the speaker embeddings as an additional input.`),ds.forEach(t),va=p(e),d(Se.$$.fragment,e),$a=p(e),Ft=o(e,"P",{});var Dp=r(Ft);Vr=c(Dp,"Verify the processing is correct by looking at a single example:"),Dp.forEach(t),_a=p(e),d(qe.$$.fragment,e),Ca=p(e),St=o(e,"P",{});var Pp=r(St);tl=o(Pp,"STRONG",{});var Op=r(tl);Br=c(Op,"Output:"),Op.forEach(t),Pp.forEach(t),Za=p(e),d(He.$$.fragment,e),Ea=p(e),qt=o(e,"P",{});var Kp=r(qt);Wr=c(Kp,"Speaker embeddings should be a 512-element vector:"),Kp.forEach(t),xa=p(e),d(De.$$.fragment,e),Ga=p(e),Ht=o(e,"P",{});var Lp=r(Ht);sl=o(Lp,"STRONG",{});var eh=r(sl);Nr=c(eh,"Output:"),eh.forEach(t),Lp.forEach(t),Va=p(e),d(Pe.$$.fragment,e),Ba=p(e),Dt=o(e,"P",{});var th=r(Dt);Rr=c(th,"The labels should be a log-mel spectrogram with 80 mel bins."),th.forEach(t),Wa=p(e),d(Oe.$$.fragment,e),Na=p(e),Ke=o(e,"DIV",{class:!0});var sh=r(Ke);Pt=o(sh,"IMG",{src:!0,alt:!0}),sh.forEach(t),Ra=p(e),Ot=o(e,"P",{});var lh=r(Ot);Ar=c(lh,`Side note: If you find this spectrogram confusing, it may be due to your familiarity with the convention of placing low frequencies
at the bottom and high frequencies at the top of a plot. However, when plotting spectrograms as an image using the matplotlib library,
the y-axis is flipped and the spectrograms appear upside down.`),lh.forEach(t),Aa=p(e),Kt=o(e,"P",{});var ah=r(Kt);Xr=c(ah,"Now we need to apply the processing function to the entire dataset. This will take between 5 and 10 minutes."),ah.forEach(t),Xa=p(e),d(Le.$$.fragment,e),Ya=p(e),Lt=o(e,"P",{});var nh=r(Lt);Yr=c(nh,`You\u2019ll see a warning saying that some examples in the dataset are longer than the maximum input length the model can handle (600 tokens).
Remove those examples from the dataset. Here we go even further and to allow for larger batch sizes we remove anything over 200 tokens.`),nh.forEach(t),Qa=p(e),d(et.$$.fragment,e),za=p(e),es=o(e,"P",{});var oh=r(es);ll=o(oh,"STRONG",{});var rh=r(ll);Qr=c(rh,"Output:"),rh.forEach(t),oh.forEach(t),Fa=p(e),d(tt.$$.fragment,e),Sa=p(e),ts=o(e,"P",{});var ih=r(ts);zr=c(ih,"Next, create a basic train/test split:"),ih.forEach(t),qa=p(e),d(st.$$.fragment,e),Ha=p(e),R=o(e,"H3",{class:!0});var Yn=r(R);se=o(Yn,"A",{id:!0,class:!0,href:!0});var ph=r(se);al=o(ph,"SPAN",{});var hh=r(al);d(lt.$$.fragment,hh),hh.forEach(t),ph.forEach(t),Fr=p(Yn),nl=o(Yn,"SPAN",{});var ch=r(nl);Sr=c(ch,"Data collator"),ch.forEach(t),Yn.forEach(t),Da=p(e),le=o(e,"P",{});var Qn=r(le);qr=c(Qn,`In order to combine multiple examples into a batch, you need to define a custom data collator. This collator will pad shorter sequences with padding
tokens, ensuring that all examples have the same length. For the spectrogram labels, the padded portions are replaced with
the special value `),ol=o(Qn,"CODE",{});var uh=r(ol);Hr=c(uh,"-100"),uh.forEach(t),Dr=c(Qn,". This special value instructs the model to ignore that part of the spectrogram when calculating the spectrogram loss."),Qn.forEach(t),Pa=p(e),d(at.$$.fragment,e),Oa=p(e),ss=o(e,"P",{});var mh=r(ss);Pr=c(mh,`In SpeechT5, the input to the decoder part of the model is reduced by a factor 2. In other words, it throws away every
other timestep from the target sequence. The decoder then predicts a sequence that is twice as long. Since the original
target sequence length may be odd, the data collator makes sure to round the maximum length of the batch down to be a
multiple of 2.`),mh.forEach(t),Ka=p(e),d(nt.$$.fragment,e),La=p(e),A=o(e,"H2",{class:!0});var zn=r(A);ae=o(zn,"A",{id:!0,class:!0,href:!0});var dh=r(ae);rl=o(dh,"SPAN",{});var fh=r(rl);d(ot.$$.fragment,fh),fh.forEach(t),dh.forEach(t),Or=p(zn),il=o(zn,"SPAN",{});var Mh=r(il);Kr=c(Mh,"Train the model"),Mh.forEach(t),zn.forEach(t),en=p(e),ls=o(e,"P",{});var yh=r(ls);Lr=c(yh,"Load the pre-trained model from the same checkpoint as you used for loading the processor:"),yh.forEach(t),tn=p(e),d(rt.$$.fragment,e),sn=p(e),ne=o(e,"P",{});var Fn=r(ne);ei=c(Fn,"The "),pl=o(Fn,"CODE",{});var wh=r(pl);ti=c(wh,"use_cache=True"),wh.forEach(t),si=c(Fn,` option is incompatible with gradient checkpointing. Disable it for training, and re-enable cache for
generation to speed-up inference time:`),Fn.forEach(t),ln=p(e),d(it.$$.fragment,e),an=p(e),as=o(e,"P",{});var Jh=r(as);li=c(Jh,`Define the training arguments. Here we are not computing any evaluation metrics during the training process,
we\u2019ll talk about evaluation later in this chapter. Instead, we\u2019ll only look at the loss:`),Jh.forEach(t),nn=p(e),d(pt.$$.fragment,e),on=p(e),oe=o(e,"P",{});var Sn=r(oe);ai=c(Sn,"Instantiate the "),hl=o(Sn,"CODE",{});var Th=r(hl);ni=c(Th,"Trainer"),Th.forEach(t),oi=c(Sn," object  and pass the model, dataset, and data collator to it."),Sn.forEach(t),rn=p(e),d(ht.$$.fragment,e),pn=p(e),C=o(e,"P",{});var fs=r(C);ri=c(fs,`And with that, we\u2019re ready to start training! Training will take several hours. Depending on your GPU,
it is possible that you will encounter a CUDA \u201Cout-of-memory\u201D error when you start training. In this case, you can reduce
the `),cl=o(fs,"CODE",{});var bh=r(cl);ii=c(bh,"per_device_train_batch_size"),bh.forEach(t),pi=c(fs," incrementally by factors of 2 and increase "),ul=o(fs,"CODE",{});var Uh=r(ul);hi=c(Uh,"gradient_accumulation_steps"),Uh.forEach(t),ci=c(fs," by 2x to compensate."),fs.forEach(t),hn=p(e),d(ct.$$.fragment,e),cn=p(e),ns=o(e,"P",{});var jh=r(ns);ui=c(jh,"Push the final model to the \u{1F917} Hub:"),jh.forEach(t),un=p(e),d(ut.$$.fragment,e),mn=p(e),X=o(e,"H2",{class:!0});var qn=r(X);re=o(qn,"A",{id:!0,class:!0,href:!0});var kh=r(re);ml=o(kh,"SPAN",{});var Ih=r(ml);d(mt.$$.fragment,Ih),Ih.forEach(t),kh.forEach(t),mi=p(qn),dl=o(qn,"SPAN",{});var gh=r(dl);di=c(gh,"Inference"),gh.forEach(t),qn.forEach(t),dn=p(e),os=o(e,"P",{});var vh=r(os);fi=c(vh,`Once you have fine-tuned a model, you can use it for inference! Load the model from the \u{1F917} Hub (make sure to use your
account name in the following code snippet):`),vh.forEach(t),fn=p(e),d(dt.$$.fragment,e),Mn=p(e),rs=o(e,"P",{});var $h=r(rs);Mi=c($h,"Pick an example, here we\u2019ll take one from the test dataset. Obtain a speaker embedding."),$h.forEach(t),yn=p(e),d(ft.$$.fragment,e),wn=p(e),is=o(e,"P",{});var _h=r(is);yi=c(_h,"Define some input text and tokenize it."),_h.forEach(t),Jn=p(e),d(Mt.$$.fragment,e),Tn=p(e),ps=o(e,"P",{});var Ch=r(ps);wi=c(Ch,"Preprocess the input text:"),Ch.forEach(t),bn=p(e),d(yt.$$.fragment,e),Un=p(e),hs=o(e,"P",{});var Zh=r(hs);Ji=c(Zh,"Instantiate a vocoder and generate speech:"),Zh.forEach(t),jn=p(e),d(wt.$$.fragment,e),kn=p(e),cs=o(e,"P",{});var Eh=r(cs);Ti=c(Eh,"Ready to listen to the result?"),Eh.forEach(t),In=p(e),d(Jt.$$.fragment,e),gn=p(e),us=o(e,"P",{});var xh=r(us);bi=c(xh,`Obtaining satisfactory results from this model on a new language can be challenging. The quality of the speaker
embeddings can be a significant factor. Since SpeechT5 was pre-trained with English x-vectors, it performs best
when using English speaker embeddings. If the synthesized speech sounds poor, try using a different speaker embedding.`),xh.forEach(t),vn=p(e),ie=o(e,"P",{});var Hn=r(ie);Ui=c(Hn,`Increasing the training duration is also likely to enhance the quality of the results. Even so, the speech clearly is Dutch instead of English, and it does
capture the voice characteristics of the speaker (compare to the original audio in the example).
Another thing to experiment with is the model\u2019s configuration. For example, try using `),fl=o(Hn,"CODE",{});var Gh=r(fl);ji=c(Gh,"config.reduction_factor = 1"),Gh.forEach(t),ki=c(Hn,` to
see if this improves the results.`),Hn.forEach(t),$n=p(e),ms=o(e,"P",{});var Vh=r(ms);Ii=c(Vh,"In the next section, we\u2019ll talk about how we evaluate text-to-speech models."),Vh.forEach(t),this.h()},h(){u(T,"name","hf:doc:metadata"),u(T,"content",JSON.stringify(Fh)),u(k,"id","finetuning-speecht5"),u(k,"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(k,"href","#finetuning-speecht5"),u(U,"class","relative group"),u(Q,"id","housekeeping"),u(Q,"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(Q,"href","#housekeeping"),u(E,"class","relative group"),u(F,"id","the-dataset"),u(F,"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(F,"href","#the-dataset"),u(x,"class","relative group"),u(ye,"href","https://huggingface.co/datasets/facebook/voxpopuli"),u(ye,"rel","nofollow"),u(we,"href","https://huggingface.co/datasets/facebook/voxpopuli"),u(we,"rel","nofollow"),u(S,"id","preprocessing-the-data"),u(S,"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(S,"href","#preprocessing-the-data"),u(G,"class","relative group"),u(q,"id","text-cleanup-for-speecht5-tokenization"),u(q,"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(q,"href","#text-cleanup-for-speecht5-tokenization"),u(V,"class","relative group"),u(D,"id","speakers"),u(D,"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(D,"href","#speakers"),u(B,"class","relative group"),Bh(Wt.src,gi="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/tts_speakers_histogram.png")||u(Wt,"src",gi),u(Wt,"alt","Speakers histogram"),u(Ve,"class","flex justify-center"),u(P,"id","speaker-embeddings"),u(P,"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(P,"href","#speaker-embeddings"),u(W,"class","relative group"),u(Ye,"href","https://huggingface.co/speechbrain/spkrec-xvect-voxceleb"),u(Ye,"rel","nofollow"),u(ze,"href","https://huggingface.co/mechanicalsea/speecht5-vc/blob/main/manifest/utils/prep_cmu_arctic_spkemb.py"),u(ze,"rel","nofollow"),u(te,"id","processing-the-dataset"),u(te,"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(te,"href","#processing-the-dataset"),u(N,"class","relative group"),Bh(Pt.src,vi="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/tts_logmelspectrogram_1.png")||u(Pt,"src",vi),u(Pt,"alt","Log-mel spectrogram with 80 mel bins"),u(Ke,"class","flex justify-center"),u(se,"id","data-collator"),u(se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(se,"href","#data-collator"),u(R,"class","relative group"),u(ae,"id","train-the-model"),u(ae,"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(ae,"href","#train-the-model"),u(A,"class","relative group"),u(re,"id","inference"),u(re,"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(re,"href","#inference"),u(X,"class","relative group")},m(e,s){l(document.head,T),a(e,Y,s),a(e,U,s),l(U,k),l(k,Ms),f(ce,Ms,null),l(U,Dn),l(U,ys),l(ys,Pn),a(e,yl,s),a(e,bt,s),l(bt,On),a(e,wl,s),a(e,E,s),l(E,Q),l(Q,ws),f(ue,ws,null),l(E,Kn),l(E,Js),l(Js,Ln),a(e,Jl,s),f(me,e,s),a(e,Tl,s),f(z,e,s),a(e,bl,s),a(e,Ut,s),l(Ut,eo),a(e,Ul,s),f(de,e,s),a(e,jl,s),a(e,jt,s),l(jt,to),a(e,kl,s),f(fe,e,s),a(e,Il,s),a(e,x,s),l(x,F),l(F,Ts),f(Me,Ts,null),l(x,so),l(x,bs),l(bs,lo),a(e,gl,s),a(e,I,s),l(I,ao),l(I,Us),l(Us,no),l(I,oo),l(I,ye),l(ye,ro),l(I,io),l(I,we),l(we,po),l(I,ho),a(e,vl,s),a(e,kt,s),l(kt,co),a(e,$l,s),a(e,It,s),l(It,uo),a(e,_l,s),f(Je,e,s),a(e,Cl,s),a(e,gt,s),l(gt,js),l(js,mo),a(e,Zl,s),f(Te,e,s),a(e,El,s),a(e,vt,s),l(vt,fo),a(e,xl,s),f(be,e,s),a(e,Gl,s),a(e,G,s),l(G,S),l(S,ks),f(Ue,ks,null),l(G,Mo),l(G,Is),l(Is,yo),a(e,Vl,s),a(e,$t,s),l($t,wo),a(e,Bl,s),f(je,e,s),a(e,Wl,s),a(e,V,s),l(V,q),l(q,gs),f(ke,gs,null),l(V,Jo),l(V,vs),l(vs,To),a(e,Nl,s),a(e,_t,s),l(_t,bo),a(e,Rl,s),f(Ie,e,s),a(e,Al,s),a(e,Ct,s),l(Ct,Uo),a(e,Xl,s),f(ge,e,s),a(e,Yl,s),a(e,Zt,s),l(Zt,$s),l($s,jo),a(e,Ql,s),f(ve,e,s),a(e,zl,s),a(e,j,s),l(j,ko),l(j,_s),l(_s,Io),l(j,go),l(j,Cs),l(Cs,vo),l(j,$o),l(j,Zs),l(Zs,_o),l(j,Co),l(j,Es),l(Es,Zo),l(j,Eo),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Ka,s),f(nt,e,s),a(e,La,s),a(e,A,s),l(A,ae),l(ae,rl),f(ot,rl,null),l(A,Or),l(A,il),l(il,Kr),a(e,en,s),a(e,ls,s),l(ls,Lr),a(e,tn,s),f(rt,e,s),a(e,sn,s),a(e,ne,s),l(ne,ei),l(ne,pl),l(pl,ti),l(ne,si),a(e,ln,s),f(it,e,s),a(e,an,s),a(e,as,s),l(as,li),a(e,nn,s),f(pt,e,s),a(e,on,s),a(e,oe,s),l(oe,ai),l(oe,hl),l(hl,ni),l(oe,oi),a(e,rn,s),f(ht,e,s),a(e,pn,s),a(e,C,s),l(C,ri),l(C,cl),l(cl,ii),l(C,pi),l(C,ul),l(ul,hi),l(C,ci),a(e,hn,s),f(ct,e,s),a(e,cn,s),a(e,ns,s),l(ns,ui),a(e,un,s),f(ut,e,s),a(e,mn,s),a(e,X,s),l(X,re),l(re,ml),f(mt,ml,null),l(X,mi),l(X,dl),l(dl,di),a(e,dn,s),a(e,os,s),l(os,fi),a(e,fn,s),f(dt,e,s),a(e,Mn,s),a(e,rs,s),l(rs,Mi),a(e,yn,s),f(ft,e,s),a(e,wn,s),a(e,is,s),l(is,yi),a(e,Jn,s),f(Mt,e,s),a(e,Tn,s),a(e,ps,s),l(ps,wi),a(e,bn,s),f(yt,e,s),a(e,Un,s),a(e,hs,s),l(hs,Ji),a(e,jn,s),f(wt,e,s),a(e,kn,s),a(e,cs,s),l(cs,Ti),a(e,In,s),f(Jt,e,s),a(e,gn,s),a(e,us,s),l(us,bi),a(e,vn,s),a(e,ie,s),l(ie,Ui),l(ie,fl),l(fl,ji),l(ie,ki),a(e,$n,s),a(e,ms,s),l(ms,Ii),_n=!0},p(e,[s]){const Tt={};s&2&&(Tt.$$scope={dirty:s,ctx:e}),z.$set(Tt)},i(e){_n||(M(ce.$$.fragment,e),M(ue.$$.fragment,e),M(me.$$.fragment,e),M(z.$$.fragment,e),M(de.$$.fragment,e),M(fe.$$.fragment,e),M(Me.$$.fragment,e),M(Je.$$.fragment,e),M(Te.$$.fragment,e),M(be.$$.fragment,e),M(Ue.$$.fragment,e),M(je.$$.fragment,e),M(ke.$$.fragment,e),M(Ie.$$.fragment,e),M(ge.$$.fragment,e),M(ve.$$.fragment,e),M($e.$$.fragment,e),M(_e.$$.fragment,e),M(Ce.$$.fragment,e),M(Ze.$$.fragment,e),M(Ee.$$.fragment,e),M(xe.$$.fragment,e),M(Ge.$$.fragment,e),M(Be.$$.fragment,e),M(We.$$.fragment,e),M(Ne.$$.fragment,e),M(Re.$$.fragment,e),M(Ae.$$.fragment,e),M(Xe.$$.fragment,e),M(Qe.$$.fragment,e),M(Fe.$$.fragment,e),M(Se.$$.fragment,e),M(qe.$$.fragment,e),M(He.$$.fragment,e),M(De.$$.fragment,e),M(Pe.$$.fragment,e),M(Oe.$$.fragment,e),M(Le.$$.fragment,e),M(et.$$.fragment,e),M(tt.$$.fragment,e),M(st.$$.fragment,e),M(lt.$$.fragment,e),M(at.$$.fragment,e),M(nt.$$.fragment,e),M(ot.$$.fragment,e),M(rt.$$.fragment,e),M(it.$$.fragment,e),M(pt.$$.fragment,e),M(ht.$$.fragment,e),M(ct.$$.fragment,e),M(ut.$$.fragment,e),M(mt.$$.fragment,e),M(dt.$$.fragment,e),M(ft.$$.fragment,e),M(Mt.$$.fragment,e),M(yt.$$.fragment,e),M(wt.$$.fragment,e),M(Jt.$$.fragment,e),_n=!0)},o(e){y(ce.$$.fragment,e),y(ue.$$.fragment,e),y(me.$$.fragment,e),y(z.$$.fragment,e),y(de.$$.fragment,e),y(fe.$$.fragment,e),y(Me.$$.fragment,e),y(Je.$$.fragment,e),y(Te.$$.fragment,e),y(be.$$.fragment,e),y(Ue.$$.fragment,e),y(je.$$.fragment,e),y(ke.$$.fragment,e),y(Ie.$$.fragment,e),y(ge.$$.fragment,e),y(ve.$$.fragment,e),y($e.$$.fragment,e),y(_e.$$.fragment,e),y(Ce.$$.fragment,e),y(Ze.$$.fragment,e),y(Ee.$$.fragment,e),y(xe.$$.fragment,e),y(Ge.$$.fragment,e),y(Be.$$.fragment,e),y(We.$$.fragment,e),y(Ne.$$.fragment,e),y(Re.$$.fragment,e),y(Ae.$$.fragment,e),y(Xe.$$.fragment,e),y(Qe.$$.fragment,e),y(Fe.$$.fragment,e),y(Se.$$.fragment,e),y(qe.$$.fragment,e),y(He.$$.fragment,e),y(De.$$.fragment,e),y(Pe.$$.fragment,e),y(Oe.$$.fragment,e),y(Le.$$.fragment,e),y(et.$$.fragment,e),y(tt.$$.fragment,e),y(st.$$.fragment,e),y(lt.$$.fragment,e),y(at.$$.fragment,e),y(nt.$$.fragment,e),y(ot.$$.fragment,e),y(rt.$$.fragment,e),y(it.$$.fragment,e),y(pt.$$.fragment,e),y(ht.$$.fragment,e),y(ct.$$.fragment,e),y(ut.$$.fragment,e),y(mt.$$.fragment,e),y(dt.$$.fragment,e),y(ft.$$.fragment,e),y(Mt.$$.fragment,e),y(yt.$$.fragment,e),y(wt.$$.fragment,e),y(Jt.$$.fragment,e),_n=!1},d(e){t(T),e&&t(Y),e&&t(U),w(ce),e&&t(yl),e&&t(bt),e&&t(wl),e&&t(E),w(ue),e&&t(Jl),w(me,e),e&&t(Tl),w(z,e),e&&t(bl),e&&t(Ut),e&&t(Ul),w(de,e),e&&t(jl),e&&t(jt),e&&t(kl),w(fe,e),e&&t(Il),e&&t(x),w(Me),e&&t(gl),e&&t(I),e&&t(vl),e&&t(kt),e&&t($l),e&&t(It),e&&t(_l),w(Je,e),e&&t(Cl),e&&t(gt),e&&t(Zl),w(Te,e),e&&t(El),e&&t(vt),e&&t(xl),w(be,e),e&&t(Gl),e&&t(G),w(Ue),e&&t(Vl),e&&t($t),e&&t(Bl),w(je,e),e&&t(Wl),e&&t(V),w(ke),e&&t(Nl),e&&t(_t),e&&t(Rl),w(Ie,e),e&&t(Al),e&&t(Ct),e&&t(Xl),w(ge,e),e&&t(Yl),e&&t(Zt),e&&t(Ql),w(ve,e),e&&t(zl),e&&t(j),e&&t(Fl),e&&t(g),e&&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&&t(ls),e&&t(tn),w(rt,e),e&&t(sn),e&&t(ne),e&&t(ln),w(it,e),e&&t(an),e&&t(as),e&&t(nn),w(pt,e),e&&t(on),e&&t(oe),e&&t(rn),w(ht,e),e&&t(pn),e&&t(C),e&&t(hn),w(ct,e),e&&t(cn),e&&t(ns),e&&t(un),w(ut,e),e&&t(mn),e&&t(X),w(mt),e&&t(dn),e&&t(os),e&&t(fn),w(dt,e),e&&t(Mn),e&&t(rs),e&&t(yn),w(ft,e),e&&t(wn),e&&t(is),e&&t(Jn),w(Mt,e),e&&t(Tn),e&&t(ps),e&&t(bn),w(yt,e),e&&t(Un),e&&t(hs),e&&t(jn),w(wt,e),e&&t(kn),e&&t(cs),e&&t(In),w(Jt,e),e&&t(gn),e&&t(us),e&&t(vn),e&&t(ie),e&&t($n),e&&t(ms)}}}const Fh={local:"finetuning-speecht5",sections:[{local:"housekeeping",title:"House-keeping"},{local:"the-dataset",title:"The dataset"},{local:"preprocessing-the-data",sections:[{local:"text-cleanup-for-speecht5-tokenization",title:"Text cleanup for SpeechT5 tokenization"},{local:"speakers",title:"Speakers"},{local:"speaker-embeddings",title:"Speaker embeddings"},{local:"processing-the-dataset",title:"Processing the dataset"},{local:"data-collator",title:"Data collator"}],title:"Preprocessing the data "},{local:"train-the-model",title:"Train the model"},{local:"inference",title:"Inference"}],title:"Fine-tuning SpeechT5"};function Sh(Ml){return Xh(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Oh extends Wh{constructor(T){super();Nh(this,T,Sh,zh,Rh,{})}}export{Oh as default,Fh as metadata};
