PageSourceSearch

https://sprag.ai/assets/useReducedMotion-ilyy5KXM.js

js sprag.ai collected 2026-10-05 12:43:20 UTC 9,697 bytes, 1 lines download raw bytes

1import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{a as t,o as n}from"./vendor-markdown-BIxMb5FY.js";import{t as r}from"./utils-Bcnzz4Mj.js";import{t as i}from"./createLucideIcon-CcbOaUyo.js";import{t as a}from"./loader-circle-CD-3WgMA.js";import{t as o}from"./pause-C2ocRRhh.js";import{t as ee}from"./play-CgnM6-co.js";import{i as s,r as c}from"./models-BbSInryx.js";import{a as l,d as u,i as te,n as d,u as f,v as p,y as m}from"./voice-catalog-DAdwVrPW.js";import{a as h,r as g}from"./demo-Bg75DeV7.js";import{t as ne}from"./useSpeechGeneration-DYer_4mV.js";import{i as _,n as v,r as y,t as b}from"./select-de5MD01j.js";import{n as x,r as S,t as C}from"./avatar-BGDHhY2o.js";var re=i(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),w=i(`mars`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`m21 3-6.75 6.75`,key:`pv0uzu`}],[`circle`,{cx:`10`,cy:`14`,r:`6`,key:`1qwbdc`}]]),T=i(`venus-and-mars`,[[`path`,{d:`M10 20h4`,key:`ni2waw`}],[`path`,{d:`M12 16v6`,key:`c8a4gj`}],[`path`,{d:`M17 2h4v4`,key:`vhe59`}],[`path`,{d:`m21 2-5.46 5.46`,key:`19kypf`}],[`circle`,{cx:`12`,cy:`11`,r:`5`,key:`16gxyc`}]]),E=i(`venus`,[[`path`,{d:`M12 15v7`,key:`t2xh3l`}],[`path`,{d:`M9 19h6`,key:`456am0`}],[`circle`,{cx:`12`,cy:`9`,r:`6`,key:`1nw4tq`}]]),D=e(n(),1),O=e=>e.accent??e.defaultLanguage,k=[`female`,`male`],A={US:0,GB:1,AU:2,IN:3,DE:4,JP:5,CN:6,KR:7},j=e=>{let t=e.locale?.split(`-`)[1];return(t?A[t]:void 0)??99},M=te.map(e=>u(e)).filter(e=>!!(e.gender&&e.defaultLanguage)).sort((e,t)=>j(e)-j(t)||0),N=(e,t)=>t===`any`?e:e.filter(e=>e.gender===t),ie=e=>k.filter(t=>e.some(e=>e.gender===t)),P=(e,t)=>[...new Set(N(e,t).map(O))].sort((e,t)=>e.localeCompare(t)),F=(e,t,n,r)=>{let i=N(e,t),a=e=>O(e)===n;return r&&i.includes(r)&&a(r)?r:i.find(a)??i[0]};function I(e){try{let t=JSON.parse(e);return Array.isArray(t.words)?t.words.flatMap(e=>typeof e.word==`string`&&typeof e.start==`number`&&typeof e.end==`number`?[{word:e.word,start:e.start,end:e.end}]:[]):[]}catch{return[]}}function ae(){let{element:e,getToken:t}=h(),[n,r]=(0,D.useState)([]),i=(0,D.useRef)(0),a=(0,D.useCallback)(()=>{i.current+=1,r([])},[]);return{words:n,align:(0,D.useCallback)(async e=>{let n=++i.current;try{let a=new FormData;a.append(`file`,new File([e],`speech.mp3`,{type:e.type||`audio/mpeg`})),a.append(`model`,c),a.append(`response_format`,`verbose_json`),a.append(`timestamp_granularities[]`,`word`);let o=await g(a,await t());if(!o.ok)return;let ee=await o.text();if(n!==i.current)return;r(I(ee))}catch{}},[t]),clear:a,turnstile:e}}var L=t(),oe=s,se=[`any`,...ie(M)],R=e=>e===`any`?`Any`:e===`female`?`Female`:`Male`,z=M.find(e=>e.voiceId===`sienna`)??M[0],B=e=>l[e],V=({endpoint:e=`/v1/audio/speech`,action:t})=>{let[n,i]=(0,D.useState)(d[0]),[s,c]=(0,D.useState)(()=>B(d[0])),l=s.trim(),[u,te]=(0,D.useState)(`any`),[h,g]=(0,D.useState)(O(z)),x=se,S=P(M,u),C=F(M,u,h)??z,w=C.voiceId,T=e=>{te(e);let t=P(M,e);t.includes(h)||g(t[0])},E=e=>{i(e),c(B(e))},k=(0,D.useCallback)(()=>({model:oe,input:l,voice:w,...n?{language:n}:{},response_format:`mp3`}),[l,w,n]),{words:A,align:j,clear:N,turnstile:ie}=ae(),I=(0,D.useCallback)(e=>{j(e)},[j]),{audioRef:V,error:U,generate:G,hasAudio:K,isBusy:q,state:J,togglePlay:Y,turnstile:ce}=ne({demo:!0,resetKey:w,canSubmit:l.length>0,buildPayload:k,unavailableMessage:`Speech deployment unavailable right now. Try again in a moment.`,onGenerated:I}),[X,le]=(0,D.useState)(0),Z=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(J!==`playing`){cancelAnimationFrame(Z.current);return}let e=()=>{let t=V.current;t&&le(t.currentTime),Z.current=requestAnimationFrame(e)};return Z.current=requestAnimationFrame(e),()=>cancelAnimationFrame(Z.current)},[J,V]);let ue=J===`playing`&&A.length>0,Q=`h-auto w-auto gap-2 whitespace-nowrap rounded-full border-border bg-card py-1.5 pl-1.5 pr-3 type-body-sm text-foreground shadow-button transition-colors hover:border-foreground
1/25 disabled:opacity-60 [&>span]:!flex [&>span]:items-center [&>span]:gap-2`,$=`rounded-lg py-2 pl-2.5 pr-3 [&>span:first-child]:hidden data-[state=checked]:bg-secondary data-[state=checked]:text-foreground data-[state=checked]:focus:bg-secondary data-[state=checked]:focus:text-foreground`;return(0,L.jsxs)(`div`,{className:`w-full rounded-3xl bg-secondary/50 p-5 sm:p-7`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,L.jsxs)(b,{value:n,onValueChange:E,disabled:q,children:[(0,L.jsx)(_,{"aria-label":`Output language`,className:Q,children:(0,L.jsxs)(`span`,{children:[(0,L.jsx)(m,{locale:p[n],shape:`circle`,className:`h-6 w-6`}),(0,L.jsx)(`span`,{children:f(n)})]})}),(0,L.jsx)(v,{className:`max-h-72`,children:d.map(e=>(0,L.jsx)(y,{value:e,className:$,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(m,{locale:p[e],shape:`circle`}),(0,L.jsx)(`span`,{children:f(e)})]})},e))})]}),(0,L.jsxs)(b,{value:u,onValueChange:e=>T(e),disabled:q,children:[(0,L.jsx)(_,{"aria-label":`Gender`,className:Q,children:(0,L.jsxs)(`span`,{children:[(0,L.jsx)(W,{gender:u}),(0,L.jsx)(`span`,{children:R(u)})]})}),(0,L.jsx)(v,{children:x.map(e=>(0,L.jsx)(y,{value:e,className:$,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(W,{gender:e}),(0,L.jsx)(`span`,{children:R(e)})]})},e))})]}),(0,L.jsxs)(b,{value:h,onValueChange:g,disabled:q,children:[(0,L.jsx)(_,{"aria-label":`Accent`,className:Q,children:(0,L.jsxs)(`span`,{children:[(0,L.jsx)(H,{src:C.portraitUrl,name:C.name}),(0,L.jsx)(`span`,{children:h})]})}),(0,L.jsx)(v,{className:`max-h-72`,children:S.map(e=>{let t=F(M,u,e);return t?(0,L.jsx)(y,{value:e,className:$,"aria-label":`${e} accent, voiced by ${t.name}`,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(H,{src:t.portraitUrl,name:t.name}),(0,L.jsx)(`span`,{children:e})]})},e):null})})]}),(e||t)&&(0,L.jsxs)(`div`,{className:`ml-auto flex items-center gap-4`,children:[e&&(0,L.jsx)(`span`,{className:`font-mono text-[0.64rem] uppercase tracking-[0.22em] text-muted-foreground/85`,children:e}),t]})]}),(0,L.jsxs)(`div`,{className:`mt-4 rounded-2xl border border-border bg-card p-4 shadow-card sm:p-5`,children:[(0,L.jsx)(`label`,{htmlFor:`tts-text`,className:`sr-only`,children:`Text to speak`}),ue?(0,L.jsx)(`p`,{className:`min-h-[6.5rem] type-body-sm leading-relaxed text-muted-foreground`,children:A.map((e,t)=>{let n=X>=e.start&&X<e.end,i=X>=e.end;return(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{let t=V.current;t&&(t.currentTime=e.start)},className:r(`-mx-0.5 rounded-sm px-0.5 transition-colors`,`focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring`,n?`bg-primary/15 text-primary-ink`:i?`text-foreground`:`text-muted-foreground`),children:e.word}),t<A.length-1&&` `]},`${e.start}-${t}`)})}):(0,L.jsx)(`textarea`,{id:`tts-text`,value:s,onChange:e=>{c(e.target.value),N()},rows:4,maxLength:500,disabled:q,placeholder:`Type any text. Up to 500 characters.`,className:r(`min-h-[6.5rem] w-full resize-none border-0 bg-transparent p-0 type-body-sm leading-relaxed text-foreground`,`placeholder:text-muted-foreground/60 focus-visible:outline-hidden`)}),(0,L.jsxs)(`div`,{className:`mt-3 flex items-center justify-end gap-2`,children:[(0,L.jsxs)(`span`,{className:`mr-auto font-mono text-[0.68rem] tabular-nums text-muted-foreground/70`,children:[l.length,` / 500`]}),K&&(0,L.jsx)(`button`,{type:`button`,onClick:Y,"aria-label":J===`playing`?`Pause`:`Replay`,className:`flex h-10 w-10 items-center justify-center rounded-full border border-border bg-card text-foreground transition-colors hover:border-foreground
1/25 hover:bg-secondary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:J===`playing`?(0,L.jsx)(o,{className:`h-4 w-4`}):(0,L.jsx)(ee,{className:`h-4 w-4 translate-x-[1px]`})}),(0,L.jsx)(`button`,{type:`button`,onClick:G,disabled:q||!l,"aria-label":q?`Generating speech`:`Generate speech`,className:r(`flex h-10 w-10 items-center justify-center rounded-full transition`,`focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,q||!l?`cursor-not-allowed bg-foreground/25 text-background`:`bg-foreground text-background hover:bg-foreground/90`),children:q?(0,L.jsx)(a,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(re,{className:`h-4 w-4`})})]})]}),U&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-3 type-body-sm text-pretty text-destructive/90`,children:U}),(0,L.jsx)(`audio`,{ref:V,preload:`none`,className:`hidden`}),ce,ie]})},H=({src:e,name:t})=>(0,L.jsxs)(C,{className:`h-6 w-6 shrink-0 rounded-full ring-1 ring-border`,children:[(0,L.jsx)(S,{src:e,alt:``}),(0,L.jsx)(x,{className:`rounded-full bg-secondary text-[0.6rem] font-semibold uppercase text-muted-foreground`,children:t.slice(0,2)})]}),U={female:{Icon:E,className:`bg-pink-500/12 text-pink-600 ring-pink-500/25 dark:text-pink-400 dark:ring-pink-400/25`},male:{Icon:w,className:`bg-blue-500/12 text-blue-600 ring-blue-500/25 dark:text-blue-400 dark:ring-blue-400/25`},any:{Icon:T,className:`bg-secondary text-muted-foreground ring-border`}},W=({gender:e})=>{let{Icon:t,className:n}=U[e];return(0,L.jsx)(`span`,{className:r(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full ring-1`,n),children:(0,L.jsx)(t,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})},G=`(prefers-reduced-motion: reduce)`;function K(e){let t=window.matchMedia(G);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}var q=()=>window.matchMedia(G).matches,J=()=>!1;function Y(){return(0,D.useSyncExternalStore)(K,q,J)}export{P as a,T as c,O as i,w as l,V as n,F as o,M as r,E as s,Y as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.