Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file. Take a look

**Warning:** Features marked as *alpha* may change or be removed in a future release without notice. Use with caution.

<!-- ## [Unreleased] -->
## [Unreleased]

### Fixed

#### Navigator

* [#459](https://github.com/readium/swift-toolkit/issues/459) Fixed the stack overflow issue that occurred when running the text-to-speech on an EPUB file with many empty resources.


## [3.0.0-alpha.2]

Expand Down
15 changes: 7 additions & 8 deletions Sources/Navigator/TTS/PublicationSpeechSynthesizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,14 @@ public class PublicationSpeechSynthesizer: Loggable {
/// Loads the utterances for the next publication `ContentElement` item in the given `direction`.
private func loadNextUtterances(_ direction: Direction) async -> Bool {
do {
guard let content = try await publicationIterator?.next(direction) else {
return false
}

let nextUtterances = try tokenize(content)
.flatMap { utterances(for: $0) }
var nextUtterances: [Utterance] = []
while nextUtterances.isEmpty {
guard let content = try await publicationIterator?.next(direction) else {
return false
}

if nextUtterances.isEmpty {
return await loadNextUtterances(direction)
nextUtterances = try tokenize(content)
.flatMap { utterances(for: $0) }
}

utterances = CursorList(
Expand Down