question

20966663 avatar image
0 Votes"
20966663 asked romungi-MSFT commented

text to speech in javascript

Hello,
I'm new to here Azure. And I only want to use the text to speech function with Azure.

I've follow the tour how-to-speech-synthesis to write the code. And everything looks fine. But the broswer only sound up once. I've try to change the config and location of the service but failed still.
what's more, there are no any error in F12. So it confuse me a lot. And don't know what to do.

In Addition, I'm using global Azure in China for free account. the last service has been set to South Korea. Is it problem in net? I'm getting more confused with the code has worked well for once.
PPPPPPPPPPPPPPPPPPPPPPPPPlase help me. Thanks a lot.

here is the code.

 function synthesizeSpeech() {
             const speechConfig = SpeechSDK.SpeechConfig.fromSubscription("***", "koreacentral");
             // Set either the `SpeechSynthesisVoiceName` or `SpeechSynthesisLanguage`.
             speechConfig.speechSynthesisLanguage = "zh-CN"; 
             // speechConfig.speechSynthesisVoiceName = "zh-CN-YunyeNeural";
             const audioConfig=SpeechSDK.AudioConfig.fromDefaultSpeakerOutput();
    
             const synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, audioConfig);
             synthesizer.speakTextAsync(
                 t,
                 result=>{
                     if(result){
                         synthesizer.close();
                         return result.audioData;
                     }
                 },
                 error=>{
                     console.error(error);
                     synthesizer.close();
                 }
             )
         }

t=`some Chinese characters`;


azure-speechazure-text-analytics
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

romungi-MSFT avatar image
0 Votes"
romungi-MSFT answered romungi-MSFT commented

@20966663 I have tried the sample and it seems to work as expected.

195482-image.png

Could you try to use the complete sample referenced above directly?


If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.




image.png (71.6 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, Thank you for your reply.

To be honest, I'm not familiar with Node.js. And I don't have the env either. So I prefer to use other examples.

I tried this example based on your reminder. But there are not many options to set in this example. I can only hear the pronunciation of the English part.

So, I still don't understand. That seems to mean it's not the network, right?


0 Votes 0 ·

@20966663 Use this sample after cloning the repo in your local. Run npm install after navigation to samples/js/browser directory. Open synthesis.html using a browser preferably edge and paste the subscription key of your speech resource in the form, select the region, voice and key in text which you want to convert to speech. I hope this helps!!





0 Votes 0 ·

@20966663 Did the below clarification help you to run the solution to try text to speech synthesis?

0 Votes 0 ·