Enable returning Sonos cache wave file if it already exists

This commit is contained in:
2020-05-15 18:55:49 +02:00
parent b2730a35ad
commit c8f4f99687

View File

@@ -22,6 +22,8 @@ class TTS(private val context: Context, initListener: TextToSpeech.OnInitListene
val filename = "tts_$digest.wav"
val file = File(context.cacheDir, filename)
file.takeIf { it.exists() } ?.let { return it }
val uuid = UUID.randomUUID().toString()
val lock = Lock()
tts.setOnUtteranceProgressListener(TTSProcessListener(uuid, lock))