Back to Blog
Java free tts7/27/2023 Static void OutputSpeechSynthesisResult(SpeechSynthesisResult speechSynthesisResult, string text)Ĭase ResultReason.SynthesizingAudioCompleted:Ĭonsole.WriteLine($"Speech synthesized for text: ") Ĭonsole.WriteLine($"CANCELED: Did you set the speech resource key and region values?") Static string speechRegion = Environment.GetEnvironmentVariable("SPEECH_REGION") Static string speechKey = Environment.GetEnvironmentVariable("SPEECH_KEY") This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION" Replace the contents of Program.cs with the following code. Install the Speech SDK in your new project with the. The Program.cs file should be created in the project directory. Open a command prompt where you want the new project, and create a console application with the. Synthesize to speaker outputįollow these steps to create a new console application and install the Speech SDK. For example, westus.įor more configuration options, see the Xcode documentation. Set SPEECH_REGION to the region of your resource. To set the environment variable for your Speech resource region, follow the same steps. Enter SPEECH_KEY for the Name and enter your Speech resource key for the Value.Under Environment Variables select the plus ( ) sign to add a new environment variable.Select Arguments on the Run (Debug Run) page.For example, follow these steps to set the environment variable in Xcode 13.4.1. Xcodeįor iOS and macOS development, you set the environment variables in Xcode. bash_profile, and add the environment variables: export SPEECH_KEY=your-keyĪfter you add the environment variables, run source ~/.bash_profile from your console window to make the changes effective. export SPEECH_KEY=your-keyĪfter you add the environment variables, run source ~/.bashrc from your console window to make the changes effective. For example, if you are using Visual Studio as your editor, restart Visual Studio before running the example. Import .If you only need to access the environment variable in the current running console, you can set the environment variable with set instead of setx.Īfter you add the environment variables, you may need to restart any running programs that will need to read the environment variable, including the console window. The code for this looks like this: package uk.co. With this in place we can run our Java application, the same application we used in the previous post, and now see we have an additional voice available. To use MBROLA in our Java application we need to set the property “mbrola.base” to the location where the executable MBROLA file is located. Now that the MBROLA files are in place we can turn our attention to our code and make use of these new files. You will end up with a folder for each voice and within the folder the voice-specific files. To install a voice simply extract the contents of the zip file into the same location as the MBROLA executable file. Once the executable file is in place next, we need to install the voices. In my case, I went with C:\mbrola\mbrola.exe. Simply extract the file to your local drive. Surprisingly, we need the DOS base file which is located in the subdirectory “mbr302a”. Now there are two versions of the file contained within the zip file, one is a Windows file and the other is a DOS file. To install MBROLA so we can use it we need to extract the executable file from the zip file and place it on our local drive. Click on each of the US voices (US1, US2, US3) to download the three zip files containing the voices. Once on the page select the “Download” option and then click on “MBROLA binary and voices” and scroll down towards the bottom of the page where the various voices are listed. I was unable to get the British voice to work and as yet I have not tried any of the others. The voices I will use are the three American voices. Next, we need to download some voices to work with our engine. This gives you a zip file with the mbrola.exe file contained within. The MBROLA engine is included with the FreeTTS zip file as a JAR file we are going to downloaded the MBROLA engine as an executable file and can be downloaded from here: External filesĪs has become our habit, before we go too far, we will take a look at the external files needed to complete this section. In this article, we will take a look at increasing the number of voices available to us by adding voices from MBROLA. In the previous post, we wrote a small application to list out all the voices available in our Java FreeTTS speech synthesiser. Welcome to the third in the series on adding speech to a Java application.
0 Comments
Read More
Leave a Reply. |