OpenVoiceOS / ovos-audio

OpenVoiceOS audio output daemon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

playback queue race condition

JarbasAl opened this issue · comments

noticed in easter eggs skill by @mikejgray

self.speak("hello")
self.play_audio("short_sound.wav")

results in sound file playing before the TTS

	ts 0 - emit speak
	ts 1 - handle_speak start executing
	ts 2 - TTS synth start
	ts 3 - emit audio
	ts 4 - handle_audio start executing
	ts 5 - handle_audio queues file
	ts 6 - handle_audio finishes executing
	ts 7 - TTS synth end
	ts 8 - handle_speak queues file
	ts 9 - handle_speak finishes executing

this is my completely unverified diagnosis

theoretically this can also happen with TTS, depending on utterance length and if its cached or not

self.speak("a very very very very very very very very very very long uncached utterance")
self.speak("hello")

may happen that hello gets spoken first, depending on RTF of the TTS plugin

workarounds: pass wait=True to the speak calls in situations where this is likely to happen