Spaces:
Running on Zero
Running on Zero
Deploy ZONOS3 9de6e39
Browse files- app.py +15 -5
- studio/assets/{chrome-CvZYAiOI.js → chrome-DSTbbLEf.js} +1 -1
- studio/assets/{index-CqBOQLX2.js → index-Cn8RrXS_.js} +1 -1
- studio/assets/{lite-3Vu_kVwP.js → lite-Dm3Lt5gI.js} +1 -1
- studio/assets/{studio-Bhcl8Nzz.js → studio-ltLzUm7R.js} +0 -0
- studio/assets/{web-engine-BJErJyzx.js → web-engine-Dm7WfUve.js} +1 -1
- studio/index.html +3 -3
- studio/lite.html +3 -3
- studio/studio.html +2 -2
- studio/sw.js +3 -3
app.py
CHANGED
|
@@ -469,6 +469,10 @@ SESSION_SECONDS = 240
|
|
| 469 |
HOLD_SECONDS = 60
|
| 470 |
RENEW_SECONDS = 45 # renew a session with less than this left after a take
|
| 471 |
MARGIN_SECONDS = 5 # a session stops taking work this long before its ZeroGPU deadline
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
_FORK = multiprocessing.get_context("fork") # spaces forks its GPU workers, which inherit both pipes
|
| 473 |
TAKE_RX, TAKE_TX = _FORK.Pipe(duplex=False) # (take id, request body) or None (close), main process -> session
|
| 474 |
RESULT_RX, RESULT_TX = _FORK.Pipe(duplex=False) # (take id, kind, payload), session -> main process
|
|
@@ -550,7 +554,7 @@ class GpuSessions:
|
|
| 550 |
except Exception as exc:
|
| 551 |
take.out.put_nowait(("failed", exc))
|
| 552 |
continue
|
| 553 |
-
if self.open() and self.left() < RENEW_SECONDS:
|
| 554 |
await self.close()
|
| 555 |
self.start(take.request, SESSION_SECONDS)
|
| 556 |
|
|
@@ -571,9 +575,12 @@ class GpuSessions:
|
|
| 571 |
await self.close() # it would run out mid-take, or is about to idle out
|
| 572 |
self.ids += 1
|
| 573 |
sender = None # a large take (a clip) blocks in the pipe until a session reads it: send alongside
|
| 574 |
-
|
|
|
|
|
|
|
|
|
|
| 575 |
if not self.open():
|
| 576 |
-
self.start(take.request,
|
| 577 |
if sender is None:
|
| 578 |
sender = asyncio.create_task(asyncio.to_thread(TAKE_TX.send, (self.ids, take.body)))
|
| 579 |
done = await self.pump(self.ids, take.out)
|
|
@@ -583,9 +590,12 @@ class GpuSessions:
|
|
| 583 |
if not done:
|
| 584 |
take.out.put_nowait(("error", "the GPU session ended mid-take"))
|
| 585 |
return
|
| 586 |
-
if self.session.exception() is not None:
|
|
|
|
|
|
|
|
|
|
| 587 |
await self.drain(sender)
|
| 588 |
-
raise
|
| 589 |
await self.drain(sender)
|
| 590 |
raise RuntimeError("the GPU session ended without running the take")
|
| 591 |
|
|
|
|
| 469 |
HOLD_SECONDS = 60
|
| 470 |
RENEW_SECONDS = 45 # renew a session with less than this left after a take
|
| 471 |
MARGIN_SECONDS = 5 # a session stops taking work this long before its ZeroGPU deadline
|
| 472 |
+
# ZeroGPU caps how long one call may hold a GPU, per visitor: one without a quota token (not signed in on huggingface.co,
|
| 473 |
+
# or the Space reached outside it) gets 60 s as ZeroGPU counts them, 40 of ours on its RTX PRO 6000 nodes (which ask for
|
| 474 |
+
# 1.5x a call's duration). A session refused as too long reopens at this length; such a session is not renewed.
|
| 475 |
+
CAPPED_SESSION_SECONDS = 40
|
| 476 |
_FORK = multiprocessing.get_context("fork") # spaces forks its GPU workers, which inherit both pipes
|
| 477 |
TAKE_RX, TAKE_TX = _FORK.Pipe(duplex=False) # (take id, request body) or None (close), main process -> session
|
| 478 |
RESULT_RX, RESULT_TX = _FORK.Pipe(duplex=False) # (take id, kind, payload), session -> main process
|
|
|
|
| 554 |
except Exception as exc:
|
| 555 |
take.out.put_nowait(("failed", exc))
|
| 556 |
continue
|
| 557 |
+
if self.open() and self.seconds >= SESSION_SECONDS and self.left() < RENEW_SECONDS:
|
| 558 |
await self.close()
|
| 559 |
self.start(take.request, SESSION_SECONDS)
|
| 560 |
|
|
|
|
| 575 |
await self.close() # it would run out mid-take, or is about to idle out
|
| 576 |
self.ids += 1
|
| 577 |
sender = None # a large take (a clip) blocks in the pipe until a session reads it: send alongside
|
| 578 |
+
seconds = max(SESSION_SECONDS, need + MARGIN_SECONDS + 1)
|
| 579 |
+
# a session that idled out as the take was sent, or that ZeroGPU refused as too long for this visitor, left it in
|
| 580 |
+
# the pipe for the next one
|
| 581 |
+
for _ in range(3):
|
| 582 |
if not self.open():
|
| 583 |
+
self.start(take.request, seconds)
|
| 584 |
if sender is None:
|
| 585 |
sender = asyncio.create_task(asyncio.to_thread(TAKE_TX.send, (self.ids, take.body)))
|
| 586 |
done = await self.pump(self.ids, take.out)
|
|
|
|
| 590 |
if not done:
|
| 591 |
take.out.put_nowait(("error", "the GPU session ended mid-take"))
|
| 592 |
return
|
| 593 |
+
if (exc := self.session.exception()) is not None:
|
| 594 |
+
if seconds > CAPPED_SESSION_SECONDS and isinstance(exc, gr.Error) and exc.title == "ZeroGPU illegal duration":
|
| 595 |
+
seconds = CAPPED_SESSION_SECONDS
|
| 596 |
+
continue
|
| 597 |
await self.drain(sender)
|
| 598 |
+
raise exc
|
| 599 |
await self.drain(sender)
|
| 600 |
raise RuntimeError("the GPU session ended without running the take")
|
| 601 |
|
studio/assets/{chrome-CvZYAiOI.js → chrome-DSTbbLEf.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{c as e,d as t,f as n,l as r,p as i,u as a}from"./web-engine-
|
|
|
|
| 1 |
+
import{c as e,d as t,f as n,l as r,p as i,u as a}from"./web-engine-Dm7WfUve.js";var o=`http://www.w3.org/2000/svg`;function s(e,t,n,r,i,a=!1){let s=document.createElementNS(o,`svg`);s.setAttribute(`class`,e),s.setAttribute(`viewBox`,t),r!==null&&s.setAttribute(`width`,String(r)),s.setAttribute(`height`,String(i)),s.setAttribute(`aria-hidden`,`true`);for(let e of n){let t=document.createElementNS(o,`path`);t.setAttribute(`d`,e),a?(t.setAttribute(`fill`,`none`),t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-width`,`1.8`),t.setAttribute(`stroke-linecap`,`round`),t.setAttribute(`stroke-linejoin`,`round`)):t.setAttribute(`fill`,`currentColor`),s.append(t)}return s}function c(t,n,i=t.dataset.icon,a=16){t.replaceChildren(...i?[s(`icon`,`0 0 24 24`,[r[i]],a,a,!e[i])]:[],n)}function l(e){document.querySelector(`.brand`).prepend(s(`z-mark`,t,a,22,3608/224),s(`z-word`,i,n,null,11));for(let e of document.querySelectorAll(`[data-icon]`))c(e,e.textContent.trim());let r=document.getElementById(`theme`),o=()=>{let e=document.documentElement.dataset.theme===`light`;c(r,``,e?`moon`:`sun`),r.title=e?`Dark theme`:`Light theme`,r.setAttribute(`aria-label`,e?`Switch to the dark theme`:`Switch to the light theme`)};r.addEventListener(`click`,()=>{let t=document.documentElement.dataset.theme!==`light`;t?document.documentElement.dataset.theme=`light`:delete document.documentElement.dataset.theme,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,t?`#f5f3ee`:`#0a0a0a`);try{localStorage.setItem(`zvs.theme`,JSON.stringify(t?`light`:`dark`))}catch{}o(),e?.()}),o()}export{c as n,l as t};
|
studio/assets/{index-CqBOQLX2.js → index-Cn8RrXS_.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{o as e}from"./web-engine-
|
|
|
|
| 1 |
+
import{o as e}from"./web-engine-Dm7WfUve.js";import{t}from"./chrome-DSTbbLEf.js";if(t(),location.search)for(let e of document.querySelectorAll(`a[data-keep-query]`))e.search=location.search;async function n(){let t=document.getElementById(`server-line`),n=document.getElementById(`choice-lite`);t.textContent=`Checking for a server…`;let r=(new URLSearchParams(location.search).get(`server`)||``).replace(/\/+$/,``),i=r||location.origin,a=new AbortController,o=setTimeout(()=>a.abort(),3e3);try{let e=await fetch(`${r}/v2/capabilities`,{signal:a.signal,headers:{accept:`application/json`}});if(e.ok&&/json/.test(e.headers.get(`content-type`)??``)){t.textContent=await fetch(`${r}/v2/controls`,{signal:a.signal,headers:{accept:`application/json`}}).then(e=>e.ok,()=>!1)?`Server: ${i}`:`Server: ${i} · controls not applied`;return}}catch{}finally{clearTimeout(o)}await e()?t.textContent=`No server · Voice Studio and Voice Cloning run in this browser (≈1.9 GB download once)`:(t.textContent=`No server · Voice Studio opens with demo audio · Voice Cloning unavailable`,n.setAttribute(`aria-disabled`,`true`),n.setAttribute(`title`,`Needs a ZONOS server, or a browser with WebGPU and the in-browser engine`))}n();
|
studio/assets/{lite-3Vu_kVwP.js → lite-Dm3Lt5gI.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./web-engine-BJErJyzx.js";import{C as o,S as s,_ as ee,c as te,g as ne,h as re,l as c,n as ie,o as ae,p as oe,r as se,t as ce,w as l,x as u}from"./latin-500-Bp0u_hc5.js";import{n as d,t as le}from"./chrome-CvZYAiOI.js";var f=44100,ue=new URLSearchParams(location.search),p=ue.get(`api`)||`auto`,m=(ue.get(`server`)||``).replace(/\/+$/,``);p===`web`&&n();var de=`zonos3.lite.session`,fe=(()=>{try{let e=sessionStorage.getItem(de);if(e)return e;let t=re();return sessionStorage.setItem(de,t),t}catch{return re()}})(),{client:h,headers:pe,ok:g}=oe({baseUrl:m,session:()=>fe,fetch:t}),me=()=>g(h.GET(`/v2/capabilities`));async function he(e){return await i(e),{kind:`web`,caps:await me()}}async function ge({download:e,confirmWeb:t}){if(p===`web`)return he(e);try{return{kind:`live`,caps:await me()}}catch(n){if(p===`live`||n instanceof c&&n.status===403||!await r()||t&&!await t())throw n;return he(e)}}var _e=r,ve=async()=>(await g(h.GET(`/v2/speakers`))).speakers,_=e=>g(h.POST(`/v2/speakers`,{body:e}));async function ye(e){let t=await g(h.GET(`/v2/speakers/{speaker_id}/embedding`,{params:{path:{speaker_id:e}}}));return Float32Array.from(t.embedding)}async function be(e){let n=await t(`${m}/v2/speakers/${encodeURIComponent(e)}/preview`,{headers:pe()});if(!n.ok)throw await ne(n);return n.blob()}async function xe(e,n,r){let i=await t(`${m}/v2/generate`,{method:`POST`,headers:pe({"Content-Type":`application/json`}),body:JSON.stringify(e),signal:r});if(!i.ok)throw await ne(i);if(!i.body)throw new c(i.status,`The response has no body`);let a=i.headers.get(`X-Seed`);return await ee(i.body,n),{seed:a}}var Se=class{sampleRate;ctx=null;out=null;next=0;t0=NaN;pending=[];pendingLength=0;sources=new Set;constructor(e){this.sampleRate=e}async begin(){this.stop(),this.ctx??=new AudioContext,this.ctx.state!==`running`&&await this.ctx.resume(),this.out=this.ctx.createGain(),this.out.connect(this.ctx.destination),this.next=0,this.t0=NaN}push(e){this.pending.push(e),this.pendingLength+=e.length,this.pendingLength>=this.sampleRate/10&&this.flush()}flush(){let{ctx:e,out:t}=this;if(!e||!t||!this.pendingLength)return;let n=e.createBuffer(1,this.pendingLength,this.sampleRate),r=n.getChannelData(0),i=0;for(let e of this.pending)r.set(e,i),i+=e.length;this.pending=[],this.pendingLength=0;let a=e.createBufferSource();a.buffer=n,a.connect(t);let o=Math.max(this.next,e.currentTime+.05);a.start(o),Number.isNaN(this.t0)?this.t0=o:this.t0+=o-this.next,this.next=o+n.duration,this.sources.add(a),a.onended=()=>this.sources.delete(a)}async play(e,t){await this.begin();let n=Math.min(e.length-1,Math.max(0,Math.round(t*this.sampleRate)));this.push(e.subarray(n)),this.flush(),this.t0-=n/this.sampleRate}position(){return!this.ctx||!this.sources.size||Number.isNaN(this.t0)?null:Math.max(0,this.ctx.currentTime-this.t0)}stop(){for(let e of this.sources)e.stop();this.sources.clear(),this.out?.disconnect(),this.out=null,this.pending=[],this.pendingLength=0}};function v(e){switch(e.source){case`default`:return e.library;case`clip`:return e.clip?.speaker??null;case`embedding`:return e.fileVoice}}function Ce(e){return e.generating?{ok:!1,why:``}:e.text.trim()?v(e)?{ok:!0,cloneFirst:!1}:e.source===`clip`?e.clip?{ok:!0,cloneFirst:!0}:{ok:!1,why:`Record or upload a clip first`}:e.source===`embedding`?{ok:!1,why:`Open a voice file first`}:{ok:!1,why:`Pick a voice first`}:{ok:!1,why:`Type something to say`}}function we(e,t){if(!e)return null;let n=e/t;return n<2?`Too short: record at least 2 s`:n>30?`Clip is ${Math.round(n)} s; use up to 30 s`:null}var y=e=>document.getElementById(e),b={backend:y(`backend`),backendNote:y(`backend-note`),studioLink:y(`studio-link`),notice:y(`notice`),download:y(`download`),consent:y(`consent`),consentYes:y(`consent-yes`),consentRetry:y(`consent-retry`),sections:document.querySelectorAll(`main section:not(#consent)`),sources:document.querySelectorAll(`input[name="source"]`),panels:{default:y(`panel-default`),clip:y(`panel-clip`),embedding:y(`panel-embedding`)},voiceSelect:y(`voice-select`),clipPick:y(`clip-pick`),clipPlay:y(`clip-play`),clipFile:y(`clip-file`),record:y(`record`),recordLevel:y(`record-level`),clipState:y(`clip-state`),clipLabel:y(`clip-label`),clipUpload:y(`clip-upload`),embeddingPick:y(`embedding-pick`),embeddingFile:y(`embedding-file`),embeddingState:y(`embedding-state`),embeddingLabel:y(`embedding-label`),embeddingUpload:y(`embedding-upload`),voiceError:y(`voice-error`),voice:y(`voice`),voiceLabel:y(`voice-label`),voiceMeta:y(`voice-meta`),preview:y(`preview`),downloadEmbedding:y(`download-embedding`),form:y(`generate-form`),text:y(`text`),language:y(`language`),seed:y(`seed`),generate:y(`generate`),stop:y(`stop`),status:y(`generate-status`),why:y(`generate-why`),seedUse:y(`seed-use`),error:y(`generate-error`),result:y(`result`),wave:y(`wave`),play:y(`play`),resultDownload:y(`result-download`),resultMeta:y(`result-meta`),takes:y(`takes`)};le(()=>{N=-1,I()});var x=[],S=null,C=`default`,w=null,T=null,E=null,D=new Se(f),O=new Audio,k=``,A=()=>({source:C,library:S,clip:w,fileVoice:T,text:b.text.value,generating:!!E}),j=new Float32Array(f*8),M=0,N=-1,P=0,Te=b.wave.querySelector(`canvas`),F=b.wave.querySelector(`.wave-head`);function Ee(e){if(M+e.length>j.length){let t=new Float32Array(Math.max(j.length*2,M+e.length));t.set(j.subarray(0,M)),j=t}j.set(e,M),M+=e.length}function De(){P=0,N!==M&&(ce(Te,j.subarray(0,M),b.wave.clientWidth,72,getComputedStyle(b.wave).color),N=M);let e=D.position(),t=e!==null&&e*44100<M;if(F.hidden=!t,t){let t=Math.min(100,e*f/M*100);F.style.left=`${t}%`,b.wave.setAttribute(`aria-valuenow`,String(Math.round(t))),b.wave.setAttribute(`aria-valuetext`,`${e.toFixed(1)} of ${(M/f).toFixed(1)} s`)}b.play.dataset.icon!==(t?`stop`:`play`)&&(b.play.dataset.icon=t?`stop`:`play`,d(b.play,``),b.play.title=t?`Stop`:`Play`,b.play.setAttribute(`aria-label`,b.play.title)),(t||E)&&(P=requestAnimationFrame(De))}function I(){P||=requestAnimationFrame(De)}new ResizeObserver(()=>{N=-1,I()}).observe(b.wave);var L=e=>e instanceof Error?e.message:String(e);function R(e,t){e.textContent=t??``,e.hidden=!t}var z=e=>`${(e/f).toFixed(1)} s`;function B(e){if(b.download.hidden=!e,!e)return;let t=Math.round(e.fraction*100);b.download.setAttribute(`aria-valuenow`,String(t)),b.download.setAttribute(`aria-valuetext`,`${e.label}: ${t}%, ${e.detail}`),b.download.setAttribute(`aria-label`,e.label),b.download.querySelector(`.dl-label`).textContent=e.label,b.download.querySelector(`.dl-pct`).textContent=`${t}%`,b.download.querySelector(`.dl-fill`).style.width=`${e.fraction*100}%`,b.download.querySelector(`.dl-detail`).textContent=e.detail}function Oe(e){R(b.notice,e),b.notice.classList.add(`bad`);for(let e of document.querySelectorAll(`main section:not(#consent) input, main section:not(#consent) button, main section:not(#consent) select, main section:not(#consent) textarea`))e.disabled=!0}function ke(){b.voiceSelect.replaceChildren();let e=[...ie(x.filter(e=>e.scope==="default")).map(e=>[e.label??`Library`,e.voices]),[`Your voices (this tab)`,x.filter(e=>e.scope===`session`)]];for(let[t,n]of e){if(!n.length)continue;let e=document.createElement(`optgroup`);e.label=t;for(let t of n)e.append(new Option(t.label,t.id,!1,t.id===S?.id));b.voiceSelect.append(e)}x.length||b.voiceSelect.append(new Option(`No voice can be used from an embedding`,``,!0,!0)),b.voiceSelect.disabled=!x.length}async function V(e){x=(await ve()).filter(e=>e.speaker_modes.includes(`embedding`)),e&&!x.some(t=>t.id===e.id)&&x.push(e);let t=ie(x.filter(e=>e.scope==="default"))[0]?.voices[0];S=(e?.scope==="default"?e:null)??x.find(e=>e.id===S?.id)??t??x[0]??null,ke(),H()}function H(){let e=v(A());if(O.pause(),b.voice.hidden=!e,e){C==="default"&&(b.voiceSelect.value=e.id),b.voiceLabel.textContent=e.label;let t=e.scope==="default"?`library voice`:`this tab`,n=e.source_type===`audio`?`from a clip`:`from a voice file`;b.voiceMeta.textContent=`(${t}, ${n})`,b.voiceMeta.title=e.embedding_dim?`${e.embedding_dim}-dimensional voice embedding`:``,b.preview.hidden=!e.has_preview,d(b.preview,`Play preview`,`play`)}Y()}function Ae(e){C=e;for(let[t,n]of Object.entries(b.panels))n.hidden=t!==e;R(b.voiceError,null),H()}async function U(e,t,n){let r=e.textContent;e.disabled=!0,e.classList.add(`is-busy`),d(e,t),R(b.voiceError,null);try{await n()}catch(e){R(b.voiceError,L(e))}finally{d(e,r),e.classList.remove(`is-busy`),e.disabled=!1,B(null)}}var W=e=>e.replace(/\.[^.]+$/,``),G=``,K=new Audio;function q(e,t){w=e;let n=e?we(e.samples,f):null,r=!!e&&e.samples>0&&e.samples<220500&&!n;b.clipState.textContent=n??(r?`${t} · under 5 s: a longer clip clones better`:t),b.clipState.classList.toggle(`is-warn`,r||!!n),n&&(w=null),b.clipUpload.disabled=!w||!!w.speaker,w&&!b.clipLabel.value.trim()&&(b.clipLabel.placeholder=W(w.name)),K.pause(),G&&URL.revokeObjectURL(G),G=e?URL.createObjectURL(e.blob):``,b.clipPlay.hidden=!e,d(b.clipPlay,`Play`,`play`),H()}b.clipPlay.addEventListener(`click`,()=>{if(!K.paused)return K.pause();K.src=G,K.play()}),K.addEventListener(`play`,()=>d(b.clipPlay,`Stop`,`stop`)),K.addEventListener(`pause`,()=>d(b.clipPlay,`Play`,`play`)),K.addEventListener(`ended`,()=>d(b.clipPlay,`Play`,`play`));async function je(e,t){try{let n=await new OfflineAudioContext(1,1,f).decodeAudioData(await e.arrayBuffer()),r=new Float32Array(n.length);for(let e=0;e<n.numberOfChannels;e++){let t=n.getChannelData(e);for(let e=0;e<r.length;e++)r[e]+=t[e]/n.numberOfChannels}return{blob:new Blob([te(r,n.sampleRate)],{type:`audio/wav`}),name:`${W(t)}.wav`,samples:r.length}}catch{return{blob:e,name:t,samples:0}}}async function Me(){if(!w)throw Error(`Record or upload a clip first`);let e=await _({label:b.clipLabel.value.trim()||W(w.name),speaker_audio_base64:u(await w.blob.arrayBuffer()),speaker_audio_name:w.name});return w={...w,speaker:e},await V(e),b.clipUpload.disabled=!0,b.clipState.textContent=`Cloned “${e.label}”`,b.clipState.classList.remove(`is-warn`),e}var J=null;async function Ne(){if(J)return J.stop();R(b.voiceError,null);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e instanceof DOMException&&(e.name===`NotAllowedError`||e.name===`SecurityError`);return R(b.voiceError,t?`Allow the microphone in the browser’s site settings`:`Microphone unavailable: ${L(e)}`)}let t=b.recordLevel.firstElementChild,n=se(e,e=>t.style.width=`${Math.round(e*100)}%`);b.recordLevel.hidden=!1;let r=new MediaRecorder(e),i=[],a=performance.now(),o=()=>{let e=Math.floor((performance.now()-a)/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} / 0:30`},s=setInterval(()=>b.clipState.textContent=`Recording… ${o()}`,250),ee=setTimeout(()=>J?.stop(),3e4);r.ondataavailable=e=>i.push(e.data),r.onstop=async()=>{clearInterval(s),clearTimeout(ee),n.stop(),b.recordLevel.hidden=!0,e.getTracks().forEach(e=>e.stop()),J=null,b.record.classList.remove(`is-recording`),d(b.record,`Record`),b.record.setAttribute(`aria-pressed`,`false`);let t=await je(new Blob(i,{type:r.mimeType}),`recording`);b.clipFile.value=``,q({...t,speaker:null},`Recording ready${t.samples?` (${z(t.samples)})`:``}`)},J={stop:()=>r.state===`recording`&&r.stop()},r.start(),b.record.classList.add(`is-recording`),b.record.replaceChildren(Object.assign(document.createElement(`span`),{className:`rec-dot`}),`Stop recording`),b.record.setAttribute(`aria-pressed`,`true`),b.clipState.textContent=`Recording… 0:00 / 0:30`}function Y(){let e=Ce(A());b.generate.disabled=!e.ok,R(b.why,e.ok?null:e.why||null)}b.text.addEventListener(`input`,Y),b.text.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Le())});var Pe=5,X=[];function Fe(){let e=X.slice(1);b.takes.hidden=!e.length,b.takes.replaceChildren(...e.map((e,t)=>{let n=document.createElement(`li`);n.className=`take-row`;let r=Object.assign(document.createElement(`button`),{type:`button`,className:`icon-btn sm`,title:`Play this take`});r.dataset.icon=`play`,d(r,``,`play`,14),r.setAttribute(`aria-label`,`Play take ${X.length-1-t}`),r.addEventListener(`click`,()=>{O.pause(),D.play(e.pcm,0).then(I)});let i=Object.assign(document.createElement(`span`),{className:`meta`,textContent:`${e.label} · ${z(e.pcm.length)} · ${e.text.length>48?`${e.text.slice(0,48)}…`:e.text}`});i.title=e.seed?`seed ${e.seed}`:``;let a=Object.assign(document.createElement(`a`),{className:`btn sm ghost`,href:e.url,download:`${l(e.label)}${e.seed?`-seed${e.seed}`:``}.wav`,textContent:`Download`});return n.append(r,i,a),n}))}function Ie(e,t,n,r){let i=URL.createObjectURL(new Blob([te(e,f)],{type:`audio/wav`}));X.unshift({pcm:e,seed:t,text:n,url:i,label:r});for(let e of X.splice(Pe))URL.revokeObjectURL(e.url);return Fe(),i}async function Le(){if(!Ce(A()).ok)return Y();let e=b.text.value.trim(),t=new AbortController;E=t,Y(),b.stop.hidden=!1,R(b.error,null),O.pause();let n=v(A());try{n||=(b.status.textContent=`Cloning the clip…`,await Me())}catch(e){E=null,b.stop.hidden=!0,b.status.textContent=``,R(b.error,L(e)),Y();return}let r={text:e,language:b.language.value,speaker_mode:`embedding`,speaker_embedding_id:n.id,stream:!0,format:`pcm`};b.seed.value!==``&&(r.seed=Number(b.seed.value)),b.status.textContent=`Generating…`,M=0,N=-1,b.result.hidden=!1,b.wave.classList.add(`is-busy`),b.resultDownload.hidden=!0,b.resultMeta.textContent=``,I();let i=performance.now(),a=0;try{await D.begin();let{seed:o}=await xe(r,e=>{a||=performance.now(),Ee(e),D.push(e),b.status.textContent=`Playing while generating… ${z(M)}`},t.signal);if(D.flush(),!M)throw new c(200,`The server returned no audio.`);let s=Ie(j.slice(0,M),o,e,n.label);b.resultDownload.href=s,b.resultDownload.download=`${l(n.label)}${o?`-seed${o}`:``}.wav`,b.resultDownload.hidden=!1,b.resultMeta.textContent=z(M),b.resultMeta.title=`seed ${o??`unknown`} · first audio after ${((a-i)/1e3).toFixed(2)} s`,b.seedUse.hidden=o==null,b.result.dataset.samples=String(M),b.result.dataset.seed=o??``,b.status.textContent=`Done: ${z(M)} of audio.`}catch(e){D.stop(),t.signal.aborted?b.status.textContent=`Stopped.`:(b.status.textContent=``,R(b.error,L(e))),b.result.hidden=!M}finally{E=null,b.wave.classList.remove(`is-busy`),b.stop.hidden=!0,Y(),B(null),I()}}async function Z(e){M&&!E&&(O.pause(),await D.play(j.subarray(0,M),e*M/f),I())}function Re(){if(D.position()===null)return void Z(0);D.stop(),I()}b.play.addEventListener(`click`,Re),b.wave.addEventListener(`pointerdown`,e=>{let t=b.wave.getBoundingClientRect();Z(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)))}),b.wave.addEventListener(`keydown`,e=>{if(M){if(e.key===` `)e.preventDefault(),Re();else if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=M/f;Z(Math.max(0,Math.min(t,(D.position()??0)+(e.key===`ArrowLeft`?-1:1)))/t)}}});for(let e of b.sources)e.addEventListener(`change`,()=>e.checked&&Ae(e.value));b.voiceSelect.addEventListener(`change`,()=>{S=x.find(e=>e.id===b.voiceSelect.value)??null,H()}),b.clipPick.addEventListener(`click`,()=>b.clipFile.click()),b.clipFile.addEventListener(`change`,async()=>{let e=b.clipFile.files?.[0];if(!e)return q(null,``);b.clipState.textContent=`Reading…`;let t=await je(e,e.name);q({...t,speaker:null},`${e.name}${t.samples?` (${z(t.samples)})`:``}`)}),b.record.addEventListener(`click`,()=>void Ne()),b.clipUpload.addEventListener(`click`,()=>U(b.clipUpload,`Cloning…`,async()=>{await Me(),b.clipLabel.value=``})),b.embeddingPick.addEventListener(`click`,()=>b.embeddingFile.click());var ze=2e6;b.embeddingFile.addEventListener(`change`,()=>{let e=b.embeddingFile.files?.[0];R(b.voiceError,null);let t=e&&(!/\.np[yz]$/i.test(e.name)||e.size>ze)?`Couldn’t read this voice file: it must be a .npy or .npz under 2 MB`:null;t&&(b.embeddingFile.value=``,R(b.voiceError,t));let n=e&&!t;b.embeddingUpload.disabled=!n,b.embeddingState.textContent=n?e.name:``,n&&(b.embeddingLabel.placeholder=W(e.name))}),b.embeddingUpload.addEventListener(`click`,()=>U(b.embeddingUpload,`Opening…`,async()=>{let e=b.embeddingFile.files?.[0];if(!e)return;let t;try{t=await _({label:b.embeddingLabel.value.trim()||W(e.name),speaker_embedding_base64:u(await e.arrayBuffer()),speaker_embedding_name:e.name})}catch(e){throw e instanceof c&&e.status===400?Error(`Couldn’t read this voice file: ${e.detail}`):e}T=t,await V(t),b.embeddingFile.value=``,b.embeddingLabel.value=``,b.embeddingState.textContent=`Opened “${t.label}”`,b.embeddingUpload.disabled=!0})),b.preview.addEventListener(`click`,()=>{let e=v(A());if(!e)return;if(!O.paused)return O.pause();let t=e.id;U(b.preview,`Loading…`,async()=>{O.dataset.id!==t&&(k&&URL.revokeObjectURL(k),k=URL.createObjectURL(await be(t)),O.src=k,O.dataset.id=t),await O.play()}).then(()=>O.paused||Q(!0))});function Q(e){d(b.preview,e?`Stop preview`:`Play preview`,e?`stop`:`play`),b.preview.classList.toggle(`is-playing`,e)}O.addEventListener(`play`,()=>Q(!0)),O.addEventListener(`pause`,()=>Q(!1)),b.downloadEmbedding.addEventListener(`click`,()=>{let e=v(A());e&&U(b.downloadEmbedding,`Downloading…`,async()=>{s(o(await ye(e.id)),`${l(e.label)}.npy`,`application/octet-stream`)})}),b.form.addEventListener(`submit`,e=>{e.preventDefault(),Le()}),b.stop.addEventListener(`click`,()=>{E?.abort(),D.stop()}),b.seedUse.addEventListener(`click`,()=>{b.seed.value=b.result.dataset.seed??``,b.seed.closest(`details`)?.setAttribute(`open`,``),b.seed.focus()});function $(e){R(b.notice,e?`Connecting…`:null),e||B(null);for(let t of b.sections)t.inert=e}function Be(){R(b.notice,null),b.consent.hidden=!1,b.consentYes.focus();let{promise:e,resolve:t}=Promise.withResolvers();return b.consentYes.addEventListener(`click`,()=>t(!0),{once:!0}),b.consentRetry.addEventListener(`click`,()=>location.reload(),{once:!0}),e.finally(()=>{b.consent.hidden=!0,R(b.notice,`Starting the in-browser engine…`)})}async function Ve(t){$(!1);let r=e();Oe(r?`The in-browser engine couldn’t start: ${L(t)}`:`Can’t reach the server at ${m||location.origin}: ${L(t)}`);let i=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm`,textContent:`Try again`});if(i.addEventListener(`click`,()=>location.reload()),b.notice.append(` `,i),!r&&await _e()){let e=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm primary`,textContent:`Run in this browser`});e.addEventListener(`click`,()=>{n();let e=new URL(location.href);e.searchParams.set(`api`,`web`),location.href=e.toString()}),b.notice.append(` `,e)}}async function He(){m&&(b.studioLink.search=`?server=${encodeURIComponent(m)}`),Y(),$(!0);let e;try{e=await ge({download:e=>{R(b.notice,null),B(e)},confirmWeb:Be})}catch(e){await Ve(e);return}$(!1);let{kind:t,caps:n}=e;b.backend.hidden=!1,b.backend.querySelector(`.pill-text`).textContent=t===`web`?`In this browser`:`Server`;let r=t===`web`?`The voice engine runs in this tab on your graphics card; its models are cached in the browser.`:`Connected to ${m||location.origin}: that server renders every voice.`;if(b.backend.title=r,b.backend.classList.add(`pill-${t}`),b.backend.addEventListener(`click`,()=>{let e=b.backendNote.hidden;R(b.backendNote,e?r:null),b.backend.setAttribute(`aria-expanded`,String(e))}),t===`web`&&(b.studioLink.search=m?`?api=web&server=${encodeURIComponent(m)}`:`?api=web`,a(e=>B(e.fraction>=1?null:e))),!n.speaker_modes.includes(`embedding`))return Oe(`This server can’t clone from a voice file: its model has no voice-embedding input.`);let i=n.text_norm_languages.length?n.text_norm_languages:[`en_us`];for(let e of i)b.language.append(new Option(ae(e),e,!1,e===`en_us`));n.speaker_audio_upload||(b.clipUpload.disabled=!0,b.clipState.textContent=`This server doesn’t take clip uploads.`,b.clipFile.disabled=b.clipPick.disabled=b.record.disabled=!0),typeof MediaRecorder<`u`&&navigator.mediaDevices?.getUserMedia||(b.record.hidden=!0);try{await V()}catch(e){R(b.voiceError,`Couldn’t list voices: ${L(e)}`)}}He();
|
|
|
|
| 1 |
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./web-engine-Dm7WfUve.js";import{C as o,S as s,_ as ee,c as te,g as ne,h as re,l as c,n as ie,o as ae,p as oe,r as se,t as ce,w as l,x as u}from"./latin-500-Bp0u_hc5.js";import{n as d,t as le}from"./chrome-DSTbbLEf.js";var f=44100,ue=new URLSearchParams(location.search),p=ue.get(`api`)||`auto`,m=(ue.get(`server`)||``).replace(/\/+$/,``);p===`web`&&n();var de=`zonos3.lite.session`,fe=(()=>{try{let e=sessionStorage.getItem(de);if(e)return e;let t=re();return sessionStorage.setItem(de,t),t}catch{return re()}})(),{client:h,headers:pe,ok:g}=oe({baseUrl:m,session:()=>fe,fetch:t}),me=()=>g(h.GET(`/v2/capabilities`));async function he(e){return await i(e),{kind:`web`,caps:await me()}}async function ge({download:e,confirmWeb:t}){if(p===`web`)return he(e);try{return{kind:`live`,caps:await me()}}catch(n){if(p===`live`||n instanceof c&&n.status===403||!await r()||t&&!await t())throw n;return he(e)}}var _e=r,ve=async()=>(await g(h.GET(`/v2/speakers`))).speakers,_=e=>g(h.POST(`/v2/speakers`,{body:e}));async function ye(e){let t=await g(h.GET(`/v2/speakers/{speaker_id}/embedding`,{params:{path:{speaker_id:e}}}));return Float32Array.from(t.embedding)}async function be(e){let n=await t(`${m}/v2/speakers/${encodeURIComponent(e)}/preview`,{headers:pe()});if(!n.ok)throw await ne(n);return n.blob()}async function xe(e,n,r){let i=await t(`${m}/v2/generate`,{method:`POST`,headers:pe({"Content-Type":`application/json`}),body:JSON.stringify(e),signal:r});if(!i.ok)throw await ne(i);if(!i.body)throw new c(i.status,`The response has no body`);let a=i.headers.get(`X-Seed`);return await ee(i.body,n),{seed:a}}var Se=class{sampleRate;ctx=null;out=null;next=0;t0=NaN;pending=[];pendingLength=0;sources=new Set;constructor(e){this.sampleRate=e}async begin(){this.stop(),this.ctx??=new AudioContext,this.ctx.state!==`running`&&await this.ctx.resume(),this.out=this.ctx.createGain(),this.out.connect(this.ctx.destination),this.next=0,this.t0=NaN}push(e){this.pending.push(e),this.pendingLength+=e.length,this.pendingLength>=this.sampleRate/10&&this.flush()}flush(){let{ctx:e,out:t}=this;if(!e||!t||!this.pendingLength)return;let n=e.createBuffer(1,this.pendingLength,this.sampleRate),r=n.getChannelData(0),i=0;for(let e of this.pending)r.set(e,i),i+=e.length;this.pending=[],this.pendingLength=0;let a=e.createBufferSource();a.buffer=n,a.connect(t);let o=Math.max(this.next,e.currentTime+.05);a.start(o),Number.isNaN(this.t0)?this.t0=o:this.t0+=o-this.next,this.next=o+n.duration,this.sources.add(a),a.onended=()=>this.sources.delete(a)}async play(e,t){await this.begin();let n=Math.min(e.length-1,Math.max(0,Math.round(t*this.sampleRate)));this.push(e.subarray(n)),this.flush(),this.t0-=n/this.sampleRate}position(){return!this.ctx||!this.sources.size||Number.isNaN(this.t0)?null:Math.max(0,this.ctx.currentTime-this.t0)}stop(){for(let e of this.sources)e.stop();this.sources.clear(),this.out?.disconnect(),this.out=null,this.pending=[],this.pendingLength=0}};function v(e){switch(e.source){case`default`:return e.library;case`clip`:return e.clip?.speaker??null;case`embedding`:return e.fileVoice}}function Ce(e){return e.generating?{ok:!1,why:``}:e.text.trim()?v(e)?{ok:!0,cloneFirst:!1}:e.source===`clip`?e.clip?{ok:!0,cloneFirst:!0}:{ok:!1,why:`Record or upload a clip first`}:e.source===`embedding`?{ok:!1,why:`Open a voice file first`}:{ok:!1,why:`Pick a voice first`}:{ok:!1,why:`Type something to say`}}function we(e,t){if(!e)return null;let n=e/t;return n<2?`Too short: record at least 2 s`:n>30?`Clip is ${Math.round(n)} s; use up to 30 s`:null}var y=e=>document.getElementById(e),b={backend:y(`backend`),backendNote:y(`backend-note`),studioLink:y(`studio-link`),notice:y(`notice`),download:y(`download`),consent:y(`consent`),consentYes:y(`consent-yes`),consentRetry:y(`consent-retry`),sections:document.querySelectorAll(`main section:not(#consent)`),sources:document.querySelectorAll(`input[name="source"]`),panels:{default:y(`panel-default`),clip:y(`panel-clip`),embedding:y(`panel-embedding`)},voiceSelect:y(`voice-select`),clipPick:y(`clip-pick`),clipPlay:y(`clip-play`),clipFile:y(`clip-file`),record:y(`record`),recordLevel:y(`record-level`),clipState:y(`clip-state`),clipLabel:y(`clip-label`),clipUpload:y(`clip-upload`),embeddingPick:y(`embedding-pick`),embeddingFile:y(`embedding-file`),embeddingState:y(`embedding-state`),embeddingLabel:y(`embedding-label`),embeddingUpload:y(`embedding-upload`),voiceError:y(`voice-error`),voice:y(`voice`),voiceLabel:y(`voice-label`),voiceMeta:y(`voice-meta`),preview:y(`preview`),downloadEmbedding:y(`download-embedding`),form:y(`generate-form`),text:y(`text`),language:y(`language`),seed:y(`seed`),generate:y(`generate`),stop:y(`stop`),status:y(`generate-status`),why:y(`generate-why`),seedUse:y(`seed-use`),error:y(`generate-error`),result:y(`result`),wave:y(`wave`),play:y(`play`),resultDownload:y(`result-download`),resultMeta:y(`result-meta`),takes:y(`takes`)};le(()=>{N=-1,I()});var x=[],S=null,C=`default`,w=null,T=null,E=null,D=new Se(f),O=new Audio,k=``,A=()=>({source:C,library:S,clip:w,fileVoice:T,text:b.text.value,generating:!!E}),j=new Float32Array(f*8),M=0,N=-1,P=0,Te=b.wave.querySelector(`canvas`),F=b.wave.querySelector(`.wave-head`);function Ee(e){if(M+e.length>j.length){let t=new Float32Array(Math.max(j.length*2,M+e.length));t.set(j.subarray(0,M)),j=t}j.set(e,M),M+=e.length}function De(){P=0,N!==M&&(ce(Te,j.subarray(0,M),b.wave.clientWidth,72,getComputedStyle(b.wave).color),N=M);let e=D.position(),t=e!==null&&e*44100<M;if(F.hidden=!t,t){let t=Math.min(100,e*f/M*100);F.style.left=`${t}%`,b.wave.setAttribute(`aria-valuenow`,String(Math.round(t))),b.wave.setAttribute(`aria-valuetext`,`${e.toFixed(1)} of ${(M/f).toFixed(1)} s`)}b.play.dataset.icon!==(t?`stop`:`play`)&&(b.play.dataset.icon=t?`stop`:`play`,d(b.play,``),b.play.title=t?`Stop`:`Play`,b.play.setAttribute(`aria-label`,b.play.title)),(t||E)&&(P=requestAnimationFrame(De))}function I(){P||=requestAnimationFrame(De)}new ResizeObserver(()=>{N=-1,I()}).observe(b.wave);var L=e=>e instanceof Error?e.message:String(e);function R(e,t){e.textContent=t??``,e.hidden=!t}var z=e=>`${(e/f).toFixed(1)} s`;function B(e){if(b.download.hidden=!e,!e)return;let t=Math.round(e.fraction*100);b.download.setAttribute(`aria-valuenow`,String(t)),b.download.setAttribute(`aria-valuetext`,`${e.label}: ${t}%, ${e.detail}`),b.download.setAttribute(`aria-label`,e.label),b.download.querySelector(`.dl-label`).textContent=e.label,b.download.querySelector(`.dl-pct`).textContent=`${t}%`,b.download.querySelector(`.dl-fill`).style.width=`${e.fraction*100}%`,b.download.querySelector(`.dl-detail`).textContent=e.detail}function Oe(e){R(b.notice,e),b.notice.classList.add(`bad`);for(let e of document.querySelectorAll(`main section:not(#consent) input, main section:not(#consent) button, main section:not(#consent) select, main section:not(#consent) textarea`))e.disabled=!0}function ke(){b.voiceSelect.replaceChildren();let e=[...ie(x.filter(e=>e.scope==="default")).map(e=>[e.label??`Library`,e.voices]),[`Your voices (this tab)`,x.filter(e=>e.scope===`session`)]];for(let[t,n]of e){if(!n.length)continue;let e=document.createElement(`optgroup`);e.label=t;for(let t of n)e.append(new Option(t.label,t.id,!1,t.id===S?.id));b.voiceSelect.append(e)}x.length||b.voiceSelect.append(new Option(`No voice can be used from an embedding`,``,!0,!0)),b.voiceSelect.disabled=!x.length}async function V(e){x=(await ve()).filter(e=>e.speaker_modes.includes(`embedding`)),e&&!x.some(t=>t.id===e.id)&&x.push(e);let t=ie(x.filter(e=>e.scope==="default"))[0]?.voices[0];S=(e?.scope==="default"?e:null)??x.find(e=>e.id===S?.id)??t??x[0]??null,ke(),H()}function H(){let e=v(A());if(O.pause(),b.voice.hidden=!e,e){C==="default"&&(b.voiceSelect.value=e.id),b.voiceLabel.textContent=e.label;let t=e.scope==="default"?`library voice`:`this tab`,n=e.source_type===`audio`?`from a clip`:`from a voice file`;b.voiceMeta.textContent=`(${t}, ${n})`,b.voiceMeta.title=e.embedding_dim?`${e.embedding_dim}-dimensional voice embedding`:``,b.preview.hidden=!e.has_preview,d(b.preview,`Play preview`,`play`)}Y()}function Ae(e){C=e;for(let[t,n]of Object.entries(b.panels))n.hidden=t!==e;R(b.voiceError,null),H()}async function U(e,t,n){let r=e.textContent;e.disabled=!0,e.classList.add(`is-busy`),d(e,t),R(b.voiceError,null);try{await n()}catch(e){R(b.voiceError,L(e))}finally{d(e,r),e.classList.remove(`is-busy`),e.disabled=!1,B(null)}}var W=e=>e.replace(/\.[^.]+$/,``),G=``,K=new Audio;function q(e,t){w=e;let n=e?we(e.samples,f):null,r=!!e&&e.samples>0&&e.samples<220500&&!n;b.clipState.textContent=n??(r?`${t} · under 5 s: a longer clip clones better`:t),b.clipState.classList.toggle(`is-warn`,r||!!n),n&&(w=null),b.clipUpload.disabled=!w||!!w.speaker,w&&!b.clipLabel.value.trim()&&(b.clipLabel.placeholder=W(w.name)),K.pause(),G&&URL.revokeObjectURL(G),G=e?URL.createObjectURL(e.blob):``,b.clipPlay.hidden=!e,d(b.clipPlay,`Play`,`play`),H()}b.clipPlay.addEventListener(`click`,()=>{if(!K.paused)return K.pause();K.src=G,K.play()}),K.addEventListener(`play`,()=>d(b.clipPlay,`Stop`,`stop`)),K.addEventListener(`pause`,()=>d(b.clipPlay,`Play`,`play`)),K.addEventListener(`ended`,()=>d(b.clipPlay,`Play`,`play`));async function je(e,t){try{let n=await new OfflineAudioContext(1,1,f).decodeAudioData(await e.arrayBuffer()),r=new Float32Array(n.length);for(let e=0;e<n.numberOfChannels;e++){let t=n.getChannelData(e);for(let e=0;e<r.length;e++)r[e]+=t[e]/n.numberOfChannels}return{blob:new Blob([te(r,n.sampleRate)],{type:`audio/wav`}),name:`${W(t)}.wav`,samples:r.length}}catch{return{blob:e,name:t,samples:0}}}async function Me(){if(!w)throw Error(`Record or upload a clip first`);let e=await _({label:b.clipLabel.value.trim()||W(w.name),speaker_audio_base64:u(await w.blob.arrayBuffer()),speaker_audio_name:w.name});return w={...w,speaker:e},await V(e),b.clipUpload.disabled=!0,b.clipState.textContent=`Cloned “${e.label}”`,b.clipState.classList.remove(`is-warn`),e}var J=null;async function Ne(){if(J)return J.stop();R(b.voiceError,null);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e instanceof DOMException&&(e.name===`NotAllowedError`||e.name===`SecurityError`);return R(b.voiceError,t?`Allow the microphone in the browser’s site settings`:`Microphone unavailable: ${L(e)}`)}let t=b.recordLevel.firstElementChild,n=se(e,e=>t.style.width=`${Math.round(e*100)}%`);b.recordLevel.hidden=!1;let r=new MediaRecorder(e),i=[],a=performance.now(),o=()=>{let e=Math.floor((performance.now()-a)/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} / 0:30`},s=setInterval(()=>b.clipState.textContent=`Recording… ${o()}`,250),ee=setTimeout(()=>J?.stop(),3e4);r.ondataavailable=e=>i.push(e.data),r.onstop=async()=>{clearInterval(s),clearTimeout(ee),n.stop(),b.recordLevel.hidden=!0,e.getTracks().forEach(e=>e.stop()),J=null,b.record.classList.remove(`is-recording`),d(b.record,`Record`),b.record.setAttribute(`aria-pressed`,`false`);let t=await je(new Blob(i,{type:r.mimeType}),`recording`);b.clipFile.value=``,q({...t,speaker:null},`Recording ready${t.samples?` (${z(t.samples)})`:``}`)},J={stop:()=>r.state===`recording`&&r.stop()},r.start(),b.record.classList.add(`is-recording`),b.record.replaceChildren(Object.assign(document.createElement(`span`),{className:`rec-dot`}),`Stop recording`),b.record.setAttribute(`aria-pressed`,`true`),b.clipState.textContent=`Recording… 0:00 / 0:30`}function Y(){let e=Ce(A());b.generate.disabled=!e.ok,R(b.why,e.ok?null:e.why||null)}b.text.addEventListener(`input`,Y),b.text.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Le())});var Pe=5,X=[];function Fe(){let e=X.slice(1);b.takes.hidden=!e.length,b.takes.replaceChildren(...e.map((e,t)=>{let n=document.createElement(`li`);n.className=`take-row`;let r=Object.assign(document.createElement(`button`),{type:`button`,className:`icon-btn sm`,title:`Play this take`});r.dataset.icon=`play`,d(r,``,`play`,14),r.setAttribute(`aria-label`,`Play take ${X.length-1-t}`),r.addEventListener(`click`,()=>{O.pause(),D.play(e.pcm,0).then(I)});let i=Object.assign(document.createElement(`span`),{className:`meta`,textContent:`${e.label} · ${z(e.pcm.length)} · ${e.text.length>48?`${e.text.slice(0,48)}…`:e.text}`});i.title=e.seed?`seed ${e.seed}`:``;let a=Object.assign(document.createElement(`a`),{className:`btn sm ghost`,href:e.url,download:`${l(e.label)}${e.seed?`-seed${e.seed}`:``}.wav`,textContent:`Download`});return n.append(r,i,a),n}))}function Ie(e,t,n,r){let i=URL.createObjectURL(new Blob([te(e,f)],{type:`audio/wav`}));X.unshift({pcm:e,seed:t,text:n,url:i,label:r});for(let e of X.splice(Pe))URL.revokeObjectURL(e.url);return Fe(),i}async function Le(){if(!Ce(A()).ok)return Y();let e=b.text.value.trim(),t=new AbortController;E=t,Y(),b.stop.hidden=!1,R(b.error,null),O.pause();let n=v(A());try{n||=(b.status.textContent=`Cloning the clip…`,await Me())}catch(e){E=null,b.stop.hidden=!0,b.status.textContent=``,R(b.error,L(e)),Y();return}let r={text:e,language:b.language.value,speaker_mode:`embedding`,speaker_embedding_id:n.id,stream:!0,format:`pcm`};b.seed.value!==``&&(r.seed=Number(b.seed.value)),b.status.textContent=`Generating…`,M=0,N=-1,b.result.hidden=!1,b.wave.classList.add(`is-busy`),b.resultDownload.hidden=!0,b.resultMeta.textContent=``,I();let i=performance.now(),a=0;try{await D.begin();let{seed:o}=await xe(r,e=>{a||=performance.now(),Ee(e),D.push(e),b.status.textContent=`Playing while generating… ${z(M)}`},t.signal);if(D.flush(),!M)throw new c(200,`The server returned no audio.`);let s=Ie(j.slice(0,M),o,e,n.label);b.resultDownload.href=s,b.resultDownload.download=`${l(n.label)}${o?`-seed${o}`:``}.wav`,b.resultDownload.hidden=!1,b.resultMeta.textContent=z(M),b.resultMeta.title=`seed ${o??`unknown`} · first audio after ${((a-i)/1e3).toFixed(2)} s`,b.seedUse.hidden=o==null,b.result.dataset.samples=String(M),b.result.dataset.seed=o??``,b.status.textContent=`Done: ${z(M)} of audio.`}catch(e){D.stop(),t.signal.aborted?b.status.textContent=`Stopped.`:(b.status.textContent=``,R(b.error,L(e))),b.result.hidden=!M}finally{E=null,b.wave.classList.remove(`is-busy`),b.stop.hidden=!0,Y(),B(null),I()}}async function Z(e){M&&!E&&(O.pause(),await D.play(j.subarray(0,M),e*M/f),I())}function Re(){if(D.position()===null)return void Z(0);D.stop(),I()}b.play.addEventListener(`click`,Re),b.wave.addEventListener(`pointerdown`,e=>{let t=b.wave.getBoundingClientRect();Z(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)))}),b.wave.addEventListener(`keydown`,e=>{if(M){if(e.key===` `)e.preventDefault(),Re();else if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=M/f;Z(Math.max(0,Math.min(t,(D.position()??0)+(e.key===`ArrowLeft`?-1:1)))/t)}}});for(let e of b.sources)e.addEventListener(`change`,()=>e.checked&&Ae(e.value));b.voiceSelect.addEventListener(`change`,()=>{S=x.find(e=>e.id===b.voiceSelect.value)??null,H()}),b.clipPick.addEventListener(`click`,()=>b.clipFile.click()),b.clipFile.addEventListener(`change`,async()=>{let e=b.clipFile.files?.[0];if(!e)return q(null,``);b.clipState.textContent=`Reading…`;let t=await je(e,e.name);q({...t,speaker:null},`${e.name}${t.samples?` (${z(t.samples)})`:``}`)}),b.record.addEventListener(`click`,()=>void Ne()),b.clipUpload.addEventListener(`click`,()=>U(b.clipUpload,`Cloning…`,async()=>{await Me(),b.clipLabel.value=``})),b.embeddingPick.addEventListener(`click`,()=>b.embeddingFile.click());var ze=2e6;b.embeddingFile.addEventListener(`change`,()=>{let e=b.embeddingFile.files?.[0];R(b.voiceError,null);let t=e&&(!/\.np[yz]$/i.test(e.name)||e.size>ze)?`Couldn’t read this voice file: it must be a .npy or .npz under 2 MB`:null;t&&(b.embeddingFile.value=``,R(b.voiceError,t));let n=e&&!t;b.embeddingUpload.disabled=!n,b.embeddingState.textContent=n?e.name:``,n&&(b.embeddingLabel.placeholder=W(e.name))}),b.embeddingUpload.addEventListener(`click`,()=>U(b.embeddingUpload,`Opening…`,async()=>{let e=b.embeddingFile.files?.[0];if(!e)return;let t;try{t=await _({label:b.embeddingLabel.value.trim()||W(e.name),speaker_embedding_base64:u(await e.arrayBuffer()),speaker_embedding_name:e.name})}catch(e){throw e instanceof c&&e.status===400?Error(`Couldn’t read this voice file: ${e.detail}`):e}T=t,await V(t),b.embeddingFile.value=``,b.embeddingLabel.value=``,b.embeddingState.textContent=`Opened “${t.label}”`,b.embeddingUpload.disabled=!0})),b.preview.addEventListener(`click`,()=>{let e=v(A());if(!e)return;if(!O.paused)return O.pause();let t=e.id;U(b.preview,`Loading…`,async()=>{O.dataset.id!==t&&(k&&URL.revokeObjectURL(k),k=URL.createObjectURL(await be(t)),O.src=k,O.dataset.id=t),await O.play()}).then(()=>O.paused||Q(!0))});function Q(e){d(b.preview,e?`Stop preview`:`Play preview`,e?`stop`:`play`),b.preview.classList.toggle(`is-playing`,e)}O.addEventListener(`play`,()=>Q(!0)),O.addEventListener(`pause`,()=>Q(!1)),b.downloadEmbedding.addEventListener(`click`,()=>{let e=v(A());e&&U(b.downloadEmbedding,`Downloading…`,async()=>{s(o(await ye(e.id)),`${l(e.label)}.npy`,`application/octet-stream`)})}),b.form.addEventListener(`submit`,e=>{e.preventDefault(),Le()}),b.stop.addEventListener(`click`,()=>{E?.abort(),D.stop()}),b.seedUse.addEventListener(`click`,()=>{b.seed.value=b.result.dataset.seed??``,b.seed.closest(`details`)?.setAttribute(`open`,``),b.seed.focus()});function $(e){R(b.notice,e?`Connecting…`:null),e||B(null);for(let t of b.sections)t.inert=e}function Be(){R(b.notice,null),b.consent.hidden=!1,b.consentYes.focus();let{promise:e,resolve:t}=Promise.withResolvers();return b.consentYes.addEventListener(`click`,()=>t(!0),{once:!0}),b.consentRetry.addEventListener(`click`,()=>location.reload(),{once:!0}),e.finally(()=>{b.consent.hidden=!0,R(b.notice,`Starting the in-browser engine…`)})}async function Ve(t){$(!1);let r=e();Oe(r?`The in-browser engine couldn’t start: ${L(t)}`:`Can’t reach the server at ${m||location.origin}: ${L(t)}`);let i=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm`,textContent:`Try again`});if(i.addEventListener(`click`,()=>location.reload()),b.notice.append(` `,i),!r&&await _e()){let e=Object.assign(document.createElement(`button`),{type:`button`,className:`btn sm primary`,textContent:`Run in this browser`});e.addEventListener(`click`,()=>{n();let e=new URL(location.href);e.searchParams.set(`api`,`web`),location.href=e.toString()}),b.notice.append(` `,e)}}async function He(){m&&(b.studioLink.search=`?server=${encodeURIComponent(m)}`),Y(),$(!0);let e;try{e=await ge({download:e=>{R(b.notice,null),B(e)},confirmWeb:Be})}catch(e){await Ve(e);return}$(!1);let{kind:t,caps:n}=e;b.backend.hidden=!1,b.backend.querySelector(`.pill-text`).textContent=t===`web`?`In this browser`:`Server`;let r=t===`web`?`The voice engine runs in this tab on your graphics card; its models are cached in the browser.`:`Connected to ${m||location.origin}: that server renders every voice.`;if(b.backend.title=r,b.backend.classList.add(`pill-${t}`),b.backend.addEventListener(`click`,()=>{let e=b.backendNote.hidden;R(b.backendNote,e?r:null),b.backend.setAttribute(`aria-expanded`,String(e))}),t===`web`&&(b.studioLink.search=m?`?api=web&server=${encodeURIComponent(m)}`:`?api=web`,a(e=>B(e.fraction>=1?null:e))),!n.speaker_modes.includes(`embedding`))return Oe(`This server can’t clone from a voice file: its model has no voice-embedding input.`);let i=n.text_norm_languages.length?n.text_norm_languages:[`en_us`];for(let e of i)b.language.append(new Option(ae(e),e,!1,e===`en_us`));n.speaker_audio_upload||(b.clipUpload.disabled=!0,b.clipState.textContent=`This server doesn’t take clip uploads.`,b.clipFile.disabled=b.clipPick.disabled=b.record.disabled=!0),typeof MediaRecorder<`u`&&navigator.mediaDevices?.getUserMedia||(b.record.hidden=!0);try{await V()}catch(e){R(b.voiceError,`Couldn’t list voices: ${L(e)}`)}}He();
|
studio/assets/{studio-Bhcl8Nzz.js → studio-ltLzUm7R.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
studio/assets/{web-engine-BJErJyzx.js → web-engine-Dm7WfUve.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=[`M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z`,`M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z`,`M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z`],t=`0 0 224 164`,n=[`M465.55,213.433L465.55,200L208.302,200L208.302,217.413L423.297,217.413L200.017,386.567L200.017,400L457.265,400L457.265,382.587L242.271,382.587L465.55,213.433Z`,`M851.628,200L816.003,200L707.884,287.313L599.766,200L564.141,200L687.586,299.751C689.243,302.736 693.386,310.448 693.386,320.398L693.386,400L721.969,400L721.969,320.398C721.969,310.448 725.697,302.985 727.768,299.751L851.628,200Z`,`M1108.047,200L969.688,200L969.688,400L998.686,400L998.686,308.458C998.686,306.219 1000.343,303.483 1011.527,303.483L1107.633,303.483C1154.857,303.483 1193.382,280.348 1193.382,251.99C1193.382,223.632 1155.271,200.249 1108.047,200ZM1009.87,286.318C1005.728,286.318 1002.414,286.567 998.686,287.065L998.686,217.662L1107.633,217.662C1139.116,217.662 1164.799,233.333 1164.799,252.239C1164.799,271.144 1139.116,286.318 1107.633,286.318L1009.87,286.318Z`,`M1524.365,400L1524.365,200L1495.368,200L1495.368,276.617C1495.368,283.831 1480.041,285.821 1466.785,285.821L1362.809,285.821C1351.21,285.821 1340.44,286.816 1334.226,289.552L1334.226,200L1305.229,200L1305.229,400L1334.226,400L1334.226,312.687C1334.226,306.716 1349.139,303.483 1362.809,303.483L1468.442,303.483C1479.212,303.234 1489.569,302.488 1494.954,300L1494.954,400L1524.365,400Z`,`M1894.702,400L1829.665,311.443C1823.037,302.239 1819.309,301.493 1819.309,301.493C1854.934,297.015 1884.76,275.622 1884.76,251.741C1884.76,223.383 1846.235,200 1799.011,200L1661.067,200L1661.067,400L1690.064,400L1690.064,308.458C1690.064,306.219 1691.721,303.483 1702.906,303.483L1777.056,303.483C1777.47,303.483 1791.555,302.985 1798.183,312.189L1862.805,400L1894.702,400ZM1689.65,286.816L1689.65,217.413L1798.597,217.413C1830.08,217.413 1855.763,232.836 1855.763,251.741C1855.763,270.647 1830.08,286.07 1798.597,286.07L1700.835,286.07C1696.692,286.07 1693.378,286.318 1689.65,286.816Z`,`M2030.575,400L2067.029,337.065C2067.443,336.567 2073.657,328.109 2095.612,328.109L2156.921,328.109C2167.691,328.109 2176.39,327.363 2184.261,325.622L2227.343,400L2257.583,400L2141.593,200L2116.739,200L2000.335,400L2030.575,400ZM2129.166,230.597L2175.147,309.453C2172.662,309.95 2166.862,310.945 2157.335,310.945L2096.026,310.945C2091.055,310.945 2086.913,311.194 2082.356,311.692L2129.166,230.597Z`],r=`200 200 2058 200`,i={play:`M7 4.5v15l12-7.5z`,stop:`M6 6h12v12H6z`,dice:`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm3 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm8 7a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm-4-3.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,star:`M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.9L12 16.9l-5.3 2.8 1-5.9-4.2-4.1 5.9-.8z`,trash:`M5 7h14M10 7V4.5h4V7m-7 0 1 13h8l1-13`,plus:`M12 5v14M5 12h14`,upload:`M12 16V4m0 0L7 9m5-5 5 5M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3`,mic:`M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3`,undo:`M9 7 4 12l5 5M4 12h11a5 5 0 0 1 0 10h-2`,redo:`M15 7l5 5-5 5M20 12H9a5 5 0 0 0 0 10h2`,refresh:`M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6`,x:`M6 6l12 12M18 6 6 18`,save:`M5 4h11l3 3v13H5zM8 4v5h7V4M8 20v-6h8v6`,download:`M12 4v12m0 0-5-5m5 5 5-5M4 20h16`,up:`M6 15l6-6 6 6`,down:`M6 9l6 6 6-6`,edit:`M4 20h4L19 9l-4-4L4 16zM14 6l4 4`,"edit-speech":`M6 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM6 14a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM20 5 8.5 13M20 19 8.5 11M12 12h2`,home:`M4 11 12 4l8 7v9h-5v-6H9v6H4z`,copy:`M9 9h10v11H9zM5 15V4h10`,wand:`M5 19 15 9m2-5v3m0 0v3m0-3h3m-3 0h-3M6 5v2m0 0v2m0-2h2m-2 0H4`,expand:`M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5`,sliders:`M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0M14 4v4M8 10v4M16 16v4`,globe:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z`,film:`M4 5h16v14H4zM8 5v14M16 5v14M4 9h4M4 15h4M16 9h4M16 15h4`,sun:`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8zM12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`,moon:`M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z`,alert:`M12 3.5 2.5 20h19zM12 10v4.5M12 17.2v.1`,left:`M15 6l-6 6 6 6`,right:`M9 6l6 6-6 6`,more:`M5 10.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,speaker:`M4 9h4l5-4v14l-5-4H4zM16 9a4 4 0 0 1 0 6M18.5 6.5a7.5 7.5 0 0 1 0 11`,brush:`M15 4l5 5-8 8-5-5zM7 12l5 5-2 2a3 3 0 0 1-4.2 0l-1.6-1.6a3 3 0 0 1 0-4.2z`,gear:`M12 8.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7zM12 2.5v2.3M12 19.2v2.3M2.5 12h2.3M19.2 12h2.3M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6`},a={play:!0,stop:!0,dice:!0,more:!0},o=`supports-zerogpu-headers`,s=`zerogpu-headers`,c=/^\/v2\/generate$/,l=typeof window<`u`&&window.parent!==window&&location.hostname.endsWith(`.hf.space`)?`https://huggingface.co`:null,u=!1;l&&(window.addEventListener(`message`,e=>{e.origin===l&&e.data===o&&(u=!0)}),window.parent.postMessage(o,l));var d=()=>u;function f(){if(!l||!u)return Promise.resolve(null);let{promise:e,resolve:t}=Promise.withResolvers(),n=new MessageChannel,r=e=>{clearTimeout(i),n.port1.close(),t(e)},i=setTimeout(()=>r(null),5e3);return n.port1.onmessage=({data:e})=>r(e&&typeof e==`object`?e:null),window.parent.postMessage(s,l,[n.port2]),e}async function p(e,t){if(!u)return t;let n=typeof e==`string`?e:e instanceof URL?e.href:e.url;if(!c.test(new URL(n,location.href).pathname))return t;let r=await f();if(!r)return t;let i=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));for(let[e,t]of Object.entries(r))i.set(e,t);return{...t,headers:i}}var m=new URLSearchParams(location.search).get(`engine`)||`/web-engine/engine.js`,h=null,g=()=>h??=import(m),_=!1,v=()=>_;function y(){_=!0}var b=(e,t)=>_?g().then(n=>n.localFetch(e,t)):p(e,t).then(t=>fetch(e,t)),x=1e6,S=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:`${Math.max(1,Math.round(e/x))} MB`;function C(e){if(e<5)return`a few seconds left`;if(e<60)return`about ${Math.ceil(e/5)*5} s left`;let t=Math.floor(e/60),n=Math.round(e%60/10)*10;return`about ${n&&t<10?`${t} min ${n} s`:`${Math.round(e/60)} min`} left`}function w(){let e=``,t=[];return n=>{let r=n.models.join(`+`);r!==e&&(e=r,t=[]);let i=performance.now();for(t.push({t:i,fetched:n.fetched});t.length>2&&i-t[1].t>8e3;)t.shift();let a=(i-t[0].t)/1e3,o=a>=2?(n.fetched-t[0].fetched)/a:0,s=Math.max(0,n.total-n.loaded),c=[`${S(n.loaded)} of ${S(n.total)}`];return o>.05*x&&s>0&&c.push(`${(o/x).toFixed(o>=10*x?0:1)} MB/s`,C(s/o)),{label:`${n.fetched>0?`Downloading`:`Loading`} ${n.models.map(E).join(` + `)}`,fraction:n.total?Math.min(1,n.loaded/n.total):0,detail:c.join(` · `)}}}var T={backbone:`voice model`,zac:`audio codec`,"zac-full_mr":`full-size audio decoder`,encoder:`voice encoder`,encoders:`voice encoders`},E=e=>T[e]??e;async function D(e){_=!0;let{engine:t}=await g(),n=w();await t.init(t=>e(n(t)))}async function O(e){let{engine:t}=await g(),n=w();t.onEncoderProgress(t=>e(n(t)))}var k=async()=>`gpu`in navigator&&await fetch(m,{method:`HEAD`}).then(e=>e.ok,()=>!1);export{v as a,a as c,t as d,n as f,b as i,i as l,y as n,k as o,r as p,D as r,d as s,O as t,e as u};
|
|
|
|
| 1 |
+
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=[`M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z`,`M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z`,`M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z`],t=`0 0 224 164`,n=[`M465.55,213.433L465.55,200L208.302,200L208.302,217.413L423.297,217.413L200.017,386.567L200.017,400L457.265,400L457.265,382.587L242.271,382.587L465.55,213.433Z`,`M851.628,200L816.003,200L707.884,287.313L599.766,200L564.141,200L687.586,299.751C689.243,302.736 693.386,310.448 693.386,320.398L693.386,400L721.969,400L721.969,320.398C721.969,310.448 725.697,302.985 727.768,299.751L851.628,200Z`,`M1108.047,200L969.688,200L969.688,400L998.686,400L998.686,308.458C998.686,306.219 1000.343,303.483 1011.527,303.483L1107.633,303.483C1154.857,303.483 1193.382,280.348 1193.382,251.99C1193.382,223.632 1155.271,200.249 1108.047,200ZM1009.87,286.318C1005.728,286.318 1002.414,286.567 998.686,287.065L998.686,217.662L1107.633,217.662C1139.116,217.662 1164.799,233.333 1164.799,252.239C1164.799,271.144 1139.116,286.318 1107.633,286.318L1009.87,286.318Z`,`M1524.365,400L1524.365,200L1495.368,200L1495.368,276.617C1495.368,283.831 1480.041,285.821 1466.785,285.821L1362.809,285.821C1351.21,285.821 1340.44,286.816 1334.226,289.552L1334.226,200L1305.229,200L1305.229,400L1334.226,400L1334.226,312.687C1334.226,306.716 1349.139,303.483 1362.809,303.483L1468.442,303.483C1479.212,303.234 1489.569,302.488 1494.954,300L1494.954,400L1524.365,400Z`,`M1894.702,400L1829.665,311.443C1823.037,302.239 1819.309,301.493 1819.309,301.493C1854.934,297.015 1884.76,275.622 1884.76,251.741C1884.76,223.383 1846.235,200 1799.011,200L1661.067,200L1661.067,400L1690.064,400L1690.064,308.458C1690.064,306.219 1691.721,303.483 1702.906,303.483L1777.056,303.483C1777.47,303.483 1791.555,302.985 1798.183,312.189L1862.805,400L1894.702,400ZM1689.65,286.816L1689.65,217.413L1798.597,217.413C1830.08,217.413 1855.763,232.836 1855.763,251.741C1855.763,270.647 1830.08,286.07 1798.597,286.07L1700.835,286.07C1696.692,286.07 1693.378,286.318 1689.65,286.816Z`,`M2030.575,400L2067.029,337.065C2067.443,336.567 2073.657,328.109 2095.612,328.109L2156.921,328.109C2167.691,328.109 2176.39,327.363 2184.261,325.622L2227.343,400L2257.583,400L2141.593,200L2116.739,200L2000.335,400L2030.575,400ZM2129.166,230.597L2175.147,309.453C2172.662,309.95 2166.862,310.945 2157.335,310.945L2096.026,310.945C2091.055,310.945 2086.913,311.194 2082.356,311.692L2129.166,230.597Z`],r=`200 200 2058 200`,i={play:`M7 4.5v15l12-7.5z`,stop:`M6 6h12v12H6z`,dice:`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm3 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm8 7a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm-4-3.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,star:`M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.9L12 16.9l-5.3 2.8 1-5.9-4.2-4.1 5.9-.8z`,trash:`M5 7h14M10 7V4.5h4V7m-7 0 1 13h8l1-13`,plus:`M12 5v14M5 12h14`,upload:`M12 16V4m0 0L7 9m5-5 5 5M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3`,mic:`M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3`,undo:`M9 7 4 12l5 5M4 12h11a5 5 0 0 1 0 10h-2`,redo:`M15 7l5 5-5 5M20 12H9a5 5 0 0 0 0 10h2`,refresh:`M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6`,x:`M6 6l12 12M18 6 6 18`,save:`M5 4h11l3 3v13H5zM8 4v5h7V4M8 20v-6h8v6`,download:`M12 4v12m0 0-5-5m5 5 5-5M4 20h16`,up:`M6 15l6-6 6 6`,down:`M6 9l6 6 6-6`,edit:`M4 20h4L19 9l-4-4L4 16zM14 6l4 4`,"edit-speech":`M6 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM6 14a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM20 5 8.5 13M20 19 8.5 11M12 12h2`,home:`M4 11 12 4l8 7v9h-5v-6H9v6H4z`,copy:`M9 9h10v11H9zM5 15V4h10`,wand:`M5 19 15 9m2-5v3m0 0v3m0-3h3m-3 0h-3M6 5v2m0 0v2m0-2h2m-2 0H4`,expand:`M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5`,sliders:`M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0M14 4v4M8 10v4M16 16v4`,globe:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z`,film:`M4 5h16v14H4zM8 5v14M16 5v14M4 9h4M4 15h4M16 9h4M16 15h4`,sun:`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8zM12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`,moon:`M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z`,alert:`M12 3.5 2.5 20h19zM12 10v4.5M12 17.2v.1`,left:`M15 6l-6 6 6 6`,right:`M9 6l6 6-6 6`,more:`M5 10.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm7 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z`,speaker:`M4 9h4l5-4v14l-5-4H4zM16 9a4 4 0 0 1 0 6M18.5 6.5a7.5 7.5 0 0 1 0 11`,brush:`M15 4l5 5-8 8-5-5zM7 12l5 5-2 2a3 3 0 0 1-4.2 0l-1.6-1.6a3 3 0 0 1 0-4.2z`,gear:`M12 8.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7zM12 2.5v2.3M12 19.2v2.3M2.5 12h2.3M19.2 12h2.3M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6`},a={play:!0,stop:!0,dice:!0,more:!0},o=`supports-zerogpu-headers`,s=`zerogpu-headers`,c=/^\/v2\/(generate|edit|edit\/transcribe|edit\/align)$/,l=typeof window<`u`&&window.parent!==window&&location.hostname.endsWith(`.hf.space`)?`https://huggingface.co`:null,u=!1;l&&(window.addEventListener(`message`,e=>{e.origin===l&&e.data===o&&(u=!0)}),window.parent.postMessage(o,l));var d=()=>u;function f(){if(!l||!u)return Promise.resolve(null);let{promise:e,resolve:t}=Promise.withResolvers(),n=new MessageChannel,r=e=>{clearTimeout(i),n.port1.close(),t(e)},i=setTimeout(()=>r(null),5e3);return n.port1.onmessage=({data:e})=>r(e&&typeof e==`object`?e:null),window.parent.postMessage(s,l,[n.port2]),e}async function p(e,t){if(!u)return t;let n=typeof e==`string`?e:e instanceof URL?e.href:e.url;if(!c.test(new URL(n,location.href).pathname))return t;let r=await f();if(!r)return t;let i=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));for(let[e,t]of Object.entries(r))i.set(e,t);return{...t,headers:i}}var m=new URLSearchParams(location.search).get(`engine`)||`/web-engine/engine.js`,h=null,g=()=>h??=import(m),_=!1,v=()=>_;function y(){_=!0}var b=(e,t)=>_?g().then(n=>n.localFetch(e,t)):p(e,t).then(t=>fetch(e,t)),x=1e6,S=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:`${Math.max(1,Math.round(e/x))} MB`;function C(e){if(e<5)return`a few seconds left`;if(e<60)return`about ${Math.ceil(e/5)*5} s left`;let t=Math.floor(e/60),n=Math.round(e%60/10)*10;return`about ${n&&t<10?`${t} min ${n} s`:`${Math.round(e/60)} min`} left`}function w(){let e=``,t=[];return n=>{let r=n.models.join(`+`);r!==e&&(e=r,t=[]);let i=performance.now();for(t.push({t:i,fetched:n.fetched});t.length>2&&i-t[1].t>8e3;)t.shift();let a=(i-t[0].t)/1e3,o=a>=2?(n.fetched-t[0].fetched)/a:0,s=Math.max(0,n.total-n.loaded),c=[`${S(n.loaded)} of ${S(n.total)}`];return o>.05*x&&s>0&&c.push(`${(o/x).toFixed(o>=10*x?0:1)} MB/s`,C(s/o)),{label:`${n.fetched>0?`Downloading`:`Loading`} ${n.models.map(E).join(` + `)}`,fraction:n.total?Math.min(1,n.loaded/n.total):0,detail:c.join(` · `)}}}var T={backbone:`voice model`,zac:`audio codec`,"zac-full_mr":`full-size audio decoder`,encoder:`voice encoder`,encoders:`voice encoders`},E=e=>T[e]??e;async function D(e){_=!0;let{engine:t}=await g(),n=w();await t.init(t=>e(n(t)))}async function O(e){let{engine:t}=await g(),n=w();t.onEncoderProgress(t=>e(n(t)))}var k=async()=>`gpu`in navigator&&await fetch(m,{method:`HEAD`}).then(e=>e.ok,()=>!1);export{v as a,a as c,t as d,n as f,b as i,i as l,y as n,k as o,r as p,D as r,d as s,O as t,e as u};
|
studio/index.html
CHANGED
|
@@ -7,9 +7,9 @@
|
|
| 7 |
<title>Zyphra Voice</title>
|
| 8 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-40 -70 304 304'%3E%3Crect x='-40' y='-70' width='304' height='304' rx='60' fill='%230a0a0a'/%3E%3Cpath d='M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z' fill='%23f5f3ee'/%3E%3C/svg%3E" />
|
| 9 |
<script src="/theme-boot.js"></script>
|
| 10 |
-
<script type="module" crossorigin src="/assets/index-
|
| 11 |
-
<link rel="modulepreload" crossorigin href="/assets/web-engine-
|
| 12 |
-
<link rel="modulepreload" crossorigin href="/assets/chrome-
|
| 13 |
<link rel="stylesheet" crossorigin href="/assets/web-engine-xKv10YAh.css">
|
| 14 |
<link rel="stylesheet" crossorigin href="/assets/index-y56CPfcm.css">
|
| 15 |
</head>
|
|
|
|
| 7 |
<title>Zyphra Voice</title>
|
| 8 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-40 -70 304 304'%3E%3Crect x='-40' y='-70' width='304' height='304' rx='60' fill='%230a0a0a'/%3E%3Cpath d='M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z' fill='%23f5f3ee'/%3E%3C/svg%3E" />
|
| 9 |
<script src="/theme-boot.js"></script>
|
| 10 |
+
<script type="module" crossorigin src="/assets/index-Cn8RrXS_.js"></script>
|
| 11 |
+
<link rel="modulepreload" crossorigin href="/assets/web-engine-Dm7WfUve.js">
|
| 12 |
+
<link rel="modulepreload" crossorigin href="/assets/chrome-DSTbbLEf.js">
|
| 13 |
<link rel="stylesheet" crossorigin href="/assets/web-engine-xKv10YAh.css">
|
| 14 |
<link rel="stylesheet" crossorigin href="/assets/index-y56CPfcm.css">
|
| 15 |
</head>
|
studio/lite.html
CHANGED
|
@@ -7,10 +7,10 @@
|
|
| 7 |
<title>Zyphra Voice Cloning</title>
|
| 8 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-40 -70 304 304'%3E%3Crect x='-40' y='-70' width='304' height='304' rx='60' fill='%230a0a0a'/%3E%3Cpath d='M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z' fill='%23f5f3ee'/%3E%3C/svg%3E" />
|
| 9 |
<script src="/theme-boot.js"></script>
|
| 10 |
-
<script type="module" crossorigin src="/assets/lite-
|
| 11 |
-
<link rel="modulepreload" crossorigin href="/assets/web-engine-
|
| 12 |
<link rel="modulepreload" crossorigin href="/assets/latin-500-Bp0u_hc5.js">
|
| 13 |
-
<link rel="modulepreload" crossorigin href="/assets/chrome-
|
| 14 |
<link rel="stylesheet" crossorigin href="/assets/web-engine-xKv10YAh.css">
|
| 15 |
<link rel="stylesheet" crossorigin href="/assets/latin-500-DKfSw4PI.css">
|
| 16 |
<link rel="stylesheet" crossorigin href="/assets/lite-CIuNopRM.css">
|
|
|
|
| 7 |
<title>Zyphra Voice Cloning</title>
|
| 8 |
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-40 -70 304 304'%3E%3Crect x='-40' y='-70' width='304' height='304' rx='60' fill='%230a0a0a'/%3E%3Cpath d='M52 12L48 0L112 29L176 0L172.5 12L132 31.5C119.834 38.4119 115.001 47.0057 112 58C109.023 46.9907 103.919 38.5163 92 31.5L52 12Z M28 54L24 42L112 82L200 42L196 54L132 84.5C120.163 91.4503 114.998 99.9976 112 111C108.997 100.003 103.724 91.4982 92 84.5L28 54Z M0 84L112 135L224 84L220 96L132 137.5C121 144 115.007 153.012 112 164C109 153 103 143 92 137.5L4 96L0 84Z' fill='%23f5f3ee'/%3E%3C/svg%3E" />
|
| 9 |
<script src="/theme-boot.js"></script>
|
| 10 |
+
<script type="module" crossorigin src="/assets/lite-Dm3Lt5gI.js"></script>
|
| 11 |
+
<link rel="modulepreload" crossorigin href="/assets/web-engine-Dm7WfUve.js">
|
| 12 |
<link rel="modulepreload" crossorigin href="/assets/latin-500-Bp0u_hc5.js">
|
| 13 |
+
<link rel="modulepreload" crossorigin href="/assets/chrome-DSTbbLEf.js">
|
| 14 |
<link rel="stylesheet" crossorigin href="/assets/web-engine-xKv10YAh.css">
|
| 15 |
<link rel="stylesheet" crossorigin href="/assets/latin-500-DKfSw4PI.css">
|
| 16 |
<link rel="stylesheet" crossorigin href="/assets/lite-CIuNopRM.css">
|
studio/studio.html
CHANGED
|
@@ -10,8 +10,8 @@
|
|
| 10 |
<link rel="manifest" href="/manifest.webmanifest" />
|
| 11 |
<meta name="theme-color" content="#0a0a0a" />
|
| 12 |
<script src="/theme-boot.js"></script>
|
| 13 |
-
<script type="module" crossorigin src="/assets/studio-
|
| 14 |
-
<link rel="modulepreload" crossorigin href="/assets/web-engine-
|
| 15 |
<link rel="modulepreload" crossorigin href="/assets/latin-500-Bp0u_hc5.js">
|
| 16 |
<link rel="stylesheet" crossorigin href="/assets/web-engine-xKv10YAh.css">
|
| 17 |
<link rel="stylesheet" crossorigin href="/assets/latin-500-DKfSw4PI.css">
|
|
|
|
| 10 |
<link rel="manifest" href="/manifest.webmanifest" />
|
| 11 |
<meta name="theme-color" content="#0a0a0a" />
|
| 12 |
<script src="/theme-boot.js"></script>
|
| 13 |
+
<script type="module" crossorigin src="/assets/studio-ltLzUm7R.js"></script>
|
| 14 |
+
<link rel="modulepreload" crossorigin href="/assets/web-engine-Dm7WfUve.js">
|
| 15 |
<link rel="modulepreload" crossorigin href="/assets/latin-500-Bp0u_hc5.js">
|
| 16 |
<link rel="stylesheet" crossorigin href="/assets/web-engine-xKv10YAh.css">
|
| 17 |
<link rel="stylesheet" crossorigin href="/assets/latin-500-DKfSw4PI.css">
|
studio/sw.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
| 14 |
// cache under it). clients.claim on activate only takes over pages nothing controls yet (the first visit), which then
|
| 15 |
// read this version's cache; a cache miss still falls back to the network.
|
| 16 |
|
| 17 |
-
const VERSION = "
|
| 18 |
const PRECACHE = [
|
| 19 |
"/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2",
|
| 20 |
"/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2",
|
|
@@ -30,8 +30,8 @@ const PRECACHE = [
|
|
| 30 |
"/assets/latin-500-Bp0u_hc5.js",
|
| 31 |
"/assets/latin-500-DKfSw4PI.css",
|
| 32 |
"/assets/studio-BSQ1WSyk.css",
|
| 33 |
-
"/assets/studio-
|
| 34 |
-
"/assets/web-engine-
|
| 35 |
"/assets/web-engine-xKv10YAh.css",
|
| 36 |
"/studio.html",
|
| 37 |
"/theme-boot.js"
|
|
|
|
| 14 |
// cache under it). clients.claim on activate only takes over pages nothing controls yet (the first visit), which then
|
| 15 |
// read this version's cache; a cache miss still falls back to the network.
|
| 16 |
|
| 17 |
+
const VERSION = "40062762334f";
|
| 18 |
const PRECACHE = [
|
| 19 |
"/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2",
|
| 20 |
"/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2",
|
|
|
|
| 30 |
"/assets/latin-500-Bp0u_hc5.js",
|
| 31 |
"/assets/latin-500-DKfSw4PI.css",
|
| 32 |
"/assets/studio-BSQ1WSyk.css",
|
| 33 |
+
"/assets/studio-ltLzUm7R.js",
|
| 34 |
+
"/assets/web-engine-Dm7WfUve.js",
|
| 35 |
"/assets/web-engine-xKv10YAh.css",
|
| 36 |
"/studio.html",
|
| 37 |
"/theme-boot.js"
|