diff --git a/src/components/TTSControls.tsx b/src/components/TTSControls.tsx index 632d93f7..2278eea7 100644 --- a/src/components/TTSControls.tsx +++ b/src/components/TTSControls.tsx @@ -1,7 +1,7 @@ import React from 'react' import { useTextToSpeech } from '../hooks/useTextToSpeech' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faPlay, faPause, faStop } from '@fortawesome/free-solid-svg-icons' +import { faPlay, faPause, faStop, faGauge } from '@fortawesome/free-solid-svg-icons' interface Props { text: string @@ -9,6 +9,8 @@ interface Props { className?: string } +const SPEED_OPTIONS = [0.8, 1, 1.2, 1.4, 1.6] + const TTSControls: React.FC = ({ text, defaultLang, className }) => { const { supported, speaking, paused, @@ -29,6 +31,12 @@ const TTSControls: React.FC = ({ text, defaultLang, className }) => { } } + const handleCycleSpeed = () => { + const currentIndex = SPEED_OPTIONS.indexOf(rate) + const nextIndex = (currentIndex + 1) % SPEED_OPTIONS.length + setRate(SPEED_OPTIONS[nextIndex]) + } + const playLabel = !speaking ? 'Listen' : (paused ? 'Resume' : 'Pause') if (!supported) return null @@ -55,20 +63,15 @@ const TTSControls: React.FC = ({ text, defaultLang, className }) => { Stop - + ) }