mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 07:36:39 +08:00
fix: remove react-speech-kit.
This commit is contained in:
parent
14e2b8dc31
commit
5b492f587e
@ -1,16 +1,26 @@
|
|||||||
// implement a voice component by speech synthesis to read the text with the voice of the user's choice
|
// 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 * as React from "react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useSpeechSynthesis } from "react-speech-kit";
|
|
||||||
import { IconButton } from "./button";
|
import { IconButton } from "./button";
|
||||||
import VoiceIcon from "../icons/voice.svg";
|
import VoiceIcon from "../icons/voice.svg";
|
||||||
|
|
||||||
const voices = window.speechSynthesis.getVoices();
|
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 }) {
|
export function Voice(props: { text: string }) {
|
||||||
const { speak } = useSpeechSynthesis();
|
|
||||||
const [voice, setVoice] = useState<SpeechSynthesisVoice | null>(null);
|
const [voice, setVoice] = useState<SpeechSynthesisVoice | null>(null);
|
||||||
|
|
||||||
return (
|
return props.text ? (
|
||||||
<div>
|
<div>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -36,5 +46,7 @@ export function Voice(props: { text: string }) {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-markdown": "^8.0.5",
|
"react-markdown": "^8.0.5",
|
||||||
"react-speech-kit": "^3.0.1",
|
|
||||||
"rehype-katex": "^6.0.2",
|
"rehype-katex": "^6.0.2",
|
||||||
"rehype-prism-plus": "^1.5.1",
|
"rehype-prism-plus": "^1.5.1",
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
|
@ -4288,11 +4288,6 @@ react-markdown@^8.0.5:
|
|||||||
unist-util-visit "^4.0.0"
|
unist-util-visit "^4.0.0"
|
||||||
vfile "^5.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:
|
react@^18.2.0:
|
||||||
version "18.2.0"
|
version "18.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
|
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
|
||||||
|
Loading…
Reference in New Issue
Block a user