Fix TTS on iOS browsers, closes #172 (#198)

This commit is contained in:
Huang Xin
2025-01-20 01:53:12 +01:00
committed by GitHub
parent ca2a62a921
commit 87069c7308
4 changed files with 106 additions and 67 deletions
@@ -162,13 +162,9 @@ const TTSControl = () => {
throttle(async (rate: number) => {
const ttsController = ttsControllerRef.current;
if (ttsController) {
if (ttsController.state === 'playing') {
await ttsController.stop();
await ttsController.setRate(rate);
await ttsController.start();
} else {
await ttsController.setRate(rate);
}
await ttsController.stop();
await ttsController.setRate(rate);
await ttsController.start();
}
}, 3000),
[],
@@ -179,13 +175,9 @@ const TTSControl = () => {
throttle(async (voice: string) => {
const ttsController = ttsControllerRef.current;
if (ttsController) {
if (ttsController.state === 'playing') {
await ttsController.stop();
await ttsController.setVoice(voice);
await ttsController.start();
} else {
await ttsController.setVoice(voice);
}
await ttsController.stop();
await ttsController.setVoice(voice);
await ttsController.start();
}
}, 3000),
[],