sur-voice 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.history/package_20260121114101.json +30 -0
- package/.history/package_20260121141349.json +30 -0
- package/.history/src/components/surVoice_20260121134911.vue +393 -0
- package/.history/src/components/surVoice_20260121140739.vue +393 -0
- package/.history/src/components/surVoice_20260121140740.vue +393 -0
- package/.history/src/components/surVoice_20260121140750.vue +393 -0
- package/.history/src/components/surVoice_20260121141112.vue +394 -0
- package/.history/src/components/surVoice_20260121141323.vue +412 -0
- package/.history/src/components/surVoice_20260121141324.vue +412 -0
- package/.history/src/components/surVoice_20260121141338.vue +414 -0
- package/.history/src/components/surVoice_20260121141339.vue +414 -0
- package/.history/src/components/surVoice_20260121141340.vue +414 -0
- package/.history/sur-voice/package_20260121113239.json +27 -0
- package/.history/sur-voice/package_20260121113252.json +27 -0
- package/.history/sur-voice/package_20260121113253.json +27 -0
- package/.history/sur-voice/package_20260121113812.json +30 -0
- package/.history/sur-voice/package_20260121113813.json +30 -0
- package/.history/sur-voice/package_20260121113851.json +30 -0
- package/.history/sur-voice/package_20260121114014.json +31 -0
- package/.history/sur-voice/package_20260121114015.json +31 -0
- package/.history/sur-voice/package_20260121114016.json +31 -0
- package/.history/sur-voice/package_20260121114017.json +31 -0
- package/.history/sur-voice/package_20260121114018.json +31 -0
- package/.history/sur-voice/package_20260121114102.json +30 -0
- package/.history/sur-voice/src/index_20260106155836.ts +18 -0
- package/.history/sur-voice/src/index_20260121113733.ts +18 -0
- package/.history/sur-voice/src/index_20260121113739.ts +18 -0
- package/.history/sur-voice/src/index_20260121113740.ts +18 -0
- package/.history/sur-voice/vite.config_20251126104257.ts +7 -0
- package/.history/sur-voice/vite.config_20260121113441.ts +23 -0
- package/.history/sur-voice/vite.config_20260121113652.ts +41 -0
- package/.history/sur-voice/vite.config_20260121113653.ts +41 -0
- package/.history/sur-voice/vite.config_20260121113700.ts +41 -0
- package/.history/sur-voice/vite.config_20260121113701.ts +41 -0
- package/.history/sur-voice/vite.config_20260121113705.ts +43 -0
- package/.history/sur-voice/vite.config_20260121113706.ts +43 -0
- package/.history/sur-voice/vite.config_20260121113920.ts +43 -0
- package/.history/sur-voice/vite.config_20260121113926.ts +43 -0
- package/.history/sur-voice/vite.config_20260121113927.ts +43 -0
- package/.history/sur-voice/vite.config_20260121113928.ts +43 -0
- package/.history/sur-voice/vite.config_20260121113929.ts +43 -0
- package/.history/sur-voice/vite.config_20260121113930.ts +43 -0
- package/package.json +1 -1
- package/src/components/surVoice.vue +26 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import { resolve } from 'path'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const root = process.cwd()
|
|
7
|
+
function pathResolve(dir: string) {
|
|
8
|
+
return resolve(root, '.', dir)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// https://vite.dev/config/
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
plugins: [vue()],
|
|
14
|
+
build: {
|
|
15
|
+
lib: {
|
|
16
|
+
entry: "./src/index.ts",
|
|
17
|
+
name: "SurVoiceUI",
|
|
18
|
+
fileName: (format) => `sur-voice.${format}.js`,
|
|
19
|
+
},
|
|
20
|
+
rollupOptions: {
|
|
21
|
+
// Ensure external dependencies are not bundled into your library
|
|
22
|
+
external: ["vue"],
|
|
23
|
+
output: {
|
|
24
|
+
globals: {
|
|
25
|
+
vue: "Vue",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
resolve: {
|
|
31
|
+
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.scss', '.css'],
|
|
32
|
+
alias: [
|
|
33
|
+
{
|
|
34
|
+
find: 'vue-i18n',
|
|
35
|
+
replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
find: /\@\//,
|
|
39
|
+
replacement: `${pathResolve('src')}/`
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
})
|
package/package.json
CHANGED
|
@@ -52,12 +52,24 @@ import { ref, watch } from "vue";
|
|
|
52
52
|
import { sha256 } from "js-sha256";
|
|
53
53
|
import Recorder from "@/utils/Recorder";
|
|
54
54
|
|
|
55
|
+
const props = withDefaults(
|
|
56
|
+
defineProps<{
|
|
57
|
+
appKey?: string;
|
|
58
|
+
secret?: string;
|
|
59
|
+
}>(),
|
|
60
|
+
{
|
|
61
|
+
appKey: "", // 3k5jkbo5jsngmjmij7fy77xyrcoud5xkinbaqnik
|
|
62
|
+
secret: "", // 01a1fe93e03bbfb775ad1a6482a130c2
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
55
66
|
const emit = defineEmits<{
|
|
56
67
|
(e: "update:inputText", v: string): void;
|
|
57
68
|
}>();
|
|
58
69
|
|
|
59
70
|
|
|
60
71
|
//!!!!!!!!!!!!!!!!!!!!! 录音(ASR)
|
|
72
|
+
|
|
61
73
|
// 目标:减少从说话到首包文字返回的延迟
|
|
62
74
|
// - 去掉每帧 console.log(会严重阻塞主线程,导致 onmessage 延迟)
|
|
63
75
|
// - 聚合/节流发送(降低 ws.send 频率,让服务端更快开始解码)
|
|
@@ -71,7 +83,9 @@ const DEBUG_ASR = false;
|
|
|
71
83
|
watch(
|
|
72
84
|
inputText,
|
|
73
85
|
(v) => {
|
|
74
|
-
|
|
86
|
+
if(v){
|
|
87
|
+
emit("update:inputText", v);
|
|
88
|
+
}
|
|
75
89
|
},
|
|
76
90
|
{ immediate: true }
|
|
77
91
|
);
|
|
@@ -211,10 +225,19 @@ function enqueueVoiceChunk(chunk: any) {
|
|
|
211
225
|
// STEP 4: 创建 VoiceWS 连接
|
|
212
226
|
const createVoiceWS = () => {
|
|
213
227
|
const tm = +new Date();
|
|
214
|
-
const appKey =
|
|
215
|
-
const secret =
|
|
228
|
+
const appKey = props.appKey;
|
|
229
|
+
const secret = props.secret;
|
|
230
|
+
|
|
231
|
+
console.log('createVoiceWS',appKey,secret) //3k5jkbo5jsngmjmij7fy77xyrcoud5xkinbaqnik 01a1fe93e03bbfb775ad1a6482a130c2
|
|
232
|
+
|
|
233
|
+
if (!appKey || !secret) {
|
|
234
|
+
console.error("缺少 ASR 配置:appKey/secret");
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
216
238
|
const sign = sha256(`${appKey}${tm}${secret}`).toUpperCase();
|
|
217
239
|
|
|
240
|
+
|
|
218
241
|
// 关闭旧连接
|
|
219
242
|
try {
|
|
220
243
|
voiceWs?.close();
|