Thought it would be very complicated to include speech in your programs.
As it seems, in it most simplest form it can be done in two lines.
Don't forget to include the System.Speech reference in your References.
Enjoy!
Speech synthesis in .NET, very easy!
using System;
using System.Speech.Synthesis;
namespace Testing
{
class Program
{
static void Main(string[] args)
{
//construct a message to say:
var user = "Danny";
var daypart = string.Empty;
var now = DateTime.Now;
if (now.Hour >= 6 && now.Hour <= 12)
{
daypart = " good morning";
}
else if (now.Hour > 12 && now.Hour <= 18)
{
daypart = " good afternoon";
}
else if (now.Hour > 18 && now.Hour <= 24)
{
daypart = " good evening";
}
var message = "Hello " + user + daypart;
//start to speak
var synth = new SpeechSynthesizer();
synth.Speak(message);
Console.WriteLine(message);
Console.ReadKey();
}
}
}
ddanbe
2,724
Professional Procrastinator
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
darkagn
commented:
Excellent description of garbage collection vs IDisposable
+11
ddanbe
2,724
Professional Procrastinator
Featured Poster
johnrosswrock
0
Light Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
JOSheaIV
119
C# Addict
ddanbe
2,724
Professional Procrastinator
Featured Poster
castajiz_2
35
Posting Whiz
ddanbe
2,724
Professional Procrastinator
Featured Poster
JOSheaIV
119
C# Addict
ddanbe
2,724
Professional Procrastinator
Featured Poster
JOSheaIV
119
C# Addict
Siphokazi_F
0
Newbie Poster
Gilberto_1
0
Newbie Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
kplcjl
17
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.