@Anna Dřevíkovská I think you should be able to get the duration of the audio file by using the SpeechSynthesisResult.getAudioLength()
method. This will be accessible after the synthesis is complete. This should also give you the exact duration of the audio file generated. I hope this helps!!
If an answer is helpful, please click on or upvote
which might help other community members reading this thread.