@dxos/plugin-transformer 0.13.0 → 0.14.0
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/dist/lib/components.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var DebugInfo = ({ error, isModelLoading, stream, isTranscribing, transcription,
|
|
|
8
8
|
className: "p-4",
|
|
9
9
|
children: [
|
|
10
10
|
error && /* @__PURE__ */ jsxs("div", {
|
|
11
|
-
className: "mb-4 text-
|
|
11
|
+
className: "mb-4 text-error-text",
|
|
12
12
|
children: [
|
|
13
13
|
/* @__PURE__ */ jsx("strong", { children: "Error:" }),
|
|
14
14
|
" ",
|
|
@@ -18,31 +18,31 @@ var DebugInfo = ({ error, isModelLoading, stream, isTranscribing, transcription,
|
|
|
18
18
|
isModelLoading && /* @__PURE__ */ jsxs("div", {
|
|
19
19
|
className: "mb-4",
|
|
20
20
|
children: [/* @__PURE__ */ jsx("div", { children: "Loading model..." }), /* @__PURE__ */ jsx("div", {
|
|
21
|
-
className: "text-sm text-
|
|
21
|
+
className: "text-sm text-fg-muted",
|
|
22
22
|
children: "This may take a few moments"
|
|
23
23
|
})]
|
|
24
24
|
}),
|
|
25
25
|
stream ? /* @__PURE__ */ jsxs("div", { children: [
|
|
26
26
|
/* @__PURE__ */ jsxs("div", {
|
|
27
|
-
className: "mb-2 text-
|
|
27
|
+
className: "mb-2 text-success-text",
|
|
28
28
|
children: [
|
|
29
29
|
/* @__PURE__ */ jsx("strong", { children: "Status:" }),
|
|
30
30
|
" Microphone is active",
|
|
31
31
|
debug && audioLevel && /* @__PURE__ */ jsx("div", {
|
|
32
|
-
className: "mt-2 w-48 h-5 bg-
|
|
32
|
+
className: "mt-2 w-48 h-5 bg-neutral-surface rounded-sm relative",
|
|
33
33
|
children: /* @__PURE__ */ jsx("div", {
|
|
34
|
-
className: "h-full bg-
|
|
34
|
+
className: "h-full bg-success-bg transition-all duration-100 rounded-sm",
|
|
35
35
|
style: { width: `${audioLevel / 255 * 100}%` }
|
|
36
36
|
})
|
|
37
37
|
})
|
|
38
38
|
]
|
|
39
39
|
}),
|
|
40
40
|
isTranscribing && /* @__PURE__ */ jsx("div", {
|
|
41
|
-
className: "mb-2 text-
|
|
41
|
+
className: "mb-2 text-fg-muted",
|
|
42
42
|
children: "Processing audio..."
|
|
43
43
|
}),
|
|
44
44
|
debug && /* @__PURE__ */ jsxs("div", {
|
|
45
|
-
className: "mb-4 text-sm text-
|
|
45
|
+
className: "mb-4 text-sm text-fg-muted space-y-1",
|
|
46
46
|
children: [
|
|
47
47
|
/* @__PURE__ */ jsxs("div", { children: ["Model: ", model] }),
|
|
48
48
|
/* @__PURE__ */ jsx("div", { children: "Sample Rate: 16000 Hz" }),
|
|
@@ -55,12 +55,12 @@ var DebugInfo = ({ error, isModelLoading, stream, isTranscribing, transcription,
|
|
|
55
55
|
transcription && /* @__PURE__ */ jsxs("div", {
|
|
56
56
|
className: "mt-4",
|
|
57
57
|
children: [/* @__PURE__ */ jsx("strong", { children: "Transcription:" }), /* @__PURE__ */ jsx("p", {
|
|
58
|
-
className: "mt-2 p-4 bg-
|
|
58
|
+
className: "mt-2 p-4 bg-group-surface rounded-sm whitespace-pre-wrap",
|
|
59
59
|
children: transcription
|
|
60
60
|
})]
|
|
61
61
|
})
|
|
62
62
|
] }) : /* @__PURE__ */ jsx("div", { children: !isModelLoading && !error && /* @__PURE__ */ jsx("div", {
|
|
63
|
-
className: "text-
|
|
63
|
+
className: "text-fg-muted",
|
|
64
64
|
children: "Microphone is inactive"
|
|
65
65
|
}) })
|
|
66
66
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.mjs","names":[],"sources":["../../src/components/Voice/DebugInfo.tsx","../../src/components/Voice/Voice.tsx"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type FC } from 'react';\n\nexport type DebugInfoProps = {\n error: string;\n isModelLoading: boolean;\n stream: MediaStream | null;\n isTranscribing: boolean;\n transcription: string;\n audioLevel: number;\n gpuInfo: string;\n model: string;\n debug: boolean;\n};\n\nexport const DebugInfo: FC<Partial<DebugInfoProps>> = ({\n error,\n isModelLoading,\n stream,\n isTranscribing,\n transcription,\n audioLevel,\n gpuInfo,\n model,\n debug = false,\n}) => {\n return (\n <div className='p-4'>\n {error && (\n <div className='mb-4 text-
|
|
1
|
+
{"version":3,"file":"components.mjs","names":[],"sources":["../../src/components/Voice/DebugInfo.tsx","../../src/components/Voice/Voice.tsx"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type FC } from 'react';\n\nexport type DebugInfoProps = {\n error: string;\n isModelLoading: boolean;\n stream: MediaStream | null;\n isTranscribing: boolean;\n transcription: string;\n audioLevel: number;\n gpuInfo: string;\n model: string;\n debug: boolean;\n};\n\nexport const DebugInfo: FC<Partial<DebugInfoProps>> = ({\n error,\n isModelLoading,\n stream,\n isTranscribing,\n transcription,\n audioLevel,\n gpuInfo,\n model,\n debug = false,\n}) => {\n return (\n <div className='p-4'>\n {error && (\n <div className='mb-4 text-error-text'>\n <strong>Error:</strong> {error}\n </div>\n )}\n {isModelLoading && (\n <div className='mb-4'>\n <div>Loading model...</div>\n <div className='text-sm text-fg-muted'>This may take a few moments</div>\n </div>\n )}\n {stream ? (\n <div>\n <div className='mb-2 text-success-text'>\n <strong>Status:</strong> Microphone is active\n {debug && audioLevel && (\n <div className='mt-2 w-48 h-5 bg-neutral-surface rounded-sm relative'>\n <div\n className='h-full bg-success-bg transition-all duration-100 rounded-sm'\n style={{ width: `${(audioLevel / 255) * 100}%` }}\n />\n </div>\n )}\n </div>\n {isTranscribing && <div className='mb-2 text-fg-muted'>Processing audio...</div>}\n {debug && (\n <div className='mb-4 text-sm text-fg-muted space-y-1'>\n <div>Model: {model}</div>\n <div>Sample Rate: 16000 Hz</div>\n <div>Format: audio/wav</div>\n <div>Chunk Size: 10 seconds</div>\n <div>GPU: {gpuInfo || 'Not available'}</div>\n <div>Backend: WebGPU</div>\n </div>\n )}\n {transcription && (\n <div className='mt-4'>\n <strong>Transcription:</strong>\n <p className='mt-2 p-4 bg-group-surface rounded-sm whitespace-pre-wrap'>{transcription}</p>\n </div>\n )}\n </div>\n ) : (\n <div>{!isModelLoading && !error && <div className='text-fg-muted'>Microphone is inactive</div>}</div>\n )}\n </div>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useState } from 'react';\n\nimport { log } from '@dxos/log';\n\nimport { useAudioStream, usePipeline } from '#hooks';\n\nimport { DebugInfo } from './DebugInfo.tsx';\n\nexport type VoiceProps = {\n active?: boolean;\n debug?: boolean;\n model?: string;\n};\n\nexport const Voice = ({ active, debug, model = 'Xenova/whisper-base' }: VoiceProps) => {\n const [isTranscribing, setIsTranscribing] = useState(false);\n const [transcription, setTranscription] = useState<string>('');\n\n const {\n transcribe,\n gpuInfo,\n isLoaded: isModelLoaded,\n isLoading: isModelLoading,\n error: pipelineError,\n } = usePipeline({ active, debug, model });\n\n const {\n stream,\n error: audioError,\n audioLevel,\n } = useAudioStream({\n active,\n debug,\n // onAudioData: handleAudioData\n });\n\n const handleAudioData = useCallback(\n async (audioData: Float32Array) => {\n if (!isModelLoaded) {\n return;\n }\n\n if (isTranscribing) {\n return;\n }\n\n setIsTranscribing(true);\n try {\n const result = await transcribe(audioData, {\n sampling_rate: 16000,\n chunk_length_s: 5,\n stride_length_s: 1,\n return_timestamps: false,\n language: 'english',\n });\n\n if (result?.text?.trim()) {\n setTranscription((prev) => prev + ' ' + result.text);\n }\n } catch (err) {\n log.error('transcription error', { err });\n throw err;\n } finally {\n setIsTranscribing(false);\n }\n },\n [transcribe, isTranscribing],\n );\n log.info('handleAudioData', { handleAudioData });\n\n useEffect(() => {\n if (debug) {\n log.info('audio state', {\n hasStream: !!stream,\n audioError,\n audioLevel,\n shouldBeActive: active && isModelLoaded,\n });\n }\n }, [debug, stream, audioError, audioLevel, active, isModelLoaded]);\n\n useEffect(() => {\n if (debug) {\n log.info('transcription state', {\n active,\n isModelLoaded,\n isModelLoading,\n isTranscribing,\n pipelineError,\n });\n }\n }, [active, debug, isModelLoaded, isModelLoading, pipelineError, isTranscribing]);\n\n return (\n <DebugInfo\n error={audioError || pipelineError || undefined}\n isModelLoading={isModelLoading}\n stream={stream}\n isTranscribing={isTranscribing}\n transcription={transcription}\n audioLevel={audioLevel}\n gpuInfo={gpuInfo}\n model={model}\n debug={debug}\n />\n );\n};\n"],"mappings":";;;;;AAkBA,IAAa,aAA0C,EACrD,OACA,gBACA,QACA,gBACA,eACA,YACA,SACA,OACA,QAAQ,YACJ;CACJ,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG,SACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,oBAAC,UAAD,EAAA,UAAQ,SAAc,CAAA;KAAC;KAAE;IACtB;;GAEN,kBACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,OAAD,EAAA,UAAK,mBAAqB,CAAA,GAC1B,oBAAC,OAAD;KAAK,WAAU;KAAwB,UAAA;IAAgC,CAAA,CACpE;;GAEN,SACC,qBAAC,OAAD,EAAA,UAAA;IACE,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA;MACE,oBAAC,UAAD,EAAA,UAAQ,UAAe,CAAA;MAAC;MACvB,SAAS,cACR,oBAAC,OAAD;OAAK,WAAU;OACb,UAAA,oBAAC,OAAD;QACE,WAAU;QACV,OAAO,EAAE,OAAO,GAAI,aAAa,MAAO,IAAI,GAAG;OAChD,CAAA;MACE,CAAA;KAEJ;;IACJ,kBAAkB,oBAAC,OAAD;KAAK,WAAU;KAAqB,UAAA;IAAwB,CAAA;IAC9E,SACC,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA;MACE,qBAAC,OAAD,EAAA,UAAA,CAAK,WAAQ,KAAW,EAAA,CAAA;MACxB,oBAAC,OAAD,EAAA,UAAK,wBAA0B,CAAA;MAC/B,oBAAC,OAAD,EAAA,UAA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