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.
28 lines
708 B
TypeScript
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>
|
|
);
|
|
}
|