Add socket.io event handlers for voice:* messages
This commit is contained in:
parent
2c80c4b279
commit
08e5c2e3d2
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue