Text-To-Speech with Windows 10 IoT Core & UWP on Raspberry Pi Part 2

In my previous post, I've written about using Raspberry Pi running Windows 10 IoT Core for Text-To-Speech services for my smart home. As I've mentioned in that post, I have speakers in two floors wired to an amplifier, connected to a Raspberry Pi. The thing is that each of the speakers is wired to its own audio channel - ground floor speaker is wired to the left and 1st floor speaker is wired to the right channel. It may not be what you'd call a true stereo when listening to music, but it plays a big deal with speech running through the house. With such wiring, I can target the floor I want to convey the speech through, exclusively or with subtle mix, e.g. 100% volume to ground floor and only 10% to 1st floor (it's basically how audio balancing works). This basically lets me cover these use cases and more:

  • Want to call your children that are playing in their rooms upstairs, to lunch? Use 1st floor speaker.
  • Somebody at the door? Send the message to upstairs and ground floor speakers equally.
  • Late at night, kids are sleeping? Maybe use ground floor speakers at full and upstairs speakers at a minimum?
  • Etc...

Scenarios are limitless. And the MediaPlayer class from my previous example offers just what I needed to implement this - audio balance. You can simply set the balance prior to playing your audio, like this:

public async Task SayAsync(string text, double balance)
{
    speechPlayer.AudioBalance = balance;
    using (var stream = await speechSynthesizer.SynthesizeTextToStreamAsync(text))
    {
        speechPlayer.Source = MediaSource.CreateFromStream(stream, stream.ContentType);
    }
    speechPlayer.Play();
}
This code is from my previous blog post, with additional parameter for setting the AudioBalance property prior to playing the synthesized speech.

Playing speech remotely

Of course the real fun begins when you're able to control your audio player remotely, e.g. from an application or even web browser. To achieve this, I have put together a simple "web server" that runs as a background service on Windows 10 IoT Core. I've used the SimpleWebServer from IoTBlockly code sample as a base for my own implementation of a "poor man's Web API server", just trying to simulate controllers, etc. I won't go into that code as it's very hacky, absolutely not production ready, complete or even tested, but it appears to work OK for my current needs. Full source code I've used for this blog post is included in my sample project; I'm only listing the part that controls the speech here:

internal class SayController : Controller
{
    private readonly SpeechService _speechService;
    public SayController(SpeechService speechService)
    {
        _speechService = speechService;
    }
    public async Task<WebServerResponse> Get(string text, string floor)
    {
        if (string.IsNullOrEmpty(floor)) { await _speechService.SayAsync(text, 0) } else if (floor.ToLower() == "up")         {
            await _speechService.SayAsync(text, -1);
        }
        else
        {
            await _speechService.SayAsync(text, 1);
        }
        return WebServerResponse.CreateOk("OK");
    }
}
The code is pretty much self explaining - the first parameter contains the text that should be spoken and the second parameter is the name of the floor the text should be spoken on ("up" sets the audio balance to the left channel and "down" to the right).

With such server set up on Raspberry Pi (the sample is set to listening on port 8085), it's easy for me to make my home say the synthesized text on a specific floor by simply calling its URL:

http://<IP>:8085/say?text=Hello&floor=up

Sample source code for this post is available on GitHub.

Avtor: Anonymous, objavljeno na portalu SloDug.si (Arhiv)

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.

Jamesdob
Jamesdob - ponedeljek, 22. julij 2024

buy ciprofloxacin over the counter: <a href=" https://ciprodelivery.pro/# ">cipro for sale</a> - buy cipro no rx

MichaelBek
MichaelBek - ponedeljek, 22. julij 2024

paxlovid india: <a href=" https://paxloviddelivery.pro/# ">paxlovid india</a> - paxlovid covid http://paxloviddelivery.pro/# Paxlovid buy online cheap doxycycline <a href=http://doxycyclinedelivery.pro/#>doxycycline capsules for sale</a> buy doxycycline canada

ThomasHew
ThomasHew - ponedeljek, 22. julij 2024

https://ciprodelivery.pro/# purchase cipro

MichaelBek
MichaelBek - ponedeljek, 22. julij 2024

cost generic clomid now: <a href=" https://clomiddelivery.pro/# ">can i get generic clomid without insurance</a> - order cheap clomid without rx https://ciprodelivery.pro/# ciprofloxacin 500mg buy online doxycycline 100mg no prescription fast delivery <a href=http://doxycyclinedelivery.pro/#>buy doxycycline 40 mg</a> cost of doxycycline canada

MyronMus
MyronMus - ponedeljek, 22. julij 2024

https://paxloviddelivery.pro/# п»їpaxlovid doxycycline 20 mg cost <a href=https://doxycyclinedelivery.pro/#>doxycycline 100mg buy online</a> doxycycline hyclate 100 mg capsules

ThomasHew
ThomasHew - ponedeljek, 22. julij 2024

https://doxycyclinedelivery.pro/# buy doxycycline cheap

MyronMus
MyronMus - ponedeljek, 22. julij 2024

https://ciprodelivery.pro/# ciprofloxacin generic doxycycline 100 mg cap over the counter <a href=https://doxycyclinedelivery.pro/#>buy doxycycline online no prescription</a> doxycycline 100 capsules

CharlesInvar
CharlesInvar - ponedeljek, 22. julij 2024

where can i buy amoxicillin online: <a href=" http://amoxildelivery.pro/# ">where to buy amoxicillin over the counter</a> - medicine amoxicillin 500mg http://ciprodelivery.pro/# buy generic ciprofloxacin

CharlesInvar
CharlesInvar - ponedeljek, 22. julij 2024

amoxicillin generic: <a href=" https://amoxildelivery.pro/# ">amoxicillin 500 mg without a prescription</a> - amoxicillin 825 mg http://amoxildelivery.pro/# amoxicillin pharmacy price

ThomasHew
ThomasHew - ponedeljek, 22. julij 2024

https://clomiddelivery.pro/# where to buy generic clomid tablets

Jamesdob
Jamesdob - ponedeljek, 22. julij 2024

amoxicillin 500mg cost: <a href=" http://amoxildelivery.pro/# ">amoxicillin 500 mg price</a> - order amoxicillin online

ThomasHew
ThomasHew - nedelja, 21. julij 2024

https://amoxildelivery.pro/# buy amoxicillin 500mg online

Jamesdob
Jamesdob - nedelja, 21. julij 2024

cost generic clomid: <a href=" https://clomiddelivery.pro/# ">order cheap clomid without a prescription</a> - can you get clomid tablets

MyronMus
MyronMus - nedelja, 21. julij 2024

https://clomiddelivery.pro/# buy clomid without rx doxycycline india <a href=https://doxycyclinedelivery.pro/#>buy doxycycline 100mg capsules</a> doxycycline 3626

MyronMus
MyronMus - nedelja, 21. julij 2024

https://amoxildelivery.pro/# purchase amoxicillin online without prescription buy generic ciprofloxacin <a href=https://ciprodelivery.pro/#>ciprofloxacin 500mg buy online</a> cipro for sale

CharlesInvar
CharlesInvar - nedelja, 21. julij 2024

amoxicillin 500 mg capsule: <a href=" https://amoxildelivery.pro/# ">can you buy amoxicillin uk</a> - where can you get amoxicillin https://doxycyclinedelivery.pro/# average price of doxycycline

ThomasHew
ThomasHew - nedelja, 21. julij 2024

https://paxloviddelivery.pro/# paxlovid pill

CharlesInvar
CharlesInvar - nedelja, 21. julij 2024

amoxicillin 500 mg tablet: <a href=" http://amoxildelivery.pro/# ">purchase amoxicillin online without prescription</a> - amoxicillin buy online canada https://amoxildelivery.pro/# can i buy amoxicillin over the counter in australia

MichaelBek
MichaelBek - nedelja, 21. julij 2024

buying cheap clomid without insurance: <a href=" https://clomiddelivery.pro/# ">where can i get cheap clomid without insurance</a> - where to buy generic clomid http://ciprodelivery.pro/# cipro for sale paxlovid generic <a href=https://paxloviddelivery.pro/#>paxlovid covid</a> paxlovid price

DavidCrorp
DavidCrorp - nedelja, 21. julij 2024

top 10 pharmacies in india: <a href=" https://indiapharmast.com/# ">cheapest online pharmacy india</a> - world pharmacy india

Michaeltep
Michaeltep - nedelja, 21. julij 2024

indian pharmacies safe: <a href=" http://indiapharmast.com/# ">top 10 online pharmacy in india</a> - Online medicine home delivery

EdwardVeW
EdwardVeW - nedelja, 21. julij 2024

https://indiapharmast.com/# india pharmacy mail order

EdwardVeW
EdwardVeW - nedelja, 21. julij 2024

http://canadapharmast.com/# canadian pharmacy ltd

MerlinRagma
MerlinRagma - nedelja, 21. julij 2024

certified canadian pharmacy: <a href=" http://canadapharmast.com/# ">canadian pharmacy world</a> - canada pharmacy reviews http://canadapharmast.com/# canada pharmacy reviews mexico drug stores pharmacies <a href=https://foruspharma.com/#>п»їbest mexican online pharmacies</a> medicine in mexico pharmacies

Michaeltep
Michaeltep - nedelja, 21. julij 2024

Online medicine home delivery: <a href=" https://indiapharmast.com/# ">reputable indian online pharmacy</a> - best india pharmacy

Charleskic
Charleskic - nedelja, 21. julij 2024

top online pharmacy india <a href=https://indiapharmast.com/#>п»їlegitimate online pharmacies india</a> pharmacy website india

DavidCrorp
DavidCrorp - nedelja, 21. julij 2024

buy prescription drugs from india: <a href=" https://indiapharmast.com/# ">india pharmacy mail order</a> - cheapest online pharmacy india

DavidCrorp
DavidCrorp - sobota, 20. julij 2024

medicine in mexico pharmacies: <a href=" http://foruspharma.com/# ">mexico drug stores pharmacies</a> - buying prescription drugs in mexico

Michaeltep
Michaeltep - sobota, 20. julij 2024

buying prescription drugs in mexico: <a href=" https://foruspharma.com/# ">buying prescription drugs in mexico online</a> - buying prescription drugs in mexico online

EdwardVeW
EdwardVeW - sobota, 20. julij 2024

http://foruspharma.com/# mexico drug stores pharmacies

EdwardVeW
EdwardVeW - sobota, 20. julij 2024

http://canadapharmast.com/# safe canadian pharmacy

Charleskic
Charleskic - sobota, 20. julij 2024

reputable mexican pharmacies online <a href=http://foruspharma.com/#>mexico pharmacies prescription drugs</a> buying prescription drugs in mexico online

DavidCrorp
DavidCrorp - sobota, 20. julij 2024

mexican mail order pharmacies: <a href=" https://foruspharma.com/# ">reputable mexican pharmacies online</a> - mexican border pharmacies shipping to usa

Michaeltep
Michaeltep - sobota, 20. julij 2024

online pharmacy india: <a href=" http://indiapharmast.com/# ">mail order pharmacy india</a> - top online pharmacy india

Charleskic
Charleskic - sobota, 20. julij 2024

india online pharmacy <a href=https://indiapharmast.com/#>pharmacy website india</a> Online medicine order

Michaeltep
Michaeltep - sobota, 20. julij 2024

cheapest online pharmacy india: <a href=" http://indiapharmast.com/# ">cheapest online pharmacy india</a> - reputable indian online pharmacy

DavidCrorp
DavidCrorp - sobota, 20. julij 2024

indianpharmacy com: <a href=" https://indiapharmast.com/# ">п»їlegitimate online pharmacies india</a> - world pharmacy india

Charleskic
Charleskic - sobota, 20. julij 2024

mexico drug stores pharmacies <a href=http://foruspharma.com/#>mexico pharmacy</a> mexican online pharmacies prescription drugs

DavidCrorp
DavidCrorp - sobota, 20. julij 2024

canada drugs online reviews: <a href=" https://canadapharmast.com/# ">pharmacy canadian</a> - pharmacy in canada

MerlinRagma
MerlinRagma - sobota, 20. julij 2024

mexico drug stores pharmacies: <a href=" https://foruspharma.com/# ">mexican online pharmacies prescription drugs</a> - mexico drug stores pharmacies https://canadapharmast.com/# canadian pharmacy buy medicines online in india <a href=http://indiapharmast.com/#>world pharmacy india</a> reputable indian online pharmacy

EdwardVeW
EdwardVeW - sobota, 20. julij 2024

http://canadapharmast.com/# best canadian online pharmacy

EdwardVeW
EdwardVeW - sobota, 20. julij 2024

https://indiapharmast.com/# indian pharmacy online

Michaeltep
Michaeltep - sobota, 20. julij 2024

mexican drugstore online: <a href=" http://foruspharma.com/# ">mexico drug stores pharmacies</a> - pharmacies in mexico that ship to usa

Charleskic
Charleskic - sobota, 20. julij 2024

cheapest online pharmacy india <a href=http://indiapharmast.com/#>world pharmacy india</a> Online medicine order

DavidCrorp
DavidCrorp - sobota, 20. julij 2024

top 10 pharmacies in india: <a href=" http://indiapharmast.com/# ">cheapest online pharmacy india</a> - Online medicine order

Michaeltep
Michaeltep - sobota, 20. julij 2024

mexico pharmacy: <a href=" http://foruspharma.com/# ">п»їbest mexican online pharmacies</a> - buying from online mexican pharmacy

Charleskic
Charleskic - sobota, 20. julij 2024

buying prescription drugs in mexico <a href=https://foruspharma.com/#>mexico drug stores pharmacies</a> best online pharmacies in mexico

HenrySeami
HenrySeami - četrtek, 11. julij 2024

purple pharmacy mexico price list: <a href=" https://cmqpharma.com/# ">mexican pharmacy</a> - buying prescription drugs in mexico