MatthewSloyan / final-year-applied-project-and-minor-dissertation

Conflict resolution application built in Unity for Virtual Reality. Azure speech services are used along with an AIML chatbot, a flask server and a MongoDB database to provide a cost-effective and realistic approach to training.
1 stars 2 forks source link

Lag when using Azure Text to Speech (Sometimes) #7

Closed MatthewSloyan closed 4 years ago

MatthewSloyan commented 4 years ago

From testing the game can hang sometimes until it returns a response from the speech service.

MatthewSloyan commented 4 years ago

From research I found that "synthesizer.SpeakTextAsync(inputText)" blocks until the task is complete, which was causing the game to hang until the speech service returned. With slow internet, this hang could be a few seconds. To solve this I have implemented a task which starts a Coroutine. This waits until the result from Azure is returned. From multiple playtests this seems to have fixed the issue but it will needed to be tested on the Oculus Quest this week to confirm.

Code was adapted from: https://stackoverflow.com/questions/57897464/unity-freezes-for-2-seconds-while-microsoft-azure-text-to-speech-processes-input