Windows 10 IoT Core is a solid choice for a home automation suite. Take a look at how to use it for texttospeech apps to use in home automation projects. Text to Speech With Windows 1. Io. T Core, UWP, and a Pi. One of the best features Ive found in using Windows 1. Io. T Core on my home Raspberry Pi which is a small, inexpensive piece of hardware is that it can do voice synthesis very well i. While Windows developers could develop applications with this same functionality for quite a long time, I was still overwhelmed when I saw such small device say anything I ordered it to. It currently may not support all the options and voices older platforms do, but its more than enough for scenarios like home automation, notifications, etc. The fact that Windows 1. Io. T Core even supports Cortana means Microsoft has big plans for Io. T Core and voice recognition and synthesis. When building my house a few years ago, I put in a pair of audio cables going to both of my two floors, to be later able to install two small but powerful speakers into a central ceiling of each floor. Its a private little whole house audioambient music system, if you will. Ive plugged them into an amplifier installed in my utility room and connected to a Raspberry Pi running Windows Io. T Core. Sure, its all possible and doable wireless as well, but Id still trust wired installations over wireless, so if given a chance, Id pick wires anytime. Windows 1. 0 Io. T Core. So why Windows Io. T Core Just because it could run Windows Universal apps where speech synthesis was supported and I already know UWP very well and have worked with the API several times in the past it was a perfect fit. Wiring my whole house audio system to a Raspberry Pi gave me quite a few gains Telling time my house reports the time every hour, on the hour. Ive got quite used to this in the past two years, as its quite useful to keep track of time, especially when youre busy its really nonintrusive. Status notifications I have my whole house wired and interconnected with my smart home installation, so anything important I dont want to miss like low water levels, motion detection, even weather reports can be reported audibly, with detailed spoken reports Door bell I also have my front door bell wired to the Raspberry Pi. It can play any sound or speech when somebody rings a bell Calendar every morning, shortly before its time to go to work or school, I can hear a quick list of activities for that day kids school schedule, any scheduled meetings, after school activities, along with the weather forecast Background music not directly speech related, but a Raspberry Pi with Windows Io. T is also a great music player. Scheduled in the morning for when its time to get up, it quietly starts playing a preset Internet radio station. These are just a few examples of how Im finding Windows 1. Io. T Core speech capabilities on a Raspberry Pi useful, and Im regularly getting ideas for more. For this blog post, however, Id like to focus on showing how easy it is to implement the first case from the above list telling time using Visual Studio to create a background Universal Windows Application and deploying it to a Raspberry Pi running Windows 1. Io. T Core. Development. What Ill be using Visual Studio 2. Raspberry Pi 3 with the latest Windows 1. Io. T Core installed see here for download and instructions on how to install it. Ill also be using the background application Io. T Visual Studio template. To install Io. T Core templates, install the Windows Io. T Core Projects extension using the Extensions and Updates menu option After that possibly restart Visual Studio installing may also take some time for additional downloads, create a new Io. T project File New Project Select the Windows Io. T Core template group on the left and pick the only template in that group Background Application Io. T. Enter a project name and click OK to create the project. After the project is created, add the Background. Task. Deferral line to prevent the background service from exiting too early private Background. Task. Deferral deferral. RunIBackground. Task. Instance task. Instance. Instance. Get. Deferral. Then add the following class internal class Speech. Service. private readonly Speech. Synthesizer speech. Synthesizer. public Speech. Service. speech. Synthesizer Create. Speech. Synthesizer. Speech. Synthesizer Create. Speech. Synthesizer. This is just an internal class that currently does nothing but trying to create a class called Speech. Synthesizer. Speech. Synthesizer. The Speech. Synthesizer class has been around for quite a while and in various implementations across different frameworks. Ill use the one weve currently got on Windows 1. UWP, where it sits under the Windows. Media. Speech. Synthesis namespace. In the above code, somethings missing the code that actually creates the Speech. Synthesizer object. Turns out its not very difficult to do that var synthesizer new Speech. Synthesizer. return synthesizer But theres more First, you can give it a voice you like. To get the list of voices your platform supports, inspect the Speech. Synthesizer. All. Voices static property. To enumerate through all the voices, you can use this foreach var voice in Speech. Synthesizer. All. Voices. Debug. Write. Linevoice. Display. Name voice. Language, voice. Gender. The above code would vary depending on which languages you have installed. For example, the English language only would give you Microsoft David Mobile en US, Male. Microsoft Zira Mobile en US, Female. Microsoft Mark Mobile en US, Male. Also note that not all languages support speech synthesis. To add one or check whats supported, go to Region Language settings and click on the language you want to add speech support for. Heres an example for German As you can see, speech data for German takes about 1. MB to download. Once it is installed, itll appear on the list. If you dont like the default voice, you can either pick another one based on its ID or one of its attributes like gender or language the following code snippet pick the first available female voice or falls back to the default voice if no female voices were found var voice Speech. Synthesizer. All. Voices. Single. Or. Defaulti i. Gender Voice. Gender. Female Speech. Synthesizer. Default. Voice The Default. Voice static property will give you the default voice for the current platform settings in case your query fails. When you have your voice selected, assign it to Speech. Synthesizer synthesizer. Voice voice Whats Coming With the Windows 1. Fall Creators Update. There are additional options you can set to Speech. Synthesizer. Adding to the existing Include. Sentence. Boundary. Metadata and Include. Word. Boundary. Metadata properties, the forthcoming Windows 1. Fall Creators update is looking to add some new, interesting ones Audio. Pitch will allow altering the pitch of synthesized utterances change to higher and lower tones, Audio. Volume will be used to individually control the volume, and Speaking. Rate will alter the tempo of spoken utterances. To try those now, you need to be on the latest Windows 1. Insider Preview Windows 1. Io. T Core version is available from here and using at least Windows SDK build 1. Im running the latest stable Windows 1. Io. T Core version on my home Raspberry Pi so, for now, Ill stick to using the latest stable version of SDK Windows 1. Creators update or build 1. To continue with the code, this is how Ive implemented the Create. Speech. Synthesizer method private static Speech. Synthesizer Create. Speech. Synthesizer. Speech. Synthesizer. Speech. Synthesizer. All. Voices. Single. Or. Defaulti i. Gender Voice. Gender. Female Speech. Synthesizer. Default. Voice. synthesizer. Voice voice. return synthesizer. Speech. It only takes a few lines to actually produce something with Speech. Synthesizer add a Media. Player to the Speech. Service class, along with the new Say. Async method private readonly Speech. Synthesizer speech. Synthesizer. private readonly Media. Player speech. Player. Speech. Service. Synthesizer Create. Speech. Synthesizer. Player new Media. Player. public async Task Say. Asyncstring text. Synthesizer. Synthesize. Text. To. Stream. Asynctext. speech. Player. Source Media. Source. Create. From. Streamstream, stream. Content. Type. speech. Player. Play. Lets take a closer look to the Say. Async method. The Synthesize. Text. To. Stream. Async method does the actual speech synthesis it turns text into a spoken audio stream.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
October 2017
Categories |