mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Init view TTS with text segmentation granularity (#47)
in order to support more TTS backends This PR also fixes a potential off-by-one error at the end boundary of the segment using `sentence` granularity.
This commit is contained in:
@@ -577,12 +577,12 @@ export class View extends HTMLElement {
|
||||
for (const item of list) this.deleteAnnotation(item)
|
||||
this.#searchResults.clear()
|
||||
}
|
||||
async initTTS() {
|
||||
async initTTS(granularity = 'word') {
|
||||
const doc = this.renderer.getContents()[0].doc
|
||||
if (this.tts && this.tts.doc === doc) return
|
||||
const { TTS } = await import('./tts.js')
|
||||
this.tts = new TTS(doc, textWalker, range =>
|
||||
this.renderer.scrollToAnchor(range, true))
|
||||
this.renderer.scrollToAnchor(range, true), granularity)
|
||||
}
|
||||
startMediaOverlay() {
|
||||
const { index } = this.renderer.getContents()[0]
|
||||
|
||||
Reference in New Issue
Block a user