Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions frontend/src/components/Result.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ReactMarkdown from 'react-markdown';
import { useRef } from 'react';
import { useRef, useState } from 'react';

const Result = ({ data }) => {
const utteranceRef = useRef(null);
const [readingAloud, setReadingAloud] = useState(false);

const downloadSummary = () => {
const element = document.createElement('a');
Expand All @@ -20,6 +21,15 @@ const Result = ({ data }) => {
}
utteranceRef.current = new window.SpeechSynthesisUtterance(data.summary);
window.speechSynthesis.speak(utteranceRef.current);
setReadingAloud(true);
};

const stopDictation = () => {
if (utteranceRef.current) {
window.speechSynthesis.cancel();
utteranceRef.current = null;
}
setReadingAloud(false);
};

return (
Expand All @@ -35,7 +45,9 @@ const Result = ({ data }) => {
</div>
<div style={{ marginTop: 20, display: 'flex', gap: 16 }}>
<button onClick={downloadSummary}>Download Summary</button>
<button onClick={readAloud}>🔊 Read Aloud</button>
<button onClick={readingAloud ? stopDictation : readAloud}>
{readingAloud ? '🔇 Stop Dictation' : '🔉 Read Aloud'}
</button>
</div>
</div>
);
Expand Down