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.

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.

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.