import{S as Ai,i as Si,s as Qi,e as n,k as h,w as u,t as r,M as Fi,c as p,d as s,m as c,a as o,x as d,h as i,b as m,N as Qo,G as a,g as l,y as f,q as y,o as M,B as w,v as qi,L as Hi}from"../../chunks/vendor-hf-doc-builder.js";import{T as Di}from"../../chunks/Tip-hf-doc-builder.js";import{I as V}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as j}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Pi}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function Ki(Kt){let b,S,U,T,$;return T=new j({props:{code:"IW52aWRpYS1zbWk=",highlighted:"!nvidia-smi"}}),{c(){b=n("p"),S=r("To follow this guide you will need a GPU. If you\u2019re working in a notebook, run the following line to check if a GPU is available:"),U=h(),u(T.$$.fragment)},l(g){b=p(g,"P",{});var C=o(b);S=i(C,"To follow this guide you will need a GPU. If you\u2019re working in a notebook, run the following line to check if a GPU is available:"),C.forEach(s),U=c(g),d(T.$$.fragment,g)},m(g,C){l(g,b,C),a(b,S),l(g,U,C),f(T,g,C),$=!0},p:Hi,i(g){$||(y(T.$$.fragment,g),$=!0)},o(g){M(T.$$.fragment,g),$=!1},d(g){g&&s(b),g&&s(U),w(T,g)}}}function Li(Kt){let b,S,U,T,$,g,C,ot,wn,Lt,ue,Ot,Q,jn,fs,gn,bn,ea,ys,Tn,sa,F,_,Jn,Ms,Un,kn,rt,vn,In,de,_n,$n,Cn,it,Zn,ta,ws,En,aa,fe,la,js,xn,na,ye,pa,q,oa,gs,Vn,ra,Me,ia,G,H,ht,we,Gn,ct,Bn,ha,je,ge,Wn,Rn,ca,bs,Xn,ma,Ts,Yn,ua,be,da,Js,Nn,fa,Te,ya,B,D,mt,Je,zn,ut,An,Ma,Us,Sn,wa,Ue,ja,W,P,dt,ke,Qn,ft,Fn,ga,ks,qn,ba,ve,Ta,k,Hn,yt,Dn,Pn,Mt,Kn,Ln,wt,On,ep,jt,sp,tp,Ja,v,ap,gt,lp,np,bt,pp,op,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"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/text-to-speech.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/text-to-speech.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/text-to-speech.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/text-to-speech.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/text-to-speech.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/text-to-speech.ipynb"}]}}),fe=new j({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRhdGFzZXRzJTIwc291bmRmaWxlJTIwc3BlZWNoYnJhaW4lMjBhY2NlbGVyYXRl",highlighted:"pip install datasets soundfile speechbrain accelerate"}}),ye=new j({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGdHJhbnNmb3JtZXJzLmdpdA==",highlighted:"pip install git+https://github.com/huggingface/transformers.git"}}),q=new Di({props:{$$slots:{default:[Ki]},$$scope:{ctx:Kt}}}),Me=new j({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`}}),we=new V({}),be=new j({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmZhY2Vib29rJTJGdm94cG9wdWxpJTIyJTJDJTIwJTIybmwlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKSUwQWxlbihkYXRhc2V0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>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-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">len</span>(dataset)
<span class="hljs-number">20968</span>`}}),Te=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>))'}}),Je=new V({}),Ue=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNwZWVjaFQ1UHJvY2Vzc29yJTBBJTBBY2hlY2twb2ludCUyMCUzRCUyMCUyMm1pY3Jvc29mdCUyRnNwZWVjaHQ1X3R0cyUyMiUwQXByb2Nlc3NvciUyMCUzRCUyMFNwZWVjaFQ1UHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SpeechT5Processor

<span class="hljs-meta">&gt;&gt;&gt; </span>checkpoint = <span class="hljs-string">&quot;microsoft/speecht5_tts&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = SpeechT5Processor.from_pretrained(checkpoint)`}}),ke=new V({}),ve=new j({props:{code:"dG9rZW5pemVyJTIwJTNEJTIwcHJvY2Vzc29yLnRva2VuaXplcg==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = processor.tokenizer'}}),Ie=new j({props:{code:"ZGVmJTIwZXh0cmFjdF9hbGxfY2hhcnMoYmF0Y2gpJTNBJTBBJTIwJTIwJTIwJTIwYWxsX3RleHQlMjAlM0QlMjAlMjIlMjAlMjIuam9pbihiYXRjaCU1QiUyMm5vcm1hbGl6ZWRfdGV4dCUyMiU1RCklMEElMjAlMjAlMjAlMjB2b2NhYiUyMCUzRCUyMGxpc3Qoc2V0KGFsbF90ZXh0KSklMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlN0IlMjJ2b2NhYiUyMiUzQSUyMCU1QnZvY2FiJTVEJTJDJTIwJTIyYWxsX3RleHQlMjIlM0ElMjAlNUJhbGxfdGV4dCU1RCU3RCUwQSUwQSUwQXZvY2FicyUyMCUzRCUyMGRhdGFzZXQubWFwKCUwQSUyMCUyMCUyMCUyMGV4dHJhY3RfYWxsX2NoYXJzJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hlZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNELTElMkMlMEElMjAlMjAlMjAlMjBrZWVwX2luX21lbW9yeSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZW1vdmVfY29sdW1ucyUzRGRhdGFzZXQuY29sdW1uX25hbWVzJTJDJTBBKSUwQSUwQWRhdGFzZXRfdm9jYWIlMjAlM0QlMjBzZXQodm9jYWJzJTVCJTIydm9jYWIlMjIlNUQlNUIwJTVEKSUwQXRva2VuaXplcl92b2NhYiUyMCUzRCUyMCU3QmslMjBmb3IlMjBrJTJDJTIwXyUyMGluJTIwdG9rZW5pemVyLmdldF92b2NhYigpLml0ZW1zKCklN0Q=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">extract_all_chars</span>(<span class="hljs-params">batch</span>):
<span class="hljs-meta">... </span>    all_text = <span class="hljs-string">&quot; &quot;</span>.join(batch[<span class="hljs-string">&quot;normalized_text&quot;</span>])
<span class="hljs-meta">... </span>    vocab = <span class="hljs-built_in">list</span>(<span class="hljs-built_in">set</span>(all_text))
<span class="hljs-meta">... </span>    <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]}


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

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset_vocab = <span class="hljs-built_in">set</span>(vocabs[<span class="hljs-string">&quot;vocab&quot;</span>][<span class="hljs-number">0</span>])
<span class="hljs-meta">&gt;&gt;&gt; </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:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset_vocab - tokenizer_vocab
{<span class="hljs-string">&#x27; &#x27;</span>, <span class="hljs-string">&#x27;\xE0&#x27;</span>, <span class="hljs-string">&#x27;\xE7&#x27;</span>, <span class="hljs-string">&#x27;\xE8&#x27;</span>, <span class="hljs-string">&#x27;\xEB&#x27;</span>, <span class="hljs-string">&#x27;\xED&#x27;</span>, <span class="hljs-string">&#x27;\xEF&#x27;</span>, <span class="hljs-string">&#x27;\xF6&#x27;</span>, <span class="hljs-string">&#x27;\xFC&#x27;</span>}`}}),$e=new j({props:{code:"cmVwbGFjZW1lbnRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVBMCUyMiUyQyUyMCUyMmElMjIpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVBNyUyMiUyQyUyMCUyMmMlMjIpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVBOCUyMiUyQyUyMCUyMmUlMjIpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVBQiUyMiUyQyUyMCUyMmUlMjIpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVBRCUyMiUyQyUyMCUyMmklMjIpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVBRiUyMiUyQyUyMCUyMmklMjIpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVCNiUyMiUyQyUyMCUyMm8lMjIpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMiVDMyVCQyUyMiUyQyUyMCUyMnUlMjIpJTJDJTBBJTVEJTBBJTBBJTBBZGVmJTIwY2xlYW51cF90ZXh0KGlucHV0cyklM0ElMEElMjAlMjAlMjAlMjBmb3IlMjBzcmMlMkMlMjBkc3QlMjBpbiUyMHJlcGxhY2VtZW50cyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlucHV0cyU1QiUyMm5vcm1hbGl6ZWRfdGV4dCUyMiU1RCUyMCUzRCUyMGlucHV0cyU1QiUyMm5vcm1hbGl6ZWRfdGV4dCUyMiU1RC5yZXBsYWNlKHNyYyUyQyUyMGRzdCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBpbnB1dHMlMEElMEElMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldC5tYXAoY2xlYW51cF90ZXh0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>replacements = [
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xE0&quot;</span>, <span class="hljs-string">&quot;a&quot;</span>),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xE7&quot;</span>, <span class="hljs-string">&quot;c&quot;</span>),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xE8&quot;</span>, <span class="hljs-string">&quot;e&quot;</span>),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xEB&quot;</span>, <span class="hljs-string">&quot;e&quot;</span>),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xED&quot;</span>, <span class="hljs-string">&quot;i&quot;</span>),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xEF&quot;</span>, <span class="hljs-string">&quot;i&quot;</span>),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xF6&quot;</span>, <span class="hljs-string">&quot;o&quot;</span>),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;\xFC&quot;</span>, <span class="hljs-string">&quot;u&quot;</span>),
<span class="hljs-meta">... </span>]


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">cleanup_text</span>(<span class="hljs-params">inputs</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> src, dst <span class="hljs-keyword">in</span> replacements:
<span class="hljs-meta">... </span>        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-meta">... </span>    <span class="hljs-keyword">return</span> inputs


<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(cleanup_text)`}}),Ce=new V({}),Ze=new j({props:{code:"ZnJvbSUyMGNvbGxlY3Rpb25zJTIwaW1wb3J0JTIwZGVmYXVsdGRpY3QlMEElMEFzcGVha2VyX2NvdW50cyUyMCUzRCUyMGRlZmF1bHRkaWN0KGludCklMEElMEFmb3IlMjBzcGVha2VyX2lkJTIwaW4lMjBkYXRhc2V0JTVCJTIyc3BlYWtlcl9pZCUyMiU1RCUzQSUwQSUyMCUyMCUyMCUyMHNwZWFrZXJfY291bnRzJTVCc3BlYWtlcl9pZCU1RCUyMCUyQiUzRCUyMDE=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> defaultdict

<span class="hljs-meta">&gt;&gt;&gt; </span>speaker_counts = defaultdict(<span class="hljs-built_in">int</span>)

<span class="hljs-meta">&gt;&gt;&gt; </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>]:
<span class="hljs-meta">... </span>    speaker_counts[speaker_id] += <span class="hljs-number">1</span>`}}),Ee=new j({props:{code:"aW1wb3J0JTIwbWF0cGxvdGxpYi5weXBsb3QlMjBhcyUyMHBsdCUwQSUwQXBsdC5maWd1cmUoKSUwQXBsdC5oaXN0KHNwZWFrZXJfY291bnRzLnZhbHVlcygpJTJDJTIwYmlucyUzRDIwKSUwQXBsdC55bGFiZWwoJTIyU3BlYWtlcnMlMjIpJTBBcGx0LnhsYWJlbCglMjJFeGFtcGxlcyUyMiklMEFwbHQuc2hvdygp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

<span class="hljs-meta">&gt;&gt;&gt; </span>plt.figure()
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.hist(speaker_counts.values(), bins=<span class="hljs-number">20</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.ylabel(<span class="hljs-string">&quot;Speakers&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.xlabel(<span class="hljs-string">&quot;Examples&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.show()`}}),Ve=new j({props:{code:"ZGVmJTIwc2VsZWN0X3NwZWFrZXIoc3BlYWtlcl9pZCklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjAxMDAlMjAlM0MlM0QlMjBzcGVha2VyX2NvdW50cyU1QnNwZWFrZXJfaWQlNUQlMjAlM0MlM0QlMjA0MDAlMEElMEElMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldC5maWx0ZXIoc2VsZWN0X3NwZWFrZXIlMkMlMjBpbnB1dF9jb2x1bW5zJTNEJTVCJTIyc3BlYWtlcl9pZCUyMiU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">select_speaker</span>(<span class="hljs-params">speaker_id</span>):
<span class="hljs-meta">... </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>


<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">filter</span>(select_speaker, input_columns=[<span class="hljs-string">&quot;speaker_id&quot;</span>])`}}),Ge=new j({props:{code:"bGVuKHNldChkYXRhc2V0JTVCJTIyc3BlYWtlcl9pZCUyMiU1RCkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">len</span>(<span class="hljs-built_in">set</span>(dataset[<span class="hljs-string">&quot;speaker_id&quot;</span>]))
<span class="hljs-number">42</span>`}}),Be=new j({props:{code:"bGVuKGRhdGFzZXQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">len</span>(dataset)
<span class="hljs-number">9973</span>`}}),We=new V({}),Xe=new j({props:{code:"aW1wb3J0JTIwb3MlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBzcGVlY2hicmFpbi5wcmV0cmFpbmVkJTIwaW1wb3J0JTIwRW5jb2RlckNsYXNzaWZpZXIlMEElMEFzcGtfbW9kZWxfbmFtZSUyMCUzRCUyMCUyMnNwZWVjaGJyYWluJTJGc3BrcmVjLXh2ZWN0LXZveGNlb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t;&gt;&gt; </span><span class="hljs-keyword">import</span> os
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> speechbrain.pretrained <span class="hljs-keyword">import</span> EncoderClassifier

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

<span class="hljs-meta">&gt;&gt;&gt; </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>
<span class="hljs-meta">&gt;&gt;&gt; </span>speaker_model = EncoderClassifier.from_hparams(
<span class="hljs-meta">... </span>    source=spk_model_name,
<span class="hljs-meta">... </span>    run_opts={<span class="hljs-string">&quot;device&quot;</span>: device},
<span class="hljs-meta">... </span>    savedir=os.path.join(<span class="hljs-string">&quot;/tmp&quot;</span>, spk_model_name),
<span class="hljs-meta">... </span>)


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

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

<span class="hljs-meta">... </span>    <span class="hljs-comment"># strip off the batch dimension</span>
<span class="hljs-meta">... </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-meta">... </span>    <span class="hljs-comment"># use SpeechBrain to obtain x-vector</span>
<span class="hljs-meta">... </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-meta">... </span>    <span class="hljs-keyword">return</span> example`}}),ze=new j({props:{code:"cHJvY2Vzc2VkX2V4YW1wbGUlMjAlM0QlMjBwcmVwYXJlX2RhdGFzZXQoZGF0YXNldCU1QjAlNUQpJTBBbGlzdChwcm9jZXNzZWRfZXhhbXBsZS5rZXlzKCkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>processed_example = prepare_dataset(dataset[<span class="hljs-number">0</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(processed_example.keys())
[<span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;stop_labels&#x27;</span>, <span class="hljs-string">&#x27;speaker_embeddings&#x27;</span>]`}}),Ae=new j({props:{code:"cHJvY2Vzc2VkX2V4YW1wbGUlNUIlMjJzcGVha2VyX2VtYmVkZGluZ3MlMjIlNUQuc2hhcGU=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>processed_example[<span class="hljs-string">&quot;speaker_embeddings&quot;</span>].shape
(<span class="hljs-number">512</span>,)`}}),Se=new j({props:{code:"aW1wb3J0JTIwbWF0cGxvdGxpYi5weXBsb3QlMjBhcyUyMHBsdCUwQSUwQXBsdC5maWd1cmUoKSUwQXBsdC5pbXNob3cocHJvY2Vzc2VkX2V4YW1wbGUlNUIlMjJsYWJlbHMlMjIlNUQuVCklMEFwbHQuc2hvdygp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

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


<span class="hljs-meta">&gt;&gt;&gt; </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-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">len</span>(dataset)
<span class="hljs-number">8259</span>`}}),He=new j({props:{code:"ZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQudHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjEp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.train_test_split(test_size=<span class="hljs-number">0.1</span>)'}}),De=new V({}),Pe=new j({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyMEFueSUyQyUyMERpY3QlMkMlMjBMaXN0JTJDJTIwVW5pb24lMEElMEElMEElNDBkYXRhY2xhc3MlMEFjbGFzcyUyMFRUU0RhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTNBJTBBJTIwJTIwJTIwJTIwcHJvY2Vzc29yJTNBJTIwQW55JTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwX19jYWxsX18oc2VsZiUyQyUyMGZlYXR1cmVzJTNBJTIwTGlzdCU1QkRpY3QlNUJzdHIlMkMlMjBVbmlvbiU1Qkxpc3QlNUJpbnQlNUQlMkMlMjB0b3JjaC5UZW5zb3IlNUQlNUQlNUQpJTIwLSUzRSUyMERpY3QlNUJzdHIlMkMlMjB0b3JjaC5UZW5zb3IlNUQlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnB1dF9pZHMlMjAlM0QlMjAlNUIlN0IlMjJpbnB1dF9pZHMlMjIl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UyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtYXhfbGVuZ3RoJTIwJTNEJTIwbWF4KHRhcmdldF9sZW5ndGhzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJhdGNoJTVCJTIybGFiZWxzJTIyJTVEJTIwJTNEJTIwYmF0Y2glNUIlMjJsYWJlbHMlMjIlNUQlNUIlM0ElMkMlMjAlM0FtYXhfbGVuZ3RoJTVEJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwYWxzbyUyMGFkZCUyMGluJTIwdGhlJTIwc3BlYWtlciUyMGVtYmVkZGluZ3MlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBiYXRjaCU1QiUyMnNwZWFrZXJfZW1iZWRkaW5ncyUyMiU1RCUyMCUzRCUyMHRvcmNoLnRlbnNvcihzcGVha2VyX2ZlYXR1cmVzKSUwQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMGJhdGNo",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-meta">&gt;&gt;&gt; </span><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">&gt;&gt;&gt; </span>@dataclass
<span class="hljs-meta">... </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">TTSDataCollatorWithPadding</span>:
<span class="hljs-meta">... </span>    processor: <span class="hljs-type">Any</span>

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

<span class="hljs-meta">... </span>        <span class="hljs-comment"># replace padding with -100 to ignore loss correctly</span>
<span class="hljs-meta">... </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-meta">... </span>        <span class="hljs-comment"># not used during fine-tuning</span>
<span class="hljs-meta">... </span>        <span class="hljs-keyword">del</span> batch[<span class="hljs-string">&quot;decoder_attention_mask&quot;</span>]

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

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

<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> batch`}}),Ke=new j({props:{code:"ZGF0YV9jb2xsYXRvciUyMCUzRCUyMFRUU0RhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHByb2Nlc3NvciUzRHByb2Nlc3Nvcik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = TTSDataCollatorWithPadding(processor=processor)'}}),Le=new V({}),Oe=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNwZWVjaFQ1Rm9yVGV4dFRvU3BlZWNoJTBBJTBBbW9kZWwlMjAlM0QlMjBTcGVlY2hUNUZvclRleHRUb1NwZWVjaC5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SpeechT5ForTextToSpeech

<span class="hljs-meta">&gt;&gt;&gt; </span>model = SpeechT5ForTextToSpeech.from_pretrained(checkpoint)`}}),es=new j({props:{code:"bW9kZWwuY29uZmlnLnVzZV9jYWNoZSUyMCUzRCUyMEZhbHNl",highlighted:'<span class="hljs-meta">&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lMjByZXBvcnRfdG8lM0QlNUIlMjJ0ZW5zb3Jib2FyZCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGxvYWRfYmVzdF9tb2RlbF9hdF9lbmQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZ3JlYXRlcl9pc19iZXR0ZXIlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMGxhYmVsX25hbWVzJTNEJTVCJTIybGFiZWxzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcHVzaF90b19odWIlM0RUcnVlJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = Seq2SeqTrainingArguments(
<span class="hljs-meta">... </span>    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>
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    gradient_accumulation_steps=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">1e-5</span>,
<span class="hljs-meta">... </span>    warmup_steps=<span class="hljs-number">500</span>,
<span class="hljs-meta">... </span>    max_steps=<span class="hljs-number">4000</span>,
<span class="hljs-meta">... </span>    gradient_checkpointing=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    fp16=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;steps&quot;</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    save_steps=<span class="hljs-number">1000</span>,
<span class="hljs-meta">... </span>    eval_steps=<span class="hljs-number">1000</span>,
<span class="hljs-meta">... </span>    logging_steps=<span class="hljs-number">25</span>,
<span class="hljs-meta">... </span>    report_to=[<span class="hljs-string">&quot;tensorboard&quot;</span>],
<span class="hljs-meta">... </span>    load_best_model_at_end=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    greater_is_better=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    label_names=[<span class="hljs-string">&quot;labels&quot;</span>],
<span class="hljs-meta">... </span>    push_to_hub=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)`}}),ts=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlcTJTZXFUcmFpbmVyJTBBJTBBdHJhaW5lciUyMCUzRCUyMFNlcTJTZXFUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0RkYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEcHJvY2Vzc29yJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainer

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Seq2SeqTrainer(
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    train_dataset=dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>    tokenizer=processor,
<span class="hljs-meta">... </span>)`}}),as=new j({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()'}}),ls=new j({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),ns=new V({}),ps=new j({props:{code:"bW9kZWwlMjAlM0QlMjBTcGVlY2hUNUZvclRleHRUb1NwZWVjaC5mcm9tX3ByZXRyYWluZWQoJTIyWU9VUl9BQ0NPVU5UJTJGc3BlZWNodDVfZmluZXR1bmVkX3ZveHBvcHVsaV9ubCUyMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model = SpeechT5ForTextToSpeech.from_pretrained(<span class="hljs-string">&quot;YOUR_ACCOUNT/speecht5_finetuned_voxpopuli_nl&quot;</span>)'}}),os=new j({props:{code:"ZXhhbXBsZSUyMCUzRCUyMGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTVCMzA0JTVEJTBBc3BlYWtlcl9lbWJlZGRpbmdzJTIwJTNEJTIwdG9yY2gudGVuc29yKGV4YW1wbGUlNUIlMjJzcGVha2VyX2VtYmVkZGluZ3MlMjIlNUQpLnVuc3F1ZWV6ZSgwKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>example = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">304</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>speaker_embeddings = torch.tensor(example[<span class="hljs-string">&quot;speaker_embeddings&quot;</span>]).unsqueeze(<span class="hljs-number">0</span>)`}}),rs=new j({props:{code:"dGV4dCUyMCUzRCUyMCUyMmhhbGxvJTIwYWxsZW1hYWwlMkMlMjBpayUyMHByYWF0JTIwbmVkZXJsYW5kcy4lMjBncm9ldGplcyUyMGFhbiUyMGllZGVyZWVuISUyMg==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;hallo allemaal, ik praat nederlands. groetjes aan iedereen!&quot;</span>'}}),is=new j({props:{code:"aW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKHRleHQlM0R0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(text=text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)'}}),hs=new j({props:{code:"c3BlY3Ryb2dyYW0lMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZV9zcGVlY2goaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTJDJTIwc3BlYWtlcl9lbWJlZGRpbmdzKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>spectrogram = model.generate_speech(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>], speaker_embeddings)'}}),cs=new j({props:{code:"cGx0LmZpZ3VyZSgpJTBBcGx0Lmltc2hvdyhzcGVjdHJvZ3JhbS5UKSUwQXBsdC5zaG93KCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>plt.figure()
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.imshow(spectrogram.T)
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.show()`}}),us=new j({props:{code:"d2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMHNwZWVjaCUyMCUzRCUyMHZvY29kZXIoc3BlY3Ryb2dyYW0pJTBBJTBBZnJvbSUyMElQeXRob24uZGlzcGxheSUyMGltcG9ydCUyMEF1ZGlvJTBBJTBBQXVkaW8oc3BlZWNoLm51bXB5KCklMkMlMjByYXRlJTNEMTYwMDAp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    speech = vocoder(spectrogram)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> IPython.display <span class="hljs-keyword">import</span> Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>Audio(speech.numpy(), rate=<span class="hljs-number">16000</span>)`}}),{c(){b=n("meta"),S=h(),U=n("h1"),T=n("a"),$=n("span"),u(g.$$.fragment),C=h(),ot=n("span"),wn=r("Text to speech"),Lt=h(),u(ue.$$.fragment),Ot=h(),Q=n("p"),jn=r(`Text-to-speech (TTS) is the task of creating natural-sounding speech from text, where the speech can be generated in multiple
languages and for multiple speakers. The only text-to-speech model currently available in \u{1F917} Transformers
is `),fs=n("a"),gn=r("SpeechT5"),bn=r(`, though more will be added in the future. SpeechT5 is pre-trained on a combination of
speech-to-text and text-to-speech data, allowing it to learn a unified space of hidden representations shared by both text
and speech. This means that the same pre-trained model can be fine-tuned for different tasks. Furthermore, SpeechT5
supports multiple speakers through x-vector speaker embeddings.`),ea=h(),ys=n("p"),Tn=r("This guide illustrates how to:"),sa=h(),F=n("ol"),_=n("li"),Jn=r("Fine-tune "),Ms=n("a"),Un=r("SpeechT5"),kn=r(" that was originally trained on English speech on the Dutch ("),rt=n("code"),vn=r("nl"),In=r(") language subset of the "),de=n("a"),_n=r("VoxPopuli"),$n=r(" dataset."),Cn=h(),it=n("li"),Zn=r("Use your fine-tuned model for inference."),ta=h(),ws=n("p"),En=r("Before you begin, make sure you have all the necessary libraries installed:"),aa=h(),u(fe.$$.fragment),la=h(),js=n("p"),xn=r("Install \u{1F917}Transformers from source as not all the SpeechT5 features have been merged into an official release yet:"),na=h(),u(ye.$$.fragment),pa=h(),u(q.$$.fragment),oa=h(),gs=n("p"),Vn=r("We encourage you to log in to your Hugging Face account to upload and share your model with the community. When prompted, enter your token to log in:"),ra=h(),u(Me.$$.fragment),ia=h(),G=n("h2"),H=n("a"),ht=n("span"),u(we.$$.fragment),Gn=h(),ct=n("span"),Bn=r("Load the dataset"),ha=h(),je=n("p"),ge=n("a"),Wn=r("VoxPopuli"),Rn=r(` 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. In this guide, we are using the Dutch language subset, feel free to pick another subset.`),ca=h(),bs=n("p"),Xn=r(`Note that VoxPopuli or any other automated speech recognition (ASR) dataset may not be the most suitable
option for training TTS models. The features that make it beneficial for ASR, such as excessive background noise, are
typically undesirable in TTS. However, finding top-quality, multilingual, and multi-speaker TTS datasets can be quite
challenging.`),ma=h(),Ts=n("p"),Yn=r("Let\u2019s load the data:"),ua=h(),u(be.$$.fragment),da=h(),Js=n("p"),Nn=r(`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:`),fa=h(),u(Te.$$.fragment),ya=h(),B=n("h2"),D=n("a"),mt=n("span"),u(Je.$$.fragment),zn=h(),ut=n("span"),An=r("Preprocess the data"),Ma=h(),Us=n("p"),Sn=r("Let\u2019s begin by defining the model checkpoint to use and loading the appropriate processor:"),wa=h(),u(Ue.$$.fragment),ja=h(),W=n("h3"),P=n("a"),dt=n("span"),u(ke.$$.fragment),Qn=h(),ft=n("span"),Fn=r("Text cleanup for SpeechT5 tokenization"),ga=h(),ks=n("p"),qn=r("Start by cleaning up the text data. You\u2019ll need the tokenizer part of the processor to process the text:"),ba=h(),u(ve.$$.fragment),Ta=h(),k=n("p"),Hn=r("The dataset examples contain "),yt=n("code"),Dn=r("raw_text"),Pn=r(" and "),Mt=n("code"),Kn=r("normalized_text"),Ln=r(` features. When deciding which feature to use as the text input,
consider that the SpeechT5 tokenizer doesn\u2019t have any tokens for numbers. In `),wt=n("code"),On=r("normalized_text"),ep=r(` the numbers are written
out as text. Thus, it is a better fit, and we recommend using    `),jt=n("code"),sp=r("normalized_text"),tp=r(" as input text."),Ja=h(),v=n("p"),ap=r(`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 `),gt=n("code"),lp=r("<unk>"),np=r(" tokens. However, in Dutch, certain characters like "),bt=n("code"),pp=r("\xE0"),op=r(` are
used to stress syllables. In order to preserve the meaning of the text, we can replace this character with a regular `),Tt=n("code"),rp=r("a"),ip=r("."),Ua=h(),J=n("p"),hp=r("To identify unsupported tokens, extract all unique characters in the dataset using the "),Jt=n("code"),cp=r("SpeechT5Tokenizer"),mp=r(` which
works with characters as tokens. To do this, write the `),Ut=n("code"),up=r("extract_all_chars"),dp=r(` mapping function that concatenates
the transcriptions from all examples into one string and converts it to a set of characters.
Make sure to set `),kt=n("code"),fp=r("batched=True"),yp=r(" and "),vt=n("code"),Mp=r("batch_size=-1"),wp=r(" in "),It=n("code"),jp=r("dataset.map()"),gp=r(` so that all transcriptions are available at once for
the mapping function.`),ka=h(),u(Ie.$$.fragment),va=h(),vs=n("p"),bp=r(`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.`),Ia=h(),u(_e.$$.fragment),_a=h(),K=n("p"),Tp=r(`To handle the unsupported characters identified in the previous step, define a function that maps these characters to
valid tokens. Note that spaces are already replaced by `),_t=n("code"),Jp=r("\u2581"),Up=r(" in the tokenizer and don\u2019t need to be handled separately."),$a=h(),u($e.$$.fragment),Ca=h(),Is=n("p"),kp=r("Now that you have dealt with special characters in the text, it\u2019s time to shift focus to the audio data."),Za=h(),R=n("h3"),L=n("a"),$t=n("span"),u(Ce.$$.fragment),vp=h(),Ct=n("span"),Ip=r("Speakers"),Ea=h(),_s=n("p"),_p=r(`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.`),xa=h(),u(Ze.$$.fragment),Va=h(),$s=n("p"),$p=r("By plotting a histogram you can get a sense of how much data there is for each speaker."),Ga=h(),u(Ee.$$.fragment),Ba=h(),xe=n("div"),Cs=n("img"),Wa=h(),Zs=n("p"),Cp=r(`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.`),Ra=h(),u(Ve.$$.fragment),Xa=h(),Es=n("p"),Zp=r("Let\u2019s check how many speakers remain:"),Ya=h(),u(Ge.$$.fragment),Na=h(),xs=n("p"),Ep=r("Let\u2019s see how many examples are left:"),za=h(),u(Be.$$.fragment),Aa=h(),Vs=n("p"),xp=r("You are left with just under 10,000 examples from approximately 40 unique speakers, which should be sufficient."),Sa=h(),Gs=n("p"),Vp=r(`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.`),Qa=h(),X=n("h3"),O=n("a"),Zt=n("span"),u(We.$$.fragment),Gp=h(),Et=n("span"),Bp=r("Speaker embeddings"),Fa=h(),ee=n("p"),Wp=r(`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 `),Re=n("a"),Rp=r("spkrec-xvect-voxceleb"),Xp=r(`
model from SpeechBrain.`),qa=h(),se=n("p"),Yp=r("Create a function "),xt=n("code"),Np=r("create_speaker_embedding()"),zp=r(` that takes an input audio waveform and outputs a 512-element vector
containing the corresponding speaker embedding.`),Ha=h(),u(Xe.$$.fragment),Da=h(),te=n("p"),Ap=r("It\u2019s important to note that the "),Vt=n("code"),Sp=r("speechbrain/spkrec-xvect-voxceleb"),Qp=r(` 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.`),Pa=h(),Bs=n("p"),Fp=r(`For optimal results, we recommend training 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.`),Ka=h(),Y=n("h3"),ae=n("a"),Gt=n("span"),u(Ye.$$.fragment),qp=h(),Bt=n("span"),Hp=r("Processing the dataset"),La=h(),Z=n("p"),Dp=r("Finally, let\u2019s process the data into the format the model expects. Create a "),Wt=n("code"),Pp=r("prepare_dataset"),Kp=r(` function that takes in a
single example and uses the `),Rt=n("code"),Lp=r("SpeechT5Processor"),Op=r(` 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.`),Oa=h(),u(Ne.$$.fragment),el=h(),Ws=n("p"),eo=r("Verify the processing is correct by looking at a single example:"),sl=h(),u(ze.$$.fragment),tl=h(),Rs=n("p"),so=r("Speaker embeddings should be a 512-element vector:"),al=h(),u(Ae.$$.fragment),ll=h(),Xs=n("p"),to=r("The labels should be a log-mel spectrogram with 80 mel bins."),nl=h(),u(Se.$$.fragment),pl=h(),Qe=n("div"),Ys=n("img"),ol=h(),Ns=n("p"),ao=r(`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.`),rl=h(),zs=n("p"),lo=r("Now apply the processing function to the entire dataset. This will take between 5 and 10 minutes."),il=h(),u(Fe.$$.fragment),hl=h(),As=n("p"),no=r(`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.`),cl=h(),u(qe.$$.fragment),ml=h(),Ss=n("p"),po=r("Next, create a basic train/test split:"),ul=h(),u(He.$$.fragment),dl=h(),N=n("h3"),le=n("a"),Xt=n("span"),u(De.$$.fragment),oo=h(),Yt=n("span"),ro=r("Data collator"),fl=h(),ne=n("p"),io=r(`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 `),Nt=n("code"),ho=r("-100"),co=r(`. This special value
instructs the model to ignore that part of the spectrogram when calculating the spectrogram loss.`),yl=h(),u(Pe.$$.fragment),Ml=h(),Qs=n("p"),mo=r(`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.`),wl=h(),u(Ke.$$.fragment),jl=h(),z=n("h2"),pe=n("a"),zt=n("span"),u(Le.$$.fragment),uo=h(),At=n("span"),fo=r("Train the model"),gl=h(),Fs=n("p"),yo=r("Load the pre-trained model from the same checkpoint as you used for loading the processor:"),bl=h(),u(Oe.$$.fragment),Tl=h(),oe=n("p"),Mo=r("The "),St=n("code"),wo=r("use_cache=True"),jo=r(" option is incompatible with gradient checkpointing. Disable it for training."),Jl=h(),u(es.$$.fragment),Ul=h(),qs=n("p"),go=r(`Define the training arguments. Here we are not computing any evaluation metrics during the training process. Instead, we\u2019ll
only look at the loss:`),kl=h(),u(ss.$$.fragment),vl=h(),re=n("p"),bo=r("Instantiate the "),Qt=n("code"),To=r("Trainer"),Jo=r(" object  and pass the model, dataset, and data collator to it."),Il=h(),u(ts.$$.fragment),_l=h(),E=n("p"),Uo=r(`And with that, you\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 `),Ft=n("code"),ko=r("per_device_train_batch_size"),vo=r(" incrementally by factors of 2 and increase "),qt=n("code"),Io=r("gradient_accumulation_steps"),_o=r(" by 2x to compensate."),$l=h(),u(as.$$.fragment),Cl=h(),Hs=n("p"),$o=r("Push the final model to the \u{1F917} Hub:"),Zl=h(),u(ls.$$.fragment),El=h(),A=n("h2"),ie=n("a"),Ht=n("span"),u(ns.$$.fragment),Co=h(),Dt=n("span"),Zo=r("Inference"),xl=h(),Ds=n("p"),Eo=r(`Great, now that you\u2019ve 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):`),Vl=h(),u(ps.$$.fragment),Gl=h(),Ps=n("p"),xo=r("Pick an example, here we\u2019ll take one from the test dataset. Obtain a speaker embedding."),Bl=h(),u(os.$$.fragment),Wl=h(),Ks=n("p"),Vo=r("Define some input text and tokenize it."),Rl=h(),u(rs.$$.fragment),Xl=h(),Ls=n("p"),Go=r("Preprocess the input text:"),Yl=h(),u(is.$$.fragment),Nl=h(),Os=n("p"),Bo=r("Create a spectrogram with your model:"),zl=h(),u(hs.$$.fragment),Al=h(),et=n("p"),Wo=r("Visualize the spectrogram, if you\u2019d like to:"),Sl=h(),u(cs.$$.fragment),Ql=h(),ms=n("div"),st=n("img"),Fl=h(),tt=n("p"),Ro=r("Finally, use the vocoder to turn the spectrogram into sound."),ql=h(),u(us.$$.fragment),Hl=h(),at=n("p"),Xo=r(`In our experience, obtaining satisfactory results from this model can be challenging. The quality of the speaker
embeddings appears to 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.`),Dl=h(),he=n("p"),Yo=r(`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 `),Pt=n("code"),No=r("config.reduction_factor = 1"),zo=r(` to
see if this improves the results.`),Pl=h(),lt=n("p"),Ao=r(`Finally, it is essential to consider ethical considerations. Although TTS technology has numerous useful applications, it
may also be used for malicious purposes, such as impersonating someone\u2019s voice without their knowledge or consent. Please
use TTS judiciously and responsibly.`),this.h()},l(e){const t=Fi('[data-svelte="svelte-1phssyn"]',document.head);b=p(t,"META",{name:!0,content:!0}),t.forEach(s),S=c(e),U=p(e,"H1",{class:!0});var ds=o(U);T=p(ds,"A",{id:!0,class:!0,href:!0});var Do=o(T);$=p(Do,"SPAN",{});var Po=o($);d(g.$$.fragment,Po),Po.forEach(s),Do.forEach(s),C=c(ds),ot=p(ds,"SPAN",{});var Ko=o(ot);wn=i(Ko,"Text to speech"),Ko.forEach(s),ds.forEach(s),Lt=c(e),d(ue.$$.fragment,e),Ot=c(e),Q=p(e,"P",{});var Ll=o(Q);jn=i(Ll,`Text-to-speech (TTS) is the task of creating natural-sounding speech from text, where the speech can be generated in multiple
languages and for multiple speakers. The only text-to-speech model currently available in \u{1F917} Transformers
is `),fs=p(Ll,"A",{href:!0});var Lo=o(fs);gn=i(Lo,"SpeechT5"),Lo.forEach(s),bn=i(Ll,`, though more will be added in the future. SpeechT5 is pre-trained on a combination of
speech-to-text and text-to-speech data, allowing it to learn a unified space of hidden representations shared by both text
and speech. This means that the same pre-trained model can be fine-tuned for different tasks. Furthermore, SpeechT5
supports multiple speakers through x-vector speaker embeddings.`),Ll.forEach(s),ea=c(e),ys=p(e,"P",{});var Oo=o(ys);Tn=i(Oo,"This guide illustrates how to:"),Oo.forEach(s),sa=c(e),F=p(e,"OL",{});var Ol=o(F);_=p(Ol,"LI",{});var ce=o(_);Jn=i(ce,"Fine-tune "),Ms=p(ce,"A",{href:!0});var er=o(Ms);Un=i(er,"SpeechT5"),er.forEach(s),kn=i(ce," that was originally trained on English speech on the Dutch ("),rt=p(ce,"CODE",{});var sr=o(rt);vn=i(sr,"nl"),sr.forEach(s),In=i(ce,") language subset of the "),de=p(ce,"A",{href:!0,rel:!0});var tr=o(de);_n=i(tr,"VoxPopuli"),tr.forEach(s),$n=i(ce," dataset."),ce.forEach(s),Cn=c(Ol),it=p(Ol,"LI",{});var ar=o(it);Zn=i(ar,"Use your fine-tuned model for inference."),ar.forEach(s),Ol.forEach(s),ta=c(e),ws=p(e,"P",{});var lr=o(ws);En=i(lr,"Before you begin, make sure you have all the necessary libraries installed:"),lr.forEach(s),aa=c(e),d(fe.$$.fragment,e),la=c(e),js=p(e,"P",{});var nr=o(js);xn=i(nr,"Install \u{1F917}Transformers from source as not all the SpeechT5 features have been merged into an official release yet:"),nr.forEach(s),na=c(e),d(ye.$$.fragment,e),pa=c(e),d(q.$$.fragment,e),oa=c(e),gs=p(e,"P",{});var pr=o(gs);Vn=i(pr,"We encourage you to log in to your Hugging Face account to upload and share your model with the community. When prompted, enter your token to log in:"),pr.forEach(s),ra=c(e),d(Me.$$.fragment,e),ia=c(e),G=p(e,"H2",{class:!0});var en=o(G);H=p(en,"A",{id:!0,class:!0,href:!0});var or=o(H);ht=p(or,"SPAN",{});var rr=o(ht);d(we.$$.fragment,rr),rr.forEach(s),or.forEach(s),Gn=c(en),ct=p(en,"SPAN",{});var ir=o(ct);Bn=i(ir,"Load the dataset"),ir.forEach(s),en.forEach(s),ha=c(e),je=p(e,"P",{});var So=o(je);ge=p(So,"A",{href:!0,rel:!0});var hr=o(ge);Wn=i(hr,"VoxPopuli"),hr.forEach(s),Rn=i(So,` 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. In this guide, we are using the Dutch language subset, feel free to pick another subset.`),So.forEach(s),ca=c(e),bs=p(e,"P",{});var cr=o(bs);Xn=i(cr,`Note that VoxPopuli or any other automated speech recognition (ASR) dataset may not be the most suitable
option for training TTS models. The features that make it beneficial for ASR, such as excessive background noise, are
typically undesirable in TTS. However, finding top-quality, multilingual, and multi-speaker TTS datasets can be quite
challenging.`),cr.forEach(s),ma=c(e),Ts=p(e,"P",{});var mr=o(Ts);Yn=i(mr,"Let\u2019s load the data:"),mr.forEach(s),ua=c(e),d(be.$$.fragment,e),da=c(e),Js=p(e,"P",{});var ur=o(Js);Nn=i(ur,`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:`),ur.forEach(s),fa=c(e),d(Te.$$.fragment,e),ya=c(e),B=p(e,"H2",{class:!0});var sn=o(B);D=p(sn,"A",{id:!0,class:!0,href:!0});var dr=o(D);mt=p(dr,"SPAN",{});var fr=o(mt);d(Je.$$.fragment,fr),fr.forEach(s),dr.forEach(s),zn=c(sn),ut=p(sn,"SPAN",{});var yr=o(ut);An=i(yr,"Preprocess the data"),yr.forEach(s),sn.forEach(s),Ma=c(e),Us=p(e,"P",{});var Mr=o(Us);Sn=i(Mr,"Let\u2019s begin by defining the model checkpoint to use and loading the appropriate processor:"),Mr.forEach(s),wa=c(e),d(Ue.$$.fragment,e),ja=c(e),W=p(e,"H3",{class:!0});var tn=o(W);P=p(tn,"A",{id:!0,class:!0,href:!0});var wr=o(P);dt=p(wr,"SPAN",{});var jr=o(dt);d(ke.$$.fragment,jr),jr.forEach(s),wr.forEach(s),Qn=c(tn),ft=p(tn,"SPAN",{});var gr=o(ft);Fn=i(gr,"Text cleanup for SpeechT5 tokenization"),gr.forEach(s),tn.forEach(s),ga=c(e),ks=p(e,"P",{});var br=o(ks);qn=i(br,"Start by cleaning up the text data. You\u2019ll need the tokenizer part of the processor to process the text:"),br.forEach(s),ba=c(e),d(ve.$$.fragment,e),Ta=c(e),k=p(e,"P",{});var x=o(k);Hn=i(x,"The dataset examples contain "),yt=p(x,"CODE",{});var Tr=o(yt);Dn=i(Tr,"raw_text"),Tr.forEach(s),Pn=i(x," and "),Mt=p(x,"CODE",{});var Jr=o(Mt);Kn=i(Jr,"normalized_text"),Jr.forEach(s),Ln=i(x,` features. When deciding which feature to use as the text input,
consider that the SpeechT5 tokenizer doesn\u2019t have any tokens for numbers. In `),wt=p(x,"CODE",{});var Ur=o(wt);On=i(Ur,"normalized_text"),Ur.forEach(s),ep=i(x,` the numbers are written
out as text. Thus, it is a better fit, and we recommend using    `),jt=p(x,"CODE",{});var kr=o(jt);sp=i(kr,"normalized_text"),kr.forEach(s),tp=i(x," as input text."),x.forEach(s),Ja=c(e),v=p(e,"P",{});var me=o(v);ap=i(me,`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 `),gt=p(me,"CODE",{});var vr=o(gt);lp=i(vr,"<unk>"),vr.forEach(s),np=i(me," tokens. However, in Dutch, certain characters like "),bt=p(me,"CODE",{});var Ir=o(bt);pp=i(Ir,"\xE0"),Ir.forEach(s),op=i(me,` are
used to stress syllables. In order to preserve the meaning of the text, we can replace this character with a regular `),Tt=p(me,"CODE",{});var _r=o(Tt);rp=i(_r,"a"),_r.forEach(s),ip=i(me,"."),me.forEach(s),Ua=c(e),J=p(e,"P",{});var I=o(J);hp=i(I,"To identify unsupported tokens, extract all unique characters in the dataset using the "),Jt=p(I,"CODE",{});var $r=o(Jt);cp=i($r,"SpeechT5Tokenizer"),$r.forEach(s),mp=i(I,` which
works with characters as tokens. To do this, write the `),Ut=p(I,"CODE",{});var Cr=o(Ut);up=i(Cr,"extract_all_chars"),Cr.forEach(s),dp=i(I,` mapping function that concatenates
the transcriptions from all examples into one string and converts it to a set of characters.
Make sure to set `),kt=p(I,"CODE",{});var Zr=o(kt);fp=i(Zr,"batched=True"),Zr.forEach(s),yp=i(I," and "),vt=p(I,"CODE",{});var Er=o(vt);Mp=i(Er,"batch_size=-1"),Er.forEach(s),wp=i(I," in "),It=p(I,"CODE",{});var xr=o(It);jp=i(xr,"dataset.map()"),xr.forEach(s),gp=i(I,` so that all transcriptions are available at once for
the mapping function.`),I.forEach(s),ka=c(e),d(Ie.$$.fragment,e),va=c(e),vs=p(e,"P",{});var Vr=o(vs);bp=i(Vr,`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.`),Vr.forEach(s),Ia=c(e),d(_e.$$.fragment,e),_a=c(e),K=p(e,"P",{});var an=o(K);Tp=i(an,`To handle the unsupported characters identified in the previous step, define a function that maps these characters to
valid tokens. Note that spaces are already replaced by `),_t=p(an,"CODE",{});var Gr=o(_t);Jp=i(Gr,"\u2581"),Gr.forEach(s),Up=i(an," in the tokenizer and don\u2019t need to be handled separately."),an.forEach(s),$a=c(e),d($e.$$.fragment,e),Ca=c(e),Is=p(e,"P",{});var Br=o(Is);kp=i(Br,"Now that you have dealt with special characters in the text, it\u2019s time to shift focus to the audio data."),Br.forEach(s),Za=c(e),R=p(e,"H3",{class:!0});var ln=o(R);L=p(ln,"A",{id:!0,class:!0,href:!0});var Wr=o(L);$t=p(Wr,"SPAN",{});var Rr=o($t);d(Ce.$$.fragment,Rr),Rr.forEach(s),Wr.forEach(s),vp=c(ln),Ct=p(ln,"SPAN",{});var Xr=o(Ct);Ip=i(Xr,"Speakers"),Xr.forEach(s),ln.forEach(s),Ea=c(e),_s=p(e,"P",{});var Yr=o(_s);_p=i(Yr,`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.`),Yr.forEach(s),xa=c(e),d(Ze.$$.fragment,e),Va=c(e),$s=p(e,"P",{});var Nr=o($s);$p=i(Nr,"By plotting a histogram you can get a sense of how much data there is for each speaker."),Nr.forEach(s),Ga=c(e),d(Ee.$$.fragment,e),Ba=c(e),xe=p(e,"DIV",{class:!0});var zr=o(xe);Cs=p(zr,"IMG",{src:!0,alt:!0}),zr.forEach(s),Wa=c(e),Zs=p(e,"P",{});var Ar=o(Zs);Cp=i(Ar,`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.`),Ar.forEach(s),Ra=c(e),d(Ve.$$.fragment,e),Xa=c(e),Es=p(e,"P",{});var Sr=o(Es);Zp=i(Sr,"Let\u2019s check how many speakers remain:"),Sr.forEach(s),Ya=c(e),d(Ge.$$.fragment,e),Na=c(e),xs=p(e,"P",{});var Qr=o(xs);Ep=i(Qr,"Let\u2019s see how many examples are left:"),Qr.forEach(s),za=c(e),d(Be.$$.fragment,e),Aa=c(e),Vs=p(e,"P",{});var Fr=o(Vs);xp=i(Fr,"You are left with just under 10,000 examples from approximately 40 unique speakers, which should be sufficient."),Fr.forEach(s),Sa=c(e),Gs=p(e,"P",{});var qr=o(Gs);Vp=i(qr,`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.`),qr.forEach(s),Qa=c(e),X=p(e,"H3",{class:!0});var nn=o(X);O=p(nn,"A",{id:!0,class:!0,href:!0});var Hr=o(O);Zt=p(Hr,"SPAN",{});var Dr=o(Zt);d(We.$$.fragment,Dr),Dr.forEach(s),Hr.forEach(s),Gp=c(nn),Et=p(nn,"SPAN",{});var Pr=o(Et);Bp=i(Pr,"Speaker embeddings"),Pr.forEach(s),nn.forEach(s),Fa=c(e),ee=p(e,"P",{});var pn=o(ee);Wp=i(pn,`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 `),Re=p(pn,"A",{href:!0,rel:!0});var Kr=o(Re);Rp=i(Kr,"spkrec-xvect-voxceleb"),Kr.forEach(s),Xp=i(pn,`
model from SpeechBrain.`),pn.forEach(s),qa=c(e),se=p(e,"P",{});var on=o(se);Yp=i(on,"Create a function "),xt=p(on,"CODE",{});var Lr=o(xt);Np=i(Lr,"create_speaker_embedding()"),Lr.forEach(s),zp=i(on,` that takes an input audio waveform and outputs a 512-element vector
containing the corresponding speaker embedding.`),on.forEach(s),Ha=c(e),d(Xe.$$.fragment,e),Da=c(e),te=p(e,"P",{});var rn=o(te);Ap=i(rn,"It\u2019s important to note that the "),Vt=p(rn,"CODE",{});var Or=o(Vt);Sp=i(Or,"speechbrain/spkrec-xvect-voxceleb"),Or.forEach(s),Qp=i(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(s),Pa=c(e),Bs=p(e,"P",{});var ei=o(Bs);Fp=i(ei,`For optimal results, we recommend training 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.`),ei.forEach(s),Ka=c(e),Y=p(e,"H3",{class:!0});var hn=o(Y);ae=p(hn,"A",{id:!0,class:!0,href:!0});var si=o(ae);Gt=p(si,"SPAN",{});var ti=o(Gt);d(Ye.$$.fragment,ti),ti.forEach(s),si.forEach(s),qp=c(hn),Bt=p(hn,"SPAN",{});var ai=o(Bt);Hp=i(ai,"Processing the dataset"),ai.forEach(s),hn.forEach(s),La=c(e),Z=p(e,"P",{});var nt=o(Z);Dp=i(nt,"Finally, let\u2019s process the data into the format the model expects. Create a "),Wt=p(nt,"CODE",{});var li=o(Wt);Pp=i(li,"prepare_dataset"),li.forEach(s),Kp=i(nt,` function that takes in a
single example and uses the `),Rt=p(nt,"CODE",{});var ni=o(Rt);Lp=i(ni,"SpeechT5Processor"),ni.forEach(s),Op=i(nt,` 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.`),nt.forEach(s),Oa=c(e),d(Ne.$$.fragment,e),el=c(e),Ws=p(e,"P",{});var pi=o(Ws);eo=i(pi,"Verify the processing is correct by looking at a single example:"),pi.forEach(s),sl=c(e),d(ze.$$.fragment,e),tl=c(e),Rs=p(e,"P",{});var oi=o(Rs);so=i(oi,"Speaker embeddings should be a 512-element vector:"),oi.forEach(s),al=c(e),d(Ae.$$.fragment,e),ll=c(e),Xs=p(e,"P",{});var ri=o(Xs);to=i(ri,"The labels should be a log-mel spectrogram with 80 mel bins."),ri.forEach(s),nl=c(e),d(Se.$$.fragment,e),pl=c(e),Qe=p(e,"DIV",{class:!0});var ii=o(Qe);Ys=p(ii,"IMG",{src:!0,alt:!0}),ii.forEach(s),ol=c(e),Ns=p(e,"P",{});var hi=o(Ns);ao=i(hi,`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.`),hi.forEach(s),rl=c(e),zs=p(e,"P",{});var ci=o(zs);lo=i(ci,"Now apply the processing function to the entire dataset. This will take between 5 and 10 minutes."),ci.forEach(s),il=c(e),d(Fe.$$.fragment,e),hl=c(e),As=p(e,"P",{});var mi=o(As);no=i(mi,`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.`),mi.forEach(s),cl=c(e),d(qe.$$.fragment,e),ml=c(e),Ss=p(e,"P",{});var ui=o(Ss);po=i(ui,"Next, create a basic train/test split:"),ui.forEach(s),ul=c(e),d(He.$$.fragment,e),dl=c(e),N=p(e,"H3",{class:!0});var cn=o(N);le=p(cn,"A",{id:!0,class:!0,href:!0});var di=o(le);Xt=p(di,"SPAN",{});var fi=o(Xt);d(De.$$.fragment,fi),fi.forEach(s),di.forEach(s),oo=c(cn),Yt=p(cn,"SPAN",{});var yi=o(Yt);ro=i(yi,"Data collator"),yi.forEach(s),cn.forEach(s),fl=c(e),ne=p(e,"P",{});var mn=o(ne);io=i(mn,`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 `),Nt=p(mn,"CODE",{});var Mi=o(Nt);ho=i(Mi,"-100"),Mi.forEach(s),co=i(mn,`. This special value
instructs the model to ignore that part of the spectrogram when calculating the spectrogram loss.`),mn.forEach(s),yl=c(e),d(Pe.$$.fragment,e),Ml=c(e),Qs=p(e,"P",{});var wi=o(Qs);mo=i(wi,`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.`),wi.forEach(s),wl=c(e),d(Ke.$$.fragment,e),jl=c(e),z=p(e,"H2",{class:!0});var un=o(z);pe=p(un,"A",{id:!0,class:!0,href:!0});var ji=o(pe);zt=p(ji,"SPAN",{});var gi=o(zt);d(Le.$$.fragment,gi),gi.forEach(s),ji.forEach(s),uo=c(un),At=p(un,"SPAN",{});var bi=o(At);fo=i(bi,"Train the model"),bi.forEach(s),un.forEach(s),gl=c(e),Fs=p(e,"P",{});var Ti=o(Fs);yo=i(Ti,"Load the pre-trained model from the same checkpoint as you used for loading the processor:"),Ti.forEach(s),bl=c(e),d(Oe.$$.fragment,e),Tl=c(e),oe=p(e,"P",{});var dn=o(oe);Mo=i(dn,"The "),St=p(dn,"CODE",{});var Ji=o(St);wo=i(Ji,"use_cache=True"),Ji.forEach(s),jo=i(dn," option is incompatible with gradient checkpointing. Disable it for training."),dn.forEach(s),Jl=c(e),d(es.$$.fragment,e),Ul=c(e),qs=p(e,"P",{});var Ui=o(qs);go=i(Ui,`Define the training arguments. Here we are not computing any evaluation metrics during the training process. Instead, we\u2019ll
only look at the loss:`),Ui.forEach(s),kl=c(e),d(ss.$$.fragment,e),vl=c(e),re=p(e,"P",{});var fn=o(re);bo=i(fn,"Instantiate the "),Qt=p(fn,"CODE",{});var ki=o(Qt);To=i(ki,"Trainer"),ki.forEach(s),Jo=i(fn," object  and pass the model, dataset, and data collator to it."),fn.forEach(s),Il=c(e),d(ts.$$.fragment,e),_l=c(e),E=p(e,"P",{});var pt=o(E);Uo=i(pt,`And with that, you\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 `),Ft=p(pt,"CODE",{});var vi=o(Ft);ko=i(vi,"per_device_train_batch_size"),vi.forEach(s),vo=i(pt," incrementally by factors of 2 and increase "),qt=p(pt,"CODE",{});var Ii=o(qt);Io=i(Ii,"gradient_accumulation_steps"),Ii.forEach(s),_o=i(pt," by 2x to compensate."),pt.forEach(s),$l=c(e),d(as.$$.fragment,e),Cl=c(e),Hs=p(e,"P",{});var _i=o(Hs);$o=i(_i,"Push the final model to the \u{1F917} Hub:"),_i.forEach(s),Zl=c(e),d(ls.$$.fragment,e),El=c(e),A=p(e,"H2",{class:!0});var yn=o(A);ie=p(yn,"A",{id:!0,class:!0,href:!0});var $i=o(ie);Ht=p($i,"SPAN",{});var Ci=o(Ht);d(ns.$$.fragment,Ci),Ci.forEach(s),$i.forEach(s),Co=c(yn),Dt=p(yn,"SPAN",{});var Zi=o(Dt);Zo=i(Zi,"Inference"),Zi.forEach(s),yn.forEach(s),xl=c(e),Ds=p(e,"P",{});var Ei=o(Ds);Eo=i(Ei,`Great, now that you\u2019ve 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):`),Ei.forEach(s),Vl=c(e),d(ps.$$.fragment,e),Gl=c(e),Ps=p(e,"P",{});var xi=o(Ps);xo=i(xi,"Pick an example, here we\u2019ll take one from the test dataset. Obtain a speaker embedding."),xi.forEach(s),Bl=c(e),d(os.$$.fragment,e),Wl=c(e),Ks=p(e,"P",{});var Vi=o(Ks);Vo=i(Vi,"Define some input text and tokenize it."),Vi.forEach(s),Rl=c(e),d(rs.$$.fragment,e),Xl=c(e),Ls=p(e,"P",{});var Gi=o(Ls);Go=i(Gi,"Preprocess the input text:"),Gi.forEach(s),Yl=c(e),d(is.$$.fragment,e),Nl=c(e),Os=p(e,"P",{});var Bi=o(Os);Bo=i(Bi,"Create a spectrogram with your model:"),Bi.forEach(s),zl=c(e),d(hs.$$.fragment,e),Al=c(e),et=p(e,"P",{});var Wi=o(et);Wo=i(Wi,"Visualize the spectrogram, if you\u2019d like to:"),Wi.forEach(s),Sl=c(e),d(cs.$$.fragment,e),Ql=c(e),ms=p(e,"DIV",{class:!0});var Ri=o(ms);st=p(Ri,"IMG",{src:!0,alt:!0}),Ri.forEach(s),Fl=c(e),tt=p(e,"P",{});var Xi=o(tt);Ro=i(Xi,"Finally, use the vocoder to turn the spectrogram into sound."),Xi.forEach(s),ql=c(e),d(us.$$.fragment,e),Hl=c(e),at=p(e,"P",{});var Yi=o(at);Xo=i(Yi,`In our experience, obtaining satisfactory results from this model can be challenging. The quality of the speaker
embeddings appears to 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.`),Yi.forEach(s),Dl=c(e),he=p(e,"P",{});var Mn=o(he);Yo=i(Mn,`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 `),Pt=p(Mn,"CODE",{});var Ni=o(Pt);No=i(Ni,"config.reduction_factor = 1"),Ni.forEach(s),zo=i(Mn,` to
see if this improves the results.`),Mn.forEach(s),Pl=c(e),lt=p(e,"P",{});var zi=o(lt);Ao=i(zi,`Finally, it is essential to consider ethical considerations. Although TTS technology has numerous useful applications, it
may also be used for malicious purposes, such as impersonating someone\u2019s voice without their knowledge or consent. Please
use TTS judiciously and responsibly.`),zi.forEach(s),this.h()},h(){m(b,"name","hf:doc:metadata"),m(b,"content",JSON.stringify(Oi)),m(T,"id","text-to-speech"),m(T,"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"),m(T,"href","#text-to-speech"),m(U,"class","relative group"),m(fs,"href","model_doc/speecht5"),m(Ms,"href","model_doc/speecht5"),m(de,"href","https://huggingface.co/datasets/facebook/voxpopuli"),m(de,"rel","nofollow"),m(H,"id","load-the-dataset"),m(H,"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"),m(H,"href","#load-the-dataset"),m(G,"class","relative group"),m(ge,"href","https://huggingface.co/datasets/facebook/voxpopuli"),m(ge,"rel","nofollow"),m(D,"id","preprocess-the-data"),m(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"),m(D,"href","#preprocess-the-data"),m(B,"class","relative group"),m(P,"id","text-cleanup-for-speecht5-tokenization"),m(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"),m(P,"href","#text-cleanup-for-speecht5-tokenization"),m(W,"class","relative group"),m(L,"id","speakers"),m(L,"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"),m(L,"href","#speakers"),m(R,"class","relative group"),Qo(Cs.src,Fo="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/tts_speakers_histogram.png")||m(Cs,"src",Fo),m(Cs,"alt","Speakers histogram"),m(xe,"class","flex justify-center"),m(O,"id","speaker-embeddings"),m(O,"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"),m(O,"href","#speaker-embeddings"),m(X,"class","relative group"),m(Re,"href","https://huggingface.co/speechbrain/spkrec-xvect-voxceleb"),m(Re,"rel","nofollow"),m(ae,"id","processing-the-dataset"),m(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"),m(ae,"href","#processing-the-dataset"),m(Y,"class","relative group"),Qo(Ys.src,qo="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/tts_logmelspectrogram_1.png")||m(Ys,"src",qo),m(Ys,"alt","Log-mel spectrogram with 80 mel bins"),m(Qe,"class","flex justify-center"),m(le,"id","data-collator"),m(le,"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"),m(le,"href","#data-collator"),m(N,"class","relative group"),m(pe,"id","train-the-model"),m(pe,"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"),m(pe,"href","#train-the-model"),m(z,"class","relative group"),m(ie,"id","inference"),m(ie,"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"),m(ie,"href","#inference"),m(A,"class","relative group"),Qo(st.src,Ho="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/tts_logmelspectrogram_2.png")||m(st,"src",Ho),m(st,"alt","Generated log-mel spectrogram"),m(ms,"class","flex justify-center")},m(e,t){a(document.head,b),l(e,S,t),l(e,U,t),a(U,T),a(T,$),f(g,$,null),a(U,C),a(U,ot),a(ot,wn),l(e,Lt,t),f(ue,e,t),l(e,Ot,t),l(e,Q,t),a(Q,jn),a(Q,fs),a(fs,gn),a(Q,bn),l(e,ea,t),l(e,ys,t),a(ys,Tn),l(e,sa,t),l(e,F,t),a(F,_),a(_,Jn),a(_,Ms),a(Ms,Un),a(_,kn),a(_,rt),a(rt,vn),a(_,In),a(_,de),a(de,_n),a(_,$n),a(F,Cn),a(F,it),a(it,Zn),l(e,ta,t),l(e,ws,t),a(ws,En),l(e,aa,t),f(fe,e,t),l(e,la,t),l(e,js,t),a(js,xn),l(e,na,t),f(ye,e,t),l(e,pa,t),f(q,e,t),l(e,oa,t),l(e,gs,t),a(gs,Vn),l(e,ra,t),f(Me,e,t),l(e,ia,t),l(e,G,t),a(G,H),a(H,ht),f(we,ht,null),a(G,Gn),a(G,ct),a(ct,Bn),l(e,ha,t),l(e,je,t),a(je,ge),a(ge,Wn),a(je,Rn),l(e,ca,t),l(e,bs,t),a(bs,Xn),l(e,ma,t),l(e,Ts,t),a(Ts,Yn),l(e,ua,t),f(be,e,t),l(e,da,t),l(e,Js,t),a(Js,Nn),l(e,fa,t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,t),f(Ke,e,t),l(e,jl,t),l(e,z,t),a(z,pe),a(pe,zt),f(Le,zt,null),a(z,uo),a(z,At),a(At,fo),l(e,gl,t),l(e,Fs,t),a(Fs,yo),l(e,bl,t),f(Oe,e,t),l(e,Tl,t),l(e,oe,t),a(oe,Mo),a(oe,St),a(St,wo),a(oe,jo),l(e,Jl,t),f(es,e,t),l(e,Ul,t),l(e,qs,t),a(qs,go),l(e,kl,t),f(ss,e,t),l(e,vl,t),l(e,re,t),a(re,bo),a(re,Qt),a(Qt,To),a(re,Jo),l(e,Il,t),f(ts,e,t),l(e,_l,t),l(e,E,t),a(E,Uo),a(E,Ft),a(Ft,ko),a(E,vo),a(E,qt),a(qt,Io),a(E,_o),l(e,$l,t),f(as,e,t),l(e,Cl,t),l(e,Hs,t),a(Hs,$o),l(e,Zl,t),f(ls,e,t),l(e,El,t),l(e,A,t),a(A,ie),a(ie,Ht),f(ns,Ht,null),a(A,Co),a(A,Dt),a(Dt,Zo),l(e,xl,t),l(e,Ds,t),a(Ds,Eo),l(e,Vl,t),f(ps,e,t),l(e,Gl,t),l(e,Ps,t),a(Ps,xo),l(e,Bl,t),f(os,e,t),l(e,Wl,t),l(e,Ks,t),a(Ks,Vo),l(e,Rl,t),f(rs,e,t),l(e,Xl,t),l(e,Ls,t),a(Ls,Go),l(e,Yl,t),f(is,e,t),l(e,Nl,t),l(e,Os,t),a(Os,Bo),l(e,zl,t),f(hs,e,t),l(e,Al,t),l(e,et,t),a(et,Wo),l(e,Sl,t),f(cs,e,t),l(e,Ql,t),l(e,ms,t),a(ms,st),l(e,Fl,t),l(e,tt,t),a(tt,Ro),l(e,ql,t),f(us,e,t),l(e,Hl,t),l(e,at,t),a(at,Xo),l(e,Dl,t),l(e,he,t),a(he,Yo),a(he,Pt),a(Pt,No),a(he,zo),l(e,Pl,t),l(e,lt,t),a(lt,Ao),Kl=!0},p(e,[t]){const ds={};t&2&&(ds.$$scope={dirty:t,ctx:e}),q.$set(ds)},i(e){Kl||(y(g.$$.fragment,e),y(ue.$$.fragment,e),y(fe.$$.fragment,e),y(ye.$$.fragment,e),y(q.$$.fragment,e),y(Me.$$.fragment,e),y(we.$$.fragment,e),y(be.$$.fragment,e),y(Te.$$.fragment,e),y(Je.$$.fragment,e),y(Ue.$$.fragment,e),y(ke.$$.fragment,e),y(ve.$$.fragment,e),y(Ie.$$.fragment,e),y(_e.$$.fragment,e),y($e.$$.fragment,e),y(Ce.$$.fragment,e),y(Ze.$$.fragment,e),y(Ee.$$.fragment,e),y(Ve.$$.fragment,e),y(Ge.$$.fragment,e),y(Be.$$.fragment,e),y(We.$$.fragment,e),y(Xe.$$.fragment,e),y(Ye.$$.fragment,e),y(Ne.$$.fragment,e),y(ze.$$.fragment,e),y(Ae.$$.fragment,e),y(Se.$$.fragment,e),y(Fe.$$.fragment,e),y(qe.$$.fragment,e),y(He.$$.fragment,e),y(De.$$.fragment,e),y(Pe.$$.fragment,e),y(Ke.$$.fragment,e),y(Le.$$.fragment,e),y(Oe.$$.fragment,e),y(es.$$.fragment,e),y(ss.$$.fragment,e),y(ts.$$.fragment,e),y(as.$$.fragment,e),y(ls.$$.fragment,e),y(ns.$$.fragment,e),y(ps.$$.fragment,e),y(os.$$.fragment,e),y(rs.$$.fragment,e),y(is.$$.fragment,e),y(hs.$$.fragment,e),y(cs.$$.fragment,e),y(us.$$.fragment,e),Kl=!0)},o(e){M(g.$$.fragment,e),M(ue.$$.fragment,e),M(fe.$$.fragment,e),M(ye.$$.fragment,e),M(q.$$.fragment,e),M(Me.$$.fragment,e),M(we.$$.fragment,e),M(be.$$.fragment,e),M(Te.$$.fragment,e),M(Je.$$.fragment,e),M(Ue.$$.fragment,e),M(ke.$$.fragment,e),M(ve.$$.fragment,e),M(Ie.$$.fragment,e),M(_e.$$.fragment,e),M($e.$$.fragment,e),M(Ce.$$.fragment,e),M(Ze.$$.fragment,e),M(Ee.$$.fragment,e),M(Ve.$$.fragment,e),M(Ge.$$.fragment,e),M(Be.$$.fragment,e),M(We.$$.fragment,e),M(Xe.$$.fragment,e),M(Ye.$$.fragment,e),M(Ne.$$.fragment,e),M(ze.$$.fragment,e),M(Ae.$$.fragment,e),M(Se.$$.fragment,e),M(Fe.$$.fragment,e),M(qe.$$.fragment,e),M(He.$$.fragment,e),M(De.$$.fragment,e),M(Pe.$$.fragment,e),M(Ke.$$.fragment,e),M(Le.$$.fragment,e),M(Oe.$$.fragment,e),M(es.$$.fragment,e),M(ss.$$.fragment,e),M(ts.$$.fragment,e),M(as.$$.fragment,e),M(ls.$$.fragment,e),M(ns.$$.fragment,e),M(ps.$$.fragment,e),M(os.$$.fragment,e),M(rs.$$.fragment,e),M(is.$$.fragment,e),M(hs.$$.fragment,e),M(cs.$$.fragment,e),M(us.$$.fragment,e),Kl=!1},d(e){s(b),e&&s(S),e&&s(U),w(g),e&&s(Lt),w(ue,e),e&&s(Ot),e&&s(Q),e&&s(ea),e&&s(ys),e&&s(sa),e&&s(F),e&&s(ta),e&&s(ws),e&&s(aa),w(fe,e),e&&s(la),e&&s(js),e&&s(na),w(ye,e),e&&s(pa),w(q,e),e&&s(oa),e&&s(gs),e&&s(ra),w(Me,e),e&&s(ia),e&&s(G),w(we),e&&s(ha),e&&s(je),e&&s(ca),e&&s(bs),e&&s(ma),e&&s(Ts),e&&s(ua),w(be,e),e&&s(da),e&&s(Js),e&&s(fa),w(Te,e),e&&s(ya),e&&s(B),w(Je),e&&s(Ma),e&&s(Us),e&&s(wa),w(Ue,e),e&&s(ja),e&&s(W),w(ke),e&&s(ga),e&&s(ks),e&&s(ba),w(ve,e),e&&s(Ta),e&&s(k),e&&s(Ja),e&&s(v),e&&s(Ua),e&&s(J),e&&s(ka),w(Ie,e),e&&s(va),e&&s(vs),e&&s(Ia),w(_e,e),e&&s(_a),e&&s(K),e&&s($a),w($e,e),e&&s(Ca),e&&s(Is),e&&s(Za),e&&s(R),w(Ce),e&&s(Ea),e&&s(_s),e&&s(xa),w(Ze,e),e&&s(Va),e&&s($s),e&&s(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al),e&&s(et),e&&s(Sl),w(cs,e),e&&s(Ql),e&&s(ms),e&&s(Fl),e&&s(tt),e&&s(ql),w(us,e),e&&s(Hl),e&&s(at),e&&s(Dl),e&&s(he),e&&s(Pl),e&&s(lt)}}}const Oi={local:"text-to-speech",sections:[{local:"load-the-dataset",title:"Load the dataset"},{local:"preprocess-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:"Preprocess the data"},{local:"train-the-model",title:"Train the model"},{local:"inference",title:"Inference"}],title:"Text to speech"};function eh(Kt){return qi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ph extends Ai{constructor(b){super();Si(this,b,eh,Li,Qi,{})}}export{ph as default,Oi as metadata};
