Open padrecedano opened 2 weeks ago
The error message comes from your subclass of SimpleBasePlayer
that requires you to override handleSeek
. If you don't override this you can't either not call a seek command, or the error you posted above is raised.
@marcbaechinger
Is there any example implementation for TTS-based content?
I found a handleSeek
method here but I don't know what to do in the method to seek the TTS content.
I added this implementation at Gradle:
implementation 'androidx.media3:media3-transformer:1.4.1'
But I can't write the method without errors. I'm trying in class TtsPlayerCompose
.
I don't think the transformer library or any Compose related classes are required or make it much simpler for you.
Is there any example implementation for TTS-based content?
Not that I am aware of this.
If you are using a SimpleBasePlayer
then you have to implement this method yourself. I'm not clear why you are using a SimpleBasePlayer
. I assume you are generating audio frames from text locally in your app and feed it to an AudioTrack
? That would explain why you can't just use an ExoPlayer
instance.
If this is the case then a seek operation would be to somehow seek in the audio frames that you are generating and have stored in memory. I don't think we would be able to provide you with general guidance how to achieve this, because this isn't trivial and very much depends on how you are playing the audio frames within the player.
If I'm wrong with this assumption and the TTS service is somewhere on a server, then I'd rather look into using a ProgressiveMediaSource
that loads the media from the server and can be set and played with ExoPlayer. Being able to use ExoPlayer would greatly simplify your task of integrating with a session, because you could just build the session with ExoPlayer.
Another thought that I just had is that you can create a ByteArrayDataSource
that you can use with a ProgressiveMediaSource
. If you generate audio in a format supported by ProgressiveMediaSource
you can put it into the ByteArrayDataSource
that is used by the progressive media source.
What is the media format that your TTS service generates?
Thanks for your interest. I'm not looking for anything too complex. It's about taking large amounts of text and converting it to speech using Android TTS. Also having the possibility to pause, stop, resume the audio and the possibility to advance or rewind by clicking on a progress bar. This is the class I currently have, and it works with XML-based code, but I want to migrate my entire app to Jetpack Compose and I'm stuck at that point.
Android TTS has the ability to create an audio file from a text, but that is not what I am interested in, but rather playing the text directly, without creating an audio.
I'm using SimpleBasePlayer because the only example I found was based on that class.
I am trying to implement a text to speech reader using Android TTS and Media3.
This is a lot of text separated by the dot, as TTS does not support content with more than 4000 characters in a single reading. There is no problem in that regard, the reading is done correctly, but if I try to skip by pressing the seek button or on the progress bar the application fails throwing the following error:
The error is this line in the
SimpleBasePlayer
file:/* pendingOperation= */ handleSeek(mediaItemIndex, positionMs, seekCommand),
This is my code:
TTS
ExoPlayerView
Service