SpeechSynthesis GetVoicesAsync problem

0
0

Hi, i need to get the voices supported by the browser.
The Speech Ext object SpeechSynthesis expose an async method called GetVoicesAsync that encapsulate the JavaScript method “getVoices()”.

I’m trying to call this method but code wait forever….

My C# code (note that i’m calling from a syncronous metodh)

var task= this.speechSynthesis.GetVoicesAsync();
task.Wait();
string[] voices = task.Result;

I need the voices lists to change the Voice used in speech syntesis.

Any help is appreciate.

Gabriele.

 

 

  • You must to post comments
0
0

Sample attached. But… getVoices() doesn’t work in the extension. Something may have changed in chrome. Anyway, I have updated the extension too but you have to compile it on your end. Get it from https://github.com/iceteagroup/wisej-extensions. It will be in the next build we distribute.

 

 

  • You must to post comments
0
0

Ciao Luca, can you give me a working sample? I only need to get the lists of installed voices…
Thank you.

  • You must to post comments
0
0

Ciao Gabriele,

task.Wait() blocks so the response doesn’t make it back to the browser and the task will never end. You can use task.ContinueWith(), it will create a new thread out of context so you have put Application.RunInContext(this) inside it.

Or you can use await. Or you can use a callback. Which are basically the same thing. The extension doesn’t expose the GetVoices(callback) but you can achieve it like this.

speechSynthesis.Call("getVoices", (list) => { ... callback code }); // or use a method instead of the lambda

HTH

 

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.