- Cloned from Aryan-Raj3112/episteme (AGPL-3.0) - Package: com.aryan.reader → org.dueattendant149.bookreader - Application ID: org.dueattendant149.bookreader - Added AGENTS.md with migration plan - Upstream: github.com/Aryan-Raj3112/episteme - Origin: git.dueattendant149.org/Atte149/book-reader
46 lines
1.5 KiB
Kotlin
46 lines
1.5 KiB
Kotlin
package org.dueattendant149.bookreader
|
|
|
|
import org.dueattendant149.bookreader.paginatedreader.TtsChunk
|
|
import org.dueattendant149.bookreader.shared.ReaderTtsReplacementPreferences
|
|
import org.dueattendant149.bookreader.shared.ReaderTtsReplacementRule
|
|
import org.junit.Assert.assertEquals
|
|
import org.junit.Test
|
|
|
|
class TtsReplacementChunkTest {
|
|
@Test
|
|
fun `tts chunk spoken text falls back to original text`() {
|
|
val chunk = TtsChunk(
|
|
text = "Dr. Smith",
|
|
sourceCfi = "epubcfi(/6/2)",
|
|
startOffsetInSource = 12
|
|
)
|
|
|
|
assertEquals("Dr. Smith", chunk.spokenText)
|
|
}
|
|
|
|
@Test
|
|
fun `chunk preparation keeps original text and writes spoken text`() {
|
|
val preferences = ReaderTtsReplacementPreferences(
|
|
globalRules = listOf(
|
|
ReaderTtsReplacementRule(
|
|
id = "dr",
|
|
from = "Dr.",
|
|
to = "Doctor",
|
|
wholeWord = false
|
|
)
|
|
)
|
|
)
|
|
val chunk = TtsChunk(
|
|
text = "Dr. Smith",
|
|
sourceCfi = "epubcfi(/6/2)",
|
|
startOffsetInSource = 12
|
|
)
|
|
|
|
val prepared = listOf(chunk).withTtsReplacements(preferences, "book").single()
|
|
|
|
assertEquals("Dr. Smith", prepared.text)
|
|
assertEquals("Doctor Smith", prepared.spokenText)
|
|
assertEquals("epubcfi(/6/2)", prepared.sourceCfi)
|
|
assertEquals(12, prepared.startOffsetInSource)
|
|
}
|
|
}
|