diff --git a/src/WebSocket.js b/src/WebSocket.js index 1612a5a..6de1d75 100644 --- a/src/WebSocket.js +++ b/src/WebSocket.js @@ -4,6 +4,7 @@ import io from "socket.io-client"; import { WS_BASE } from "./config"; import { useDispatch } from "react-redux"; import { setData, setPlugin } from "./coreSlice"; +import { setRecording, setText } from "./voiceSlice"; const WebSocketContext = createContext(null); @@ -26,6 +27,20 @@ function WebSocketProvider({ children }) { }, payload.time); } }); + + socket.on("voice:wakeword", () => { + dispatch(setRecording(true)); + dispatch(setText(null)); + }); + socket.on("voice:record_end", () => { + dispatch(setRecording(false)); + dispatch(setText(null)); + }); + socket.on("voice:utterance", payload => { + dispatch(setRecording(false)); + dispatch(setText(payload.text)); + setTimeout(() => dispatch(setText(null)), 3000); + }); } return (