diff --git a/astro.config.mjs b/astro.config.mjs index eba0dba..0b0acb8 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,7 +5,7 @@ import sitemap from '@astrojs/sitemap'; import pkgs from './package.json'; import tailwindcss from '@tailwindcss/vite'; const isDev = process.env.NODE_ENV === 'development'; - +import { viteStaticCopy } from 'vite-plugin-static-copy'; let target = process.env.VITE_API_URL || 'https://localhost:51015'; const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' }; let proxy = { @@ -16,6 +16,30 @@ let proxy = { }; const basename = isDev ? undefined : `${pkgs.basename}`; +const vad = viteStaticCopy({ + targets: [ + { + src: 'node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js', + dest: './public/', + }, + { + src: 'node_modules/@ricky0123/vad-web/dist/silero_vad_v5.onnx', + dest: './public/', + }, + { + src: 'node_modules/@ricky0123/vad-web/dist/silero_vad_legacy.onnx', + dest: './public/', + }, + { + src: 'node_modules/onnxruntime-web/dist/*.wasm', + dest: './public/', + }, + { + src: 'node_modules/onnxruntime-web/dist/*.mjs', + dest: './public/', + }, + ], +}); export default defineConfig({ base: basename, integrations: [ @@ -23,14 +47,13 @@ export default defineConfig({ react(), // // sitemap(), // sitemap must be site has a domain ], - + vite: { - plugins: [tailwindcss()], + plugins: [tailwindcss(), vad], define: { basename: JSON.stringify(basename || ''), }, server: { - https: true, port: 7008, host: '0.0.0.0', allowedHosts: true, diff --git a/package.json b/package.json index f6fe47c..0a99386 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "@kevisual/astro-simplate-template", + "name": "@kevisual/vad-voice-web", "version": "0.0.1", "description": "", "main": "index.js", - "basename": "/root/astro-simplate-template", + "basename": "/root/vad-voice-web", "scripts": { "dev": "astro dev", "build": "astro build", "preview": "astro preview", - "pub": "envision deploy ./dist -k astro-simplate-template -v 0.0.1 -u", + "pub": "envision deploy ./dist -k vad-voice-web -v 0.0.1 -u", "sn": "pnpm dlx shadcn@latest add " }, "keywords": [], @@ -22,6 +22,7 @@ "@kevisual/query": "^0.0.29", "@kevisual/query-login": "^0.0.6", "@kevisual/registry": "^0.0.1", + "@ricky0123/vad-web": "^0.0.28", "@tailwindcss/vite": "^4.1.14", "astro": "^5.14.5", "class-variance-authority": "^0.7.1", @@ -30,6 +31,7 @@ "lodash-es": "^4.17.21", "lucide-react": "^0.546.0", "nanoid": "^5.1.6", + "onnxruntime-web": "^1.23.0", "react": "^19.2.0", "react-dom": "^19.2.0", "react-toastify": "^11.0.5", @@ -46,7 +48,8 @@ "@vitejs/plugin-basic-ssl": "^2.1.0", "dotenv": "^17.2.3", "tailwindcss": "^4.1.14", - "tw-animate-css": "^1.4.0" + "tw-animate-css": "^1.4.0", + "vite-plugin-static-copy": "^3.1.4" }, "packageManager": "pnpm@10.18.3", "onlyBuiltDependencies": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6d90a88..81b6d4e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: '@kevisual/registry': specifier: ^0.0.1 version: 0.0.1(typescript@5.9.3) + '@ricky0123/vad-web': + specifier: ^0.0.28 + version: 0.0.28 '@tailwindcss/vite': specifier: ^4.1.14 version: 4.1.14(vite@6.3.6(@types/node@24.7.2)(jiti@2.6.1)(lightningcss@1.30.1)) @@ -50,6 +53,9 @@ importers: nanoid: specifier: ^5.1.6 version: 5.1.6 + onnxruntime-web: + specifier: ^1.23.0 + version: 1.23.0 react: specifier: ^19.2.0 version: 19.2.0 @@ -87,6 +93,9 @@ importers: tw-animate-css: specifier: ^1.4.0 version: 1.4.0 + vite-plugin-static-copy: + specifier: ^3.1.4 + version: 3.1.4(vite@6.3.6(@types/node@24.7.2)(jiti@2.6.1)(lightningcss@1.30.1)) packages: @@ -558,6 +567,39 @@ packages: '@oslojs/encoding@1.1.0': resolution: {integrity: sha512-70wQhgYmndg4GCPxPPxPGevRKqTIJ2Nh4OkiMWmDAVYsTQ+Ta7Sq+rPevXyXGdzr30/qZBnyOalCszoMxlyldQ==} + '@protobufjs/aspromise@1.1.2': + resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} + + '@protobufjs/base64@1.1.2': + resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} + + '@protobufjs/codegen@2.0.4': + resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==} + + '@protobufjs/eventemitter@1.1.0': + resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==} + + '@protobufjs/fetch@1.1.0': + resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==} + + '@protobufjs/float@1.0.2': + resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} + + '@protobufjs/inquire@1.1.0': + resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==} + + '@protobufjs/path@1.1.2': + resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} + + '@protobufjs/pool@1.1.0': + resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} + + '@protobufjs/utf8@1.1.0': + resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} + + '@ricky0123/vad-web@0.0.28': + resolution: {integrity: sha512-Hvw8jN3r1SBxmjJa89HITxRcwlT6dc7CQPVtVQLrqfY8EeQcx41QeqKUol4lw8ZCeAIHKwYndHnB1K/4SAQJgQ==} + '@rolldown/pluginutils@1.0.0-beta.27': resolution: {integrity: sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==} @@ -988,10 +1030,18 @@ packages: resolution: {integrity: sha512-OMu3BGQ4E7P1ErFsIPpbJh0qvDudM/UuJeHgkAvfWe+0HFJCXh+t/l8L6fVLR55RI/UbKrVLnAXZSVwd9ysWYw==} hasBin: true + binary-extensions@2.3.0: + resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} + engines: {node: '>=8'} + boxen@8.0.1: resolution: {integrity: sha512-F3PH5k5juxom4xktynS7MoFY+NUWH5LC4CnH11YB8NPew+HLpmBLCybSAEyb2F+4pRXhuhWqFesoQd6DAyc2hw==} engines: {node: '>=18'} + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + brotli@1.3.3: resolution: {integrity: sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==} @@ -1026,6 +1076,10 @@ packages: character-reference-invalid@2.0.1: resolution: {integrity: sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==} + chokidar@3.6.0: + resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} + engines: {node: '>= 8.10.0'} + chokidar@4.0.3: resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} engines: {node: '>= 14.16.0'} @@ -1239,6 +1293,13 @@ packages: picomatch: optional: true + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + + flatbuffers@25.9.23: + resolution: {integrity: sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==} + flattie@1.1.1: resolution: {integrity: sha512-9UbaD6XdAL97+k/n+N7JwX46K/M6Zc6KcFYskrYL8wbBV/Uyk0CTAMY0VT+qiK5PM7AIc9aTWYtq65U7T+aCNQ==} engines: {node: '>=8'} @@ -1268,9 +1329,16 @@ packages: github-slugger@2.0.0: resolution: {integrity: sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==} + glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + guid-typescript@1.0.9: + resolution: {integrity: sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==} + h3@1.15.4: resolution: {integrity: sha512-z5cFQWDffyOe4vQ9xIqNfCZdV4p//vy6fBnr8Q1AWnVZ0teurKMG66rLj++TKwKPUP3u7iMUvrvKaEUiQw2QWQ==} @@ -1358,6 +1426,10 @@ packages: is-alphanumerical@2.0.1: resolution: {integrity: sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==} + is-binary-path@2.1.0: + resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} + engines: {node: '>=8'} + is-core-module@2.16.1: resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} engines: {node: '>= 0.4'} @@ -1370,10 +1442,18 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} hasBin: true + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + is-hexadecimal@2.0.1: resolution: {integrity: sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==} @@ -1385,6 +1465,10 @@ packages: is-module@1.0.0: resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + is-plain-obj@4.1.0: resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==} engines: {node: '>=12'} @@ -1496,6 +1580,9 @@ packages: lodash-es@4.17.21: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} + long@5.3.2: + resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==} + longest-streak@3.1.0: resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} @@ -1753,6 +1840,12 @@ packages: oniguruma-to-es@4.3.3: resolution: {integrity: sha512-rPiZhzC3wXwE59YQMRDodUwwT9FZ9nNBwQQfsd1wfdtlKEyCdRV0avrTcSZ5xlIvGRVPd/cx6ZN45ECmS39xvg==} + onnxruntime-common@1.23.0: + resolution: {integrity: sha512-Auz8S9D7vpF8ok7fzTobvD1XdQDftRf/S7pHmjeCr3Xdymi4z1C7zx4vnT6nnUjbpelZdGwda0BmWHCCTMKUTg==} + + onnxruntime-web@1.23.0: + resolution: {integrity: sha512-w0bvC2RwDxphOUFF8jFGZ/dYw+duaX20jM6V4BIZJPCfK4QuCpB/pVREV+hjYbT3x4hyfa2ZbTaWx4e1Vot0fQ==} + openai@5.23.2: resolution: {integrity: sha512-MQBzmTulj+MM5O8SKEk/gL8a7s5mktS9zUtAkU257WjvobGc9nKcBuVwjyEEcb9SI8a8Y2G/mzn3vm9n1Jlleg==} hasBin: true @@ -1769,6 +1862,10 @@ packages: resolution: {integrity: sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA==} engines: {node: '>=18'} + p-map@7.0.3: + resolution: {integrity: sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==} + engines: {node: '>=18'} + p-queue@8.1.1: resolution: {integrity: sha512-aNZ+VfjobsWryoiPnEApGGmf5WmNsCo9xu8dfaYamG5qaLP7ClhLN6NgsFe6SwJ2UbLEBK5dv9x8Mn5+RVhMWQ==} engines: {node: '>=18'} @@ -1806,6 +1903,9 @@ packages: resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} engines: {node: '>=12'} + platform@1.3.6: + resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==} + postcss@8.5.6: resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} engines: {node: ^10 || ^12 || >=14} @@ -1824,6 +1924,10 @@ packages: property-information@7.1.0: resolution: {integrity: sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==} + protobufjs@7.5.4: + resolution: {integrity: sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==} + engines: {node: '>=12.0.0'} + radix3@1.1.2: resolution: {integrity: sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==} @@ -1862,6 +1966,10 @@ packages: resolution: {integrity: sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==} engines: {node: '>=0.10.0'} + readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + readdirp@4.1.2: resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} engines: {node: '>= 14.18.0'} @@ -2056,6 +2164,10 @@ packages: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} @@ -2221,6 +2333,12 @@ packages: vfile@6.0.3: resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} + vite-plugin-static-copy@3.1.4: + resolution: {integrity: sha512-iCmr4GSw4eSnaB+G8zc2f4dxSuDjbkjwpuBLLGvQYR9IW7rnDzftnUjOH5p4RYR+d4GsiBqXRvzuFhs5bnzVyw==} + engines: {node: ^18.0.0 || >=20.0.0} + peerDependencies: + vite: ^5.0.0 || ^6.0.0 || ^7.0.0 + vite@6.3.6: resolution: {integrity: sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} @@ -2845,6 +2963,33 @@ snapshots: '@oslojs/encoding@1.1.0': {} + '@protobufjs/aspromise@1.1.2': {} + + '@protobufjs/base64@1.1.2': {} + + '@protobufjs/codegen@2.0.4': {} + + '@protobufjs/eventemitter@1.1.0': {} + + '@protobufjs/fetch@1.1.0': + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/inquire': 1.1.0 + + '@protobufjs/float@1.0.2': {} + + '@protobufjs/inquire@1.1.0': {} + + '@protobufjs/path@1.1.2': {} + + '@protobufjs/pool@1.1.0': {} + + '@protobufjs/utf8@1.1.0': {} + + '@ricky0123/vad-web@0.0.28': + dependencies: + onnxruntime-web: 1.23.0 + '@rolldown/pluginutils@1.0.0-beta.27': {} '@rollup/plugin-commonjs@28.0.6(rollup@4.52.4)': @@ -3295,6 +3440,8 @@ snapshots: baseline-browser-mapping@2.8.16: {} + binary-extensions@2.3.0: {} + boxen@8.0.1: dependencies: ansi-align: 3.0.1 @@ -3306,6 +3453,10 @@ snapshots: widest-line: 5.0.0 wrap-ansi: 9.0.2 + braces@3.0.3: + dependencies: + fill-range: 7.1.1 + brotli@1.3.3: dependencies: base64-js: 1.5.1 @@ -3334,6 +3485,18 @@ snapshots: character-reference-invalid@2.0.1: {} + chokidar@3.6.0: + dependencies: + anymatch: 3.1.3 + braces: 3.0.3 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.3 + chokidar@4.0.3: dependencies: readdirp: 4.1.2 @@ -3534,6 +3697,12 @@ snapshots: optionalDependencies: picomatch: 4.0.3 + fill-range@7.1.1: + dependencies: + to-regex-range: 5.0.1 + + flatbuffers@25.9.23: {} + flattie@1.1.1: {} fontace@0.3.1: @@ -3564,8 +3733,14 @@ snapshots: github-slugger@2.0.0: {} + glob-parent@5.1.2: + dependencies: + is-glob: 4.0.3 + graceful-fs@4.2.11: {} + guid-typescript@1.0.9: {} + h3@1.15.4: dependencies: cookie-es: 1.2.2 @@ -3751,6 +3926,10 @@ snapshots: is-alphabetical: 2.0.1 is-decimal: 2.0.1 + is-binary-path@2.1.0: + dependencies: + binary-extensions: 2.3.0 + is-core-module@2.16.1: dependencies: hasown: 2.0.2 @@ -3759,8 +3938,14 @@ snapshots: is-docker@3.0.0: {} + is-extglob@2.1.1: {} + is-fullwidth-code-point@3.0.0: {} + is-glob@4.0.3: + dependencies: + is-extglob: 2.1.1 + is-hexadecimal@2.0.1: {} is-inside-container@1.0.0: @@ -3769,6 +3954,8 @@ snapshots: is-module@1.0.0: {} + is-number@7.0.0: {} + is-plain-obj@4.1.0: {} is-reference@1.2.1: @@ -3842,6 +4029,8 @@ snapshots: lodash-es@4.17.21: {} + long@5.3.2: {} + longest-streak@3.1.0: {} lru-cache@10.4.3: {} @@ -4355,6 +4544,17 @@ snapshots: regex: 6.0.1 regex-recursion: 6.0.2 + onnxruntime-common@1.23.0: {} + + onnxruntime-web@1.23.0: + dependencies: + flatbuffers: 25.9.23 + guid-typescript: 1.0.9 + long: 5.3.2 + onnxruntime-common: 1.23.0 + platform: 1.3.6 + protobufjs: 7.5.4 + openai@5.23.2(zod@3.25.76): optionalDependencies: zod: 3.25.76 @@ -4363,6 +4563,8 @@ snapshots: dependencies: yocto-queue: 1.2.1 + p-map@7.0.3: {} + p-queue@8.1.1: dependencies: eventemitter3: 5.0.1 @@ -4405,6 +4607,8 @@ snapshots: picomatch@4.0.3: {} + platform@1.3.6: {} + postcss@8.5.6: dependencies: nanoid: 3.3.11 @@ -4422,6 +4626,21 @@ snapshots: property-information@7.1.0: {} + protobufjs@7.5.4: + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/base64': 1.1.2 + '@protobufjs/codegen': 2.0.4 + '@protobufjs/eventemitter': 1.1.0 + '@protobufjs/fetch': 1.1.0 + '@protobufjs/float': 1.0.2 + '@protobufjs/inquire': 1.1.0 + '@protobufjs/path': 1.1.2 + '@protobufjs/pool': 1.1.0 + '@protobufjs/utf8': 1.1.0 + '@types/node': 24.7.2 + long: 5.3.2 + radix3@1.1.2: {} react-dom@19.2.0(react@19.2.0): @@ -4449,6 +4668,10 @@ snapshots: react@19.2.0: {} + readdirp@3.6.0: + dependencies: + picomatch: 2.3.1 + readdirp@4.1.2: {} recma-build-jsx@1.0.0: @@ -4766,6 +4989,10 @@ snapshots: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + to-regex-range@5.0.1: + dependencies: + is-number: 7.0.0 + tr46@0.0.3: {} trim-lines@3.0.1: {} @@ -4898,6 +5125,14 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 + vite-plugin-static-copy@3.1.4(vite@6.3.6(@types/node@24.7.2)(jiti@2.6.1)(lightningcss@1.30.1)): + dependencies: + chokidar: 3.6.0 + p-map: 7.0.3 + picocolors: 1.1.1 + tinyglobby: 0.2.15 + vite: 6.3.6(@types/node@24.7.2)(jiti@2.6.1)(lightningcss@1.30.1) + vite@6.3.6(@types/node@24.7.2)(jiti@2.6.1)(lightningcss@1.30.1): dependencies: esbuild: 0.25.10 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..2797245 --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ + +能做来什么,记录每句话的内容,然后每一个记录都可以转为文字。 + diff --git a/src/apps/VadVoice.tsx b/src/apps/VadVoice.tsx new file mode 100644 index 0000000..101693a --- /dev/null +++ b/src/apps/VadVoice.tsx @@ -0,0 +1,71 @@ +import { MicVAD, utils } from "@ricky0123/vad-web" +import clsx from "clsx"; +import { useState, useEffect, useRef } from "react"; +import './style.css' + +type speakType = { + timestamp: number; + url: string; + +} +export const VadVoice = () => { + const [userList, setUserList] = useState([]); + const [listen, setListen] = useState(true); + const ref = useRef(null); + async function main() { + const myvad = await MicVAD.new({ + onSpeechEnd: (audio) => { + // do something with `audio` (Float32Array of audio samples at sample rate 16000)... + const wavBuffer = utils.encodeWAV(audio) + const base64 = utils.arrayBufferToBase64(wavBuffer) + // const url = `data:audio/wav;base64,${base64}` + const url = URL.createObjectURL(new Blob([wavBuffer], { type: 'audio/wav' })) + setUserList((prev) => [...prev, { timestamp: Date.now(), url }]); + }, + onnxWASMBasePath: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/", + baseAssetPath: "https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.27/dist/", + }) + ref.current = myvad; + myvad.start(); + return myvad; + } + useEffect(() => { + main(); + }, []) + const close = () => { + if (ref.current) { + ref.current.destroy(); + ref.current = null; + setListen(false); + } + } + return
+
    + {userList.map((url, index) => ( +
  • + +
    {new Date(url.timestamp).toLocaleString()}
    +
  • + ))} +
+ +
+
+
+
+
{ + if (listen) { + close(); + } else { + main(); + setListen(true); + } + }}> +
{listen ? 'Pause' : 'Start'}
+
+
+
+} \ No newline at end of file diff --git a/src/apps/style.css b/src/apps/style.css new file mode 100644 index 0000000..f43be4e --- /dev/null +++ b/src/apps/style.css @@ -0,0 +1,5 @@ +@import 'tailwindcss'; + +.low-energy-spin { + animation: 2.5s linear 0s infinite normal forwards running spin; +} \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 3e848df..637680d 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,6 +1,6 @@ --- // import { query } from '@/modules/query.ts'; -console.log('Hello from index.astro'); +import { VadVoice } from '../apps/VadVoice'; import '../styles/global.css'; --- @@ -8,40 +8,9 @@ import '../styles/global.css'; My Homepage - -

Welcome to my website!

-
-
- - + +
+ +