Problemas al ejecutar los servcios de texto a voz de azure en un webform

Orlando José Polo Padilla 0 Reputation points
2023-02-23T19:42:06.99+00:00
Tengo un código hecho en asp.net que convierte texto a voz usando los servicios cognitivos de Azure. si pruebo el código en un winform me trabaja bien. pero si lo ejecuto en un webform me manda el siguente mensaje: 

System.DllNotFoundException: 'No se puede cargar el archivo DLL 'Microsoft.CognitiveServices.Speech.core.dll': No se puede encontrar el módulo especificado.
he buscado por todos lados y no se que me hace falta.
comparto el código en asp.net - c# 

 public void Hablar()
        {
            string speechKey = "ab48e94e9a9c4d5a806c4fa05ded6b5b";
            string speechRegion = "eastus";

            SpeechConfig speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);

            speechConfig.SpeechSynthesisVoiceName = "es-CR-MariaNeural";

            SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer(speechConfig);

            string text = "hola";

            speechSynthesizer.SpeakTextAsync(text);

        }


 protected void Button1_Click(object sender, EventArgs e)
        {
            Hablar();
        }

alguien me puede orientar?. muchas gracias
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,277 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 4,366 Reputation points Microsoft Vendor
    2023-03-02T09:22:19.02+00:00

    Hi @Orlando José Polo Padilla,

    Next time please use English, then you could get help faster. Please re-generate the speeckey when you use higher price plan.

    Why I change the test code, because I am facing other issues related to environment, if you not facing the same issue again, it means it works in your project. If you facing other issues, we very much welcome your new questions.

    I create a folder and copy the Microsoft.CognitiveServices.Speech.core.dll file into the new folder. And select Copy always like below.

    Screenshot 2023-03-02 171559

    We can find Microsoft.CognitiveServices.Speech.core.dll file here.

    Animation

    Here is my test code

    using Microsoft.CognitiveServices.Speech;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace _1183770
    {
        public partial class _Default : Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
            public async void Speak()
            {
                string speechKey = "ab48e94e9a9c4d5a806c4fa05ded6b5b";
                string speechRegion = "eastus";
    
                var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);
                speechConfig.SetSpeechSynthesisOutputFormat(SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm);
    
                var synthesizer = new SpeechSynthesizer(speechConfig, null);
                var result = await synthesizer.SpeakTextAsync("I'm excited to try text-to-speech");
    
                var stream = AudioDataStream.FromResult(result);
                await stream.SaveToWaveFileAsync("E://file" + Guid.NewGuid().ToString() + ".wav");
    
            }
            protected async void btnTest_Click(object sender, EventArgs e)
            {
                // Here's where you do stuff.
                Speak();
            }
        }
    }
    

    Test Result

    Animation


    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.

    Best Regards,

    Jason

    0 comments No comments