Back to Articles

Building an EPUB Reader with Text-to-Speech on Android Using Kotlin

How to build a native Android e-book reader with EPUB rendering, customizable reading themes, text-to-speech narration, and Room Database for library management.

Building an EPUB Reader with Text-to-Speech on Android Using Kotlin

Reading apps must balance typography, performance, and accessibility. BookShelf delivers all three with native Kotlin rendering.


1. EPUB Parsing and Rendering

EPUBs are essentially ZIP archives containing XHTML chapters. We parse the content.opf manifest and render chapters in a WebView with custom CSS injection:

kotlin
class EpubParser(private val file: File) { fun getChapters(): List<Chapter> { val zip = ZipFile(file) val opf = parseContentOpf(zip) return opf.spine.map { itemRef -> val entry = zip.getEntry(opf.manifest[itemRef]!!.href) Chapter(title = itemRef, content = zip.getInputStream(entry).readText()) } } }

2. Text-to-Speech Integration

Android's built-in TTS engine narrates chapters aloud. Users can adjust speed, pitch, and choose voice variants.


3. Reading Analytics

Room Database tracks pages read, time spent, and daily goals. A progress widget on the home screen shows the current book and completion percentage.


Summary

Native EPUB rendering with TTS and reading analytics creates an accessible, feature-rich book reader that rivals commercial alternatives.