Files
chadiapp/components/SpeakButton.tsx
T
X4Lo 1f1d28a34d Add B1 Meister: OeSD B1 exam trainer (German-Arabic)
Next.js app with Hoeren, Lesen, Schreiben, Sprechen, Grammatik and Wortschatz sections, flashcards with spaced repetition, speaking chat, XP/streaks/badges, daily reminders (PWA) and Docker Compose setup for Coolify.
2026-11-05 19:11:46 +00:00

28 lines
708 B
TypeScript

"use client";
import { speak, stopSpeaking } from "@/lib/speech";
import { useState } from "react";
export default function SpeakButton({ text, gender = "f", rate = 0.9, label }: { text: string; gender?: "f" | "m"; rate?: number; label?: string }) {
const [on, setOn] = useState(false);
return (
<button
type="button"
className="btn secondary small"
aria-label="Vorlesen"
onClick={(e) => {
e.stopPropagation();
if (on) {
stopSpeaking();
setOn(false);
return;
}
setOn(true);
speak(text, { gender, rate, onEnd: () => setOn(false) });
}}
>
{on ? "⏹" : "🔊"} {label}
</button>
);
}