From c2bf4b4a9a9467c4986b2d05ed640a1978b6aa41 Mon Sep 17 00:00:00 2001 From: Gigi Date: Mon, 20 Oct 2025 22:00:46 +0200 Subject: [PATCH] feat(tts): replace speed dropdown with cycling button --- src/components/TTSControls.tsx | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) 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 - + ) }