Setting things up
It looks like we have all our things in place to get going. However, there are some caveats here: the method SynthesizeTextToStreamAsync is an asynchronous method, hence the name. That means our GenerateVoiceAsync is also asynchronous, a method that should waited for. Every caller in the call tree needs to be aware of this.
The result of all this is that we cannot really use this in the Update() method in the main class like we did before: this is being called 60 times per second. We do not want to instantiate an asynchronous stream 60 times per second. We need to do this earlier.
We can fix this as follows. In our main class (in my application it is called VoiceInHolographicDirectXMain), I add a private field for our
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access