功能优化 #54
@@ -18,10 +18,12 @@ ai:
|
|||||||
provider: mimo
|
provider: mimo
|
||||||
model: mimo-v2.5-asr
|
model: mimo-v2.5-asr
|
||||||
endpoint: "https://api.xiaomimimo.com/v1"
|
endpoint: "https://api.xiaomimimo.com/v1"
|
||||||
|
api_key: "sk-c3jhv58rr5djhxw398w2rrij5tfpnpdgxqq1bojagshzviah"
|
||||||
llm:
|
llm:
|
||||||
provider: dashscope
|
provider: dashscope
|
||||||
model: qwen3-vl-plus
|
model: qwen3-vl-plus
|
||||||
endpoint: "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
endpoint: "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
api_key: "sk-ws-H.REHELLY.C4s3.MEUCIQCRee37XWEKp2szaxVLFDtR1rxNNsf372zMvCR0Xl6UvQIgZgvhRTvaa1FmhbCQJgaHu4Jny29AQkn01-3hX9CWBOg"
|
||||||
timeout: 30
|
timeout: 30
|
||||||
tts:
|
tts:
|
||||||
provider: Xiaomi MiMo
|
provider: Xiaomi MiMo
|
||||||
@@ -29,6 +31,7 @@ ai:
|
|||||||
voice: alloy
|
voice: alloy
|
||||||
speed: 1.0
|
speed: 1.0
|
||||||
endpoint: "https://token-plan-cn.xiaomimimo.com/v1"
|
endpoint: "https://token-plan-cn.xiaomimimo.com/v1"
|
||||||
|
api_key: "tp-c9e7scwfx94qvqyhpnahnw8uaiya01za2qzvg4xe24rp3xiv"
|
||||||
timeout: 5
|
timeout: 5
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
|
|||||||
4
frontend/.gitignore
vendored
4
frontend/.gitignore
vendored
@@ -12,6 +12,10 @@ dist
|
|||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
|
||||||
|
# VAD 静态资源(从 node_modules 自动复制)
|
||||||
|
public/silero_vad_*.onnx
|
||||||
|
public/vad.worklet.bundle.min.js
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ export function useVAD(options?: VADOptions) {
|
|||||||
getStream: () => Promise.resolve(stream),
|
getStream: () => Promise.resolve(stream),
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
model: "legacy",
|
model: "legacy",
|
||||||
|
// 指向 node_modules 中的 WASM 文件(由 Vite 中间件提供)
|
||||||
|
onnxWASMBasePath: "/node_modules/onnxruntime-web/dist/",
|
||||||
|
|
||||||
onSpeechStart: () => {
|
onSpeechStart: () => {
|
||||||
setIsSpeaking(true);
|
setIsSpeaking(true);
|
||||||
|
|||||||
@@ -1,7 +1,52 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
const ortDistDir = path.resolve(__dirname, 'node_modules/onnxruntime-web/dist')
|
||||||
|
const vadDistDir = path.resolve(__dirname, 'node_modules/@ricky0123/vad-web/dist')
|
||||||
|
const publicDir = path.resolve(__dirname, 'public')
|
||||||
|
|
||||||
|
// 需要复制到 public 的静态资源
|
||||||
|
const staticFiles = [
|
||||||
|
{ src: vadDistDir, name: 'silero_vad_legacy.onnx' },
|
||||||
|
{ src: vadDistDir, name: 'silero_vad_v5.onnx' },
|
||||||
|
{ src: vadDistDir, name: 'vad.worklet.bundle.min.js' },
|
||||||
|
]
|
||||||
|
|
||||||
// https://vite.dev/config/
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [
|
||||||
|
react(),
|
||||||
|
{
|
||||||
|
name: 'serve-vad-assets',
|
||||||
|
// 1. 启动时将 VAD 模型/工作线程复制到 public
|
||||||
|
configResolved() {
|
||||||
|
for (const { src, name } of staticFiles) {
|
||||||
|
const dest = path.join(publicDir, name)
|
||||||
|
if (!fs.existsSync(dest)) {
|
||||||
|
fs.copyFileSync(path.join(src, name), dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 2. 中间件拦截所有 WASM 相关请求,从原始路径提供文件
|
||||||
|
configureServer(server) {
|
||||||
|
server.middlewares.use((req, res, next) => {
|
||||||
|
const url = req.url?.split('?')[0] ?? ''
|
||||||
|
// 匹配任意路径下的 ort-wasm 文件(包括 .vite/deps/ 和根路径)
|
||||||
|
const wasmMatch = url.match(/\/(ort-wasm-simd-threaded\.(mjs|wasm))$/)
|
||||||
|
if (wasmMatch) {
|
||||||
|
const fileName = wasmMatch[1]
|
||||||
|
const filePath = path.join(ortDistDir, fileName)
|
||||||
|
if (fs.existsSync(filePath)) {
|
||||||
|
res.setHeader('Content-Type', fileName.endsWith('.wasm') ? 'application/wasm' : 'application/javascript')
|
||||||
|
res.setHeader('Cache-Control', 'no-cache')
|
||||||
|
res.end(fs.readFileSync(filePath))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user