As you could tell from my previous post, I enjoy fiddling around with the COM automation stuff in LightSwitch. Here's a fun one - using Windows’ built-in SAPI engine to do Text to Speech in three simple steps (for out of browser applications) -
1. Create a button on any screen
2. Add the System.Runtime.InteropServices.Automation reference
3. Add the following code to the button -
partial void MyButton_Execute()
{
using (dynamic ISpeechVoice = System.Runtime.InteropServices.Automation.
AutomationFactory.CreateObject("SAPI.SpVoice"))
{
ISpeechVolume = 100;
ISpeechVoice.Speak("<rate speed=\"0\"><pitch middle=\"0\">Bald is beautiful, baby.");
}
}
That's it - just replace the sample text I included with something more relevant and useful for your users. There's potential to do a number of things with this (perhaps spoken notifications to users when records are updated?), but I use it mostly to have a little fun when the click my "About The App" button.
