Files
ReadViewSDK/Sources/RDSpeechReaderView/README.md
T
2026-07-27 21:43:13 +08:00

47 lines
1.3 KiB
Markdown

# RDSpeechReaderView
`RDSpeechReaderView` provides bounded, on-device text-to-speech playback for
ReadViewSDK readers. It uses `AVSpeechSynthesizer` and does not upload book
content or create exportable audio files.
## Install
```ruby
pod 'RDSpeechReaderView'
pod 'RDPDFReaderView/Speech'
pod 'RDEpubReaderView/Speech'
```
The host app must enable the **Audio, AirPlay, and Picture in Picture**
background mode to continue reading after it enters the background.
## Use with PDF
```swift
let provider = reader.makeSpeechContentProvider()
let speech = RDSpeechReaderController(contentProvider: provider)
try await speech.start()
```
The PDF adapter reads `RDPDFReaderTextRun` values supplied by the host or by
PDFKit. Image-only PDFs require an OCR-backed provider before they can speak.
For automatic page navigation and temporary read-aloud highlighting, create a
PDF session instead:
```swift
let session = reader.makeSpeechSession()
try await session.start(from: 0)
```
## Use with EPUB
```swift
let provider = reader.makeSpeechContentProvider()
let speech = RDSpeechReaderController(contentProvider: provider)
try await speech.start(from: nil)
```
Speech locations use EPUB `href` plus a UTF-16 text offset. They remain stable
when the user changes fonts or page size, unlike screen page numbers.