fix: remove react-speech-kit.

This commit is contained in:
lushevol 2023-03-30 16:14:31 +08:00
parent 14e2b8dc31
commit 5b492f587e
3 changed files with 15 additions and 9 deletions

View File

@ -1,16 +1,26 @@
// implement a voice component by speech synthesis to read the text with the voice of the user's choice
import * as React from "react";
import { useState } from "react";
import { useSpeechSynthesis } from "react-speech-kit";
import { IconButton } from "./button";
import VoiceIcon from "../icons/voice.svg";
const voices = window.speechSynthesis.getVoices();
const speak = ({
text,
voice,
}: {
text: string;
voice?: SpeechSynthesisVoice;
}) => {
if (!text) return;
const utterance = new SpeechSynthesisUtterance(text);
utterance.voice = voice || voices[0];
window.speechSynthesis.speak(utterance);
};
export function Voice(props: { text: string }) {
const { speak } = useSpeechSynthesis();
const [voice, setVoice] = useState<SpeechSynthesisVoice | null>(null);
return (
return props.text ? (
<div>
<IconButton
onClick={() => {
@ -36,5 +46,7 @@ export function Voice(props: { text: string }) {
))}
</select>
</div>
) : (
<></>
);
}

View File

@ -23,7 +23,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^8.0.5",
"react-speech-kit": "^3.0.1",
"rehype-katex": "^6.0.2",
"rehype-prism-plus": "^1.5.1",
"remark-gfm": "^3.0.1",

View File

@ -4288,11 +4288,6 @@ react-markdown@^8.0.5:
unist-util-visit "^4.0.0"
vfile "^5.0.0"
react-speech-kit@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/react-speech-kit/-/react-speech-kit-3.0.1.tgz#8bd936adfe064be1c5a07e2992dfdfd772e80d14"
integrity sha512-MXNOciISanhmnxpHJkBOev3M3NPDpW1T7nTc/eGw5pO9cXpoUccRxZkmr/IlpTPbPEneDNeTmbwri/YweyctZg==
react@^18.2.0:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"