createTtsSyncMediaTimeline

abstract fun createTtsSyncMediaTimeline(readerDocuments: List<ReaderDocument>, config: TtsSyncMediaTimelineConfiguration, onSuccess: (SyncMediaTimeline) -> Unit, onError: (ColibrioException) -> Unit, progressCallback: (Double) -> Unit = {})

Creates a new TTS SyncMediaTimeline from the specified list of ReaderDocuments. The resulting SyncMediaTimeline can be played using a SyncMediaPlayer.

When creating a TTS SyncMediaTimeline, you must specify:

  • A TTS Synthesizer used for speaking the text contents.

  • A ReaderViewAnnotationLayer used for highlighting the currently spoken text.

TtsSynthesizer

The TtsSynthesizer is responsible for synthesizing text fragments into audio and play it. This framework provides ColibrioTtsSynthesizer which uses android.speech.tts.TextToSpeech.

Highlighting

When playing the timeline, the passed ReaderViewAnnotationLayer will be used to create ReaderViewAnnotation instances for highlighting the current spoken text.

Use TtsSyncMediaTimelineConfiguration.rendererOptions to configure how the highlights should be styled. If no options are specified, the options set using ReaderViewAnnotationLayer.defaultAnnotationOptions will be used.

WARNING: If you don't specify any range styles using TtsSyncMediaTimelineConfiguration.rendererOptions or ReaderViewAnnotationLayer.defaultAnnotationOptions, highlights will be transparent!

Checking if publication supports TTS

You can check if this publication supports TTS by checking if availableSyncMediaFormats contains SyncMediaFormat.CONTENT_BLOCK_TTS.

Failed calls

If the call fails, ownership of TtsSyncMediaTimelineConfiguration.ttsSynthesizer returns to you; see that property for what you must then do with it.

Parameters

readerDocuments
  • The reader documents that should be part of the timeline.

config
  • The TTS SyncMediaTimeline configuration.

onSuccess
onError
  • Called if there was an error creating the timeline.

progressCallback
  • A function called several times indicating the create progress as a value between 0 and 1.


abstract suspend fun createTtsSyncMediaTimeline(readerDocuments: List<ReaderDocument>, config: TtsSyncMediaTimelineConfiguration, progressCallback: (Double) -> Unit = {}): ColibrioResult<SyncMediaTimeline>

Creates a new TTS SyncMediaTimeline from the specified list of ReaderDocuments. The resulting SyncMediaTimeline can be played using a SyncMediaPlayer.

When creating a TTS SyncMediaTimeline, you must specify:

  • A TTS Synthesizer used for speaking the text contents.

  • A ReaderViewAnnotationLayer used for highlighting the currently spoken text.

TtsSynthesizer

The TtsSynthesizer is responsible for synthesizing text fragments into audio and play it. This framework provides ColibrioTtsSynthesizer which uses android.speech.tts.TextToSpeech.

Highlighting

When playing the timeline, the passed ReaderViewAnnotationLayer will be used to create ReaderViewAnnotation instances for highlighting the current spoken text.

Use TtsSyncMediaTimelineConfiguration.rendererOptions to configure how the highlights should be styled. If no options are specified, the options set using ReaderViewAnnotationLayer.defaultAnnotationOptions will be used.

WARNING: If you don't specify any range styles using TtsSyncMediaTimelineConfiguration.rendererOptions or ReaderViewAnnotationLayer.defaultAnnotationOptions, highlights will be transparent!

Checking if publication supports TTS

You can check if this publication supports TTS by checking if availableSyncMediaFormats contains SyncMediaFormat.CONTENT_BLOCK_TTS.

Threading

Call this from the main dispatcher. Called from another dispatcher, the cleanup that runs when the call fails or is cancelled may not reach the reading system, leaving the timeline behind.

Failed and cancelled calls

Ownership of TtsSyncMediaTimelineConfiguration.ttsSynthesizer returns to you; see that property for what you must then do with it.

Cancelling does not abort a timeline the reading system has already started building. Such a timeline may still be created, and you never receive its handle; it is released when the publication is unloaded.

Return

Either ColibrioResult.Success with the created SyncMediaTimeline if the operation is successful, or ColibrioResult.Error if an error occurred while creating the timeline.

Parameters

readerDocuments
  • The reader documents that should be part of the timeline.

config
  • The TTS SyncMediaTimeline configuration.

progressCallback
  • A function called several times indicating the create progress as a value between 0 and 1.