Skip to content

Commit

Permalink
chore: 提示音
Browse files Browse the repository at this point in the history
  • Loading branch information
DDMeaqua committed Oct 14, 2024
1 parent 7475519 commit f0b9068
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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) => {
Expand Down
Binary file added public/Recordingdone.mp3
Binary file not shown.
Binary file added public/Recordingstart.mp3
Binary file not shown.

0 comments on commit f0b9068

Please sign in to comment.