chore: 提示音

This commit is contained in:
DDMeaqua 2024-10-14 15:02:41 +08:00
parent 7475519473
commit f0b9068ddf
3 changed files with 10 additions and 1 deletions

View File

@ -370,7 +370,7 @@ export function ChatAction(props: {
text: string;
icon: JSX.Element;
onClick: () => void;
isListening: boolean;
isListening?: boolean;
}) {
const iconRef = useRef<HTMLDivElement>(null);
const textRef = useRef<HTMLDivElement>(null);
@ -574,7 +574,15 @@ export function ChatActions(props: {
);
}, []);
function playSound(fileName: string) {
const audio = new Audio(fileName);
audio.play().catch((error) => {
console.error("error:", error);
});
}
const startListening = async () => {
playSound("/Recordingstart.mp3");
showToast(Locale.Chat.StartSpeak);
if (speechApi) {
await speechApi.start();
@ -590,6 +598,7 @@ export function ChatActions(props: {
await speechApi.stop();
setIsListening(false);
}
playSound("/Recordingdone.mp3");
document.getElementById("chat-input")?.focus();
};
const onRecognitionEnd = (finalTranscript: string) => {

BIN
public/Recordingdone.mp3 Normal file

Binary file not shown.

BIN
public/Recordingstart.mp3 Normal file

Binary file not shown.