forked from akai/readest
Fix TTS might stop at the end of the section (#126)
This commit is contained in:
@@ -23,6 +23,7 @@ import { useFoliateEvents } from '../../hooks/useFoliateEvents';
|
||||
import { useNotesSync } from '../../hooks/useNotesSync';
|
||||
import { getPopupPosition, getPosition, Position, TextSelection } from '@/utils/sel';
|
||||
import { eventDispatcher } from '@/utils/event';
|
||||
import { getBookLangCode } from '@/utils/book';
|
||||
import AnnotationPopup from './AnnotationPopup';
|
||||
import WiktionaryPopup from './WiktionaryPopup';
|
||||
import WikipediaPopup from './WikipediaPopup';
|
||||
@@ -339,7 +340,9 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
|
||||
if (!selection || !selection.text) return;
|
||||
setShowAnnotPopup(false);
|
||||
|
||||
await view!.initTTS();
|
||||
const lang = getBookLangCode(bookData.bookDoc!.metadata.language);
|
||||
const granularity = ['zh', 'ja', 'ko'].includes(lang) ? 'sentence' : 'word';
|
||||
await view!.initTTS(granularity);
|
||||
const ssml = view!.tts.from(selection.range)!;
|
||||
eventDispatcher.dispatch('speak', { bookKey, ssml });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user