problem of running speechSynthetiser on aspx page

marc-antoine yonga 81 Reputation points
2021-10-15T14:57:19.683+00:00

Hello,

I've got a problem of running System.Speech.Synthesis.SpeechSynthetiser on aspx page. on a computer with windows 10 installation the control is operationnal but on a server with windows vista the same program with the same aspx and aspx.cs pages, the control is not operational. the page running on a site IIS (http://testpro0.jicixipi.net). I put the option Async to true to the page but the loading of page is blocking or there is no sound output.

code :
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
synthesizer.SetOutputToDefaultAudioDevice();
synthesizer.Volume = 100;
synthesizer.Speak("Hello World");
//synthesizer.SpeakAsync("bonjour tout le monde, comment allez vous ? êtes vous partie pour une nouvelle partie de bon et joyeux coeur.");

Thanks you for your solution.

Marc-Antoine

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,388 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,248 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 25,471 Reputation points Microsoft Vendor
    2021-10-19T05:28:23.197+00:00

    Hi @marc-antoine yonga ,
    If it is not asynchronous when setting Async = true, then it will be blocked.
    For how to use asynchronous methods, you can refer to:
    https://learn.microsoft.com/en-us/aspnet/web-forms/overview/performance-and-caching/using-asynchronous-methods-in-aspnet-45
    Besides, the ASP.NET application can’t have the sufficient permission to access Speech Synthesis.
    They are only useful on the OS which is hosting the application. In Request/ Response architecture(as web is) you can only write something to the browser and nothing much.
    While in testing, the server and client are the same, if you got this to work and deployed it as a site, the C# code, running on the server, would cause the server to speak,and not the client machine. Please note this.
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. AgaveJoe 26,191 Reputation points
    2021-10-15T17:55:57.897+00:00

    The code behind runs on the web server not the client machine. the design seems to work as expected during development because your development machine is both the server and the client. Once deployed to the actual web server only people in server room can hear the sounds - only if the server has speakers and a sound card.


  2. marc-antoine yonga 81 Reputation points
    2021-10-20T02:30:57.54+00:00

    hello,

    finaly, i research on the net and i'm trying to used speechsynthesis of or by javascript. it's interessant by the client beside.

    truly yours.

    0 comments No comments

  3. Ivan 1 Reputation point
    2021-10-23T15:14:25.427+00:00

    hello, I had a lot of time spent with text-to-speech in c#. I know about Microsoft-Agent, and am sure it can run in browser (at least in Internet Explorer). Though, it is kind of old technology, and not really much supported now. Instead, there is the project doubleagent.sourceforge.net - DoubleAgent, which fixes running issues on newver MS Windows OSes. So, if you want user to have text-to-speech on page, I'ld do this:
    create .aspx page )WebForms project).
    add there Double Agent (DLL), and probably drag-and-drop some component to aspx page (I didn't try, but hope it is similar to WinForms and should work).
    place some button on aspx page. double click it and add function to activate that double agent (or maybe even ms-agent) on aspx page. if browser supports it (user controls like double agent in browser) it will show and run.
    the issue here, problem is that some bad guys (hackers) used to misuse this feature of custom controls in aspx pages (like in general all those virus writers for web for whatever). so there can be some prblems to make it run in some browsers. but I think it should work at least for MS browser (now they call it edge). not sure about support for this for Chrome, Opera/Vivaldi, Firefox etc (maybe firefox is more advanced for this).
    Also, I played with text-to-speech in Unity3d game engine. I used "FinalMarco text to speech". maybe it can also work for you, but for Unity TTS on web-page it maybe a bit uneasy to do. first try MSagent/DoubleAgent etc. if not enough you can add Unity3d TTS, but they also rely on common MS Win TTS features/DLLs

    0 comments No comments