Spaces:
Running
Running
| import{r as s,j as e}from"./react-_fH1j4AW.js";import{c as b}from"./index-Nqm_ElTk.js";import"./@braintree-9Zuj5s7N.js";import"./react-dom-B47xkeQg.js";import"./scheduler-DYLXRpC5.js";import"./mermaid-CwNlsT42.js";import"./dayjs-LlU9W_sF.js";import"./d3-transition-593SbTzI.js";import"./d3-timer-DdKHrDhs.js";import"./d3-dispatch-kxCwF96_.js";import"./d3-interpolate-CfLzPKWk.js";import"./d3-color-amxIadob.js";import"./d3-selection-C52G7wmG.js";import"./d3-ease-DRPgKoYJ.js";import"./d3-zoom-Dc8HCWOS.js";import"./dompurify-J5RlrwSC.js";import"./dagre-d3-es-CXvdFQqV.js";import"./lodash-es-CKQobiyk.js";import"./d3-shape-C6amFesj.js";import"./d3-path-CimkQT29.js";import"./d3-fetch-BOsq7VnW.js";import"./khroma-DUX6PT6k.js";import"./uuid-DhYbOkY1.js";import"./d3-scale-BchcX-lF.js";import"./internmap-BkD7Hj8s.js";import"./d3-array-DGRYoJHh.js";import"./d3-format-CzD4bSOQ.js";import"./d3-time-format-CUNN4Ell.js";import"./d3-time-6cSPyVSY.js";import"./d3-axis-DSWTncID.js";import"./elkjs-BS_sNva5.js";import"./cytoscape-Copgxxlq.js";import"./cytoscape-cose-bilkent-DNVwk4oY.js";import"./cose-base-HlRMd3jM.js";import"./layout-base-BVPXtQQC.js";import"./d3-sankey-DgqkLiUE.js";import"./d3-scale-chromatic-B-NsZVaP.js";import"./ts-dedent-DrFu-skq.js";import"./stylis-D5iaQeiq.js";import"./mdast-util-from-markdown-CLAsVoWb.js";import"./micromark-CTBPIv-_.js";import"./micromark-util-combine-extensions-Bka6Sc1c.js";import"./micromark-util-chunked-DrRIdSP-.js";import"./micromark-factory-space-x2vfxbz5.js";import"./micromark-util-character-Bcm1tP9o.js";import"./micromark-core-commonmark-AH8VCgT7.js";import"./micromark-util-classify-character-Cq7Fg3xE.js";import"./micromark-util-resolve-all-PQCKh0dx.js";import"./decode-named-character-reference-C3-224fz.js";import"./micromark-util-subtokenize-QwsxNXk2.js";import"./micromark-factory-destination-CypD_wgM.js";import"./micromark-factory-label-CRHH4ZHP.js";import"./micromark-factory-title-B7kCBvC9.js";import"./micromark-factory-whitespace-B322EA6O.js";import"./micromark-util-normalize-identifier-C9ANKk3v.js";import"./micromark-util-html-tag-name-DbKNfynz.js";import"./micromark-util-decode-numeric-character-reference-DRnCnno4.js";import"./micromark-util-decode-string-DJl8Y_PO.js";import"./unist-util-stringify-position-Ch_qCilz.js";import"./mdast-util-to-string-C_aolqmU.js";const ke=()=>{const[l,p]=s.useState(`function helloWorld() { | |
| console.log("Hello, world!"); | |
| }`),[n,d]=s.useState([]),[m,c]=s.useState(),[r,x]=s.useState(1),[a,h]=s.useState(1);s.useEffect(()=>{const t=()=>{var i;const o=window.speechSynthesis.getVoices();d(o),o.length>0&&c(((i=o.find(g=>g.lang.startsWith("en")))==null?void 0:i.name)||o[0].name)};t(),window.speechSynthesis.onvoiceschanged=t},[]);const u=()=>{window.speechSynthesis.speaking&&window.speechSynthesis.cancel();const t=new SpeechSynthesisUtterance(l),o=n.find(i=>i.name===m);o&&(t.voice=o),t.rate=r,t.pitch=a,window.speechSynthesis.speak(t)},f=()=>{window.speechSynthesis.cancel()};return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold text-slate-100 flex items-center",children:[e.jsx(b,{}),e.jsx("span",{className:"ml-3",children:"Code Audio Narrator"})]}),e.jsx("p",{className:"text-slate-400 mt-1",children:"Have your code read aloud for accessibility or proof-listening."})]}),e.jsxs("div",{className:"flex-grow grid grid-cols-1 lg:grid-cols-3 gap-6 min-h-0",children:[e.jsxs("div",{className:"lg:col-span-2 flex flex-col h-full",children:[e.jsx("label",{htmlFor:"code-narrator-input",className:"text-sm font-medium text-slate-400 mb-2",children:"Code to Read"}),e.jsx("textarea",{id:"code-narrator-input",value:l,onChange:t=>p(t.target.value),className:"flex-grow p-4 bg-slate-900 border border-slate-700 rounded-md resize-none font-mono text-sm text-cyan-300 focus:ring-2 focus:ring-cyan-500 focus:outline-none"})]}),e.jsxs("div",{className:"flex flex-col gap-4 bg-slate-800/50 p-6 rounded-lg",children:[e.jsx("h3",{className:"text-xl font-bold",children:"Controls"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"voice-select",className:"block text-sm font-medium text-slate-400",children:"Voice"}),e.jsx("select",{id:"voice-select",value:m,onChange:t=>c(t.target.value),className:"w-full mt-1 px-3 py-2 rounded-md bg-slate-800 border border-slate-700",children:n.map(t=>e.jsxs("option",{value:t.name,children:[t.name," (",t.lang,")"]},t.name))})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"rate",className:"block text-sm font-medium text-slate-400",children:["Rate (",r.toFixed(1),")"]}),e.jsx("input",{id:"rate",type:"range",min:"0.5",max:"2",step:"0.1",value:r,onChange:t=>x(Number(t.target.value)),className:"w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"pitch",className:"block text-sm font-medium text-slate-400",children:["Pitch (",a.toFixed(1),")"]}),e.jsx("input",{id:"pitch",type:"range",min:"0",max:"2",step:"0.1",value:a,onChange:t=>h(Number(t.target.value)),className:"w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer"})]}),e.jsxs("div",{className:"flex gap-2 mt-auto",children:[e.jsx("button",{onClick:u,className:"flex-1 px-6 py-3 bg-cyan-500 text-slate-900 font-bold rounded-md",children:"Speak"}),e.jsx("button",{onClick:f,className:"flex-1 px-6 py-3 bg-slate-700 text-slate-200 font-bold rounded-md",children:"Stop"})]})]})]})]})};export{ke as CodeAudioNarrator}; | |
| //# sourceMappingURL=CodeAudioNarrator-0iRIzTGo.js.map | |