@huyooo/ai-chat-frontend-react 0.2.12 → 0.2.13
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/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/useVoiceInput.ts +17 -0
package/dist/index.js
CHANGED
|
@@ -2812,6 +2812,7 @@ function resample(audioData, fromSampleRate, toSampleRate) {
|
|
|
2812
2812
|
}
|
|
2813
2813
|
return result;
|
|
2814
2814
|
}
|
|
2815
|
+
var asrWarmupDone = false;
|
|
2815
2816
|
async function setupAudioWorkletCapture(opts) {
|
|
2816
2817
|
const { audioContext, source, chunkSize, onChunk } = opts;
|
|
2817
2818
|
const workletCode = `
|
|
@@ -2894,6 +2895,16 @@ registerProcessor('pcm-capture', PcmCaptureProcessor);
|
|
|
2894
2895
|
}
|
|
2895
2896
|
function useVoiceInput(adapter, config = {}) {
|
|
2896
2897
|
const { sampleRate = 16e3, sendInterval = 200, enablePunc = true, enableItn = true } = config;
|
|
2898
|
+
useEffect10(() => {
|
|
2899
|
+
if (adapter && !asrWarmupDone && typeof adapter.asrWarmup === "function") {
|
|
2900
|
+
asrWarmupDone = true;
|
|
2901
|
+
const timer = setTimeout(() => {
|
|
2902
|
+
adapter.asrWarmup?.().catch(() => {
|
|
2903
|
+
});
|
|
2904
|
+
}, 800);
|
|
2905
|
+
return () => clearTimeout(timer);
|
|
2906
|
+
}
|
|
2907
|
+
}, [adapter]);
|
|
2897
2908
|
const [status, setStatus] = useState15("idle");
|
|
2898
2909
|
const [currentText, setCurrentText] = useState15("");
|
|
2899
2910
|
const [finalText, setFinalText] = useState15("");
|