Make Your Computer Talk with VB.NET Application (and Source Code)
I was playing around with COM objects in Windows and discovered that I could access the SAPI.SpVoice interface and make Microsoft Windows talk to me. Well needless to say I had to rush and develop and application to do just that. I uploaded a simple applicaton which will just say whatever you type in as an argument. For example SpeakToMeConsole.exe Hello World will make your computer speak the words “Hello World.” The part that really amazes me is that the guts of this program is only 2 lines long, and it can even that can reduced down to 1 line if we create an anonymous instance of SAPI.SpVoice object.
The reason I created it as a console application and not a windows app is because I envisioned this program only really only having a valid function when it’s called from another application. Or even better, you want to spook your girlfriend or parents by making their laptop talk to them when it turns on! Whatever your reasons are, enjoy! Oh and let me know how you use this program in the comments.
Here is the complete source code to the above application. Let me know what you think in the comments!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 'This application was developed by Gerardo Lopez and was downloaded from www.brangle.com 'Complete source code is available at: 'http://www.brangle.com/wordpress/2009/08/make-your-computer-talk-with-vb-net-app-source-code/ Module Module1 'We want to make sure we grab any arguments as args so that we speak them Sub Main(ByVal args As String()) 'If there are no arguments UBound will return -1 'Therefore we want to make sure to let the user know how to run the app if 'they don't enter any arguments If UBound(args) > -1 Then 'Generate an empty string, we'll use this to concatenate all of our arguments 'together so we can pass it to the narrator Dim input As String = "" 'Concat all of our arguments together and make sure to put a space in 'between them so the words don't run together For Each arg As String In args input = input + arg + " " Next 'Create an object and gain access to the narrator Dim voice = CreateObject("SAPI.SpVoice") 'Tells the narrator what to say voice.Speak(input) Else 'The is where we tell the user what to say if they didn't enter any arguments Console.WriteLine("No arguments specified") Console.WriteLine("Try this instead: SpeakToMe.exe Hello World") Console.WriteLine(vbCrLf + vbCrLf + "Visit www.brangle.com for other apps") End If End Sub End Module 'The End |
To run this program from the command line, you can type in something like the following:
SpeakToMeConsole.exe Hello World
And here is the beautiful one-liner!
1 | CreateObject("SAPI.SpVoice").Speak("hello from brangle.com") |
Thanks for a marvelous posting! I seriously enjoyed reading it,
you are a great author.I will be sure to bookmark your blog and will often come back later
in life. I want to encourage yourself to continue your great writing,
have a nice evening!
Spot on with this write-up, I honestly feel this website needs much more attention. I’ll
probably be returning to read through more, thanks for the information!
Hi are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started and create my own. Do you need any
html coding knowledge to make your own blog? Any help
would be really appreciated!
Very energetic article, I loved that a lot. Will there be a part 2?
Very nice post. I just stumbled upon your weblog
and wished to say that I’ve truly enjoyed browsing your blog posts.
After all I will be subscribing to your feed and I hope you
write again very soon!
Hi i am kavin, its my first time to commenting anywhere, when i read this paragraph i thought
i could also create comment due to this brilliant post.
Your mode of describing all in this post is truly pleasant, every
one be capable of effortlessly be aware of it, Thanks a lot.
Hi there, I do think your blog may be having browser
compatibility problems. When I take a look at your site in Safari, it looks fine however
when opening in Internet Explorer, it has some
overlapping issues. I just wanted to provide you with a quick
heads up! Apart from that, fantastic blog!
My partner and I stumbled over here by a different web page
and thought I might check things out. I like what I see so now i am following you.
Look forward to looking into your web page yet again.
It’s actually very difficult in this full of activity life to listen news
on Television, therefore I just use web for that purpose,
and obtain the newest news.
Fastidious response in return of this matter
with firm arguments and explaining everything on the topic of
that.
Write more, thats all I have to say. Literally, it seems
as though you relied onn tthe video to make your point.
You clearly know wht youre talking about, why waste your intelligence on just postiing videos to yopur blog when you could be giving us
something enlightening to read?
hello!,I like your writing so much! proportion we communicate more approximately your articlee on AOL?
I nered aan expert iin this house to resolve my problem.
Mayy be that is you! Having a look ahead to see you.
Oh myy goodness! Awesome article dude! Thanks, However I am having issues with ykur
RSS. I don’t understand the reason whhy I can’t subscrdibe to it.
Is there anyone else getting similar RSS problems?
Anybody who knows the solution can you kindly respond?
Thanks!!
I’ve been browsing on-line more than 3 hours today, but I by no means discovered any interessting artkcle like yours.
It is beautiful price sufficient for me. In my
opinion, if all website owners and bloggers made excellent
content as you did, the weeb will likely be a lot more useful than ever before.
That iss realⅼy fascinating, You aree a vеry skilled blogger.
Ӏ’ve joined your feed and looк ahezd tօ searching fοr extra oof your magnificent post.
Additionally, І havе shared уoᥙr web site iin my
social networks
Basically to follow up on the update of this issue on your website and would
really want to let you know how much I appreciated the
time you took to publish this useful post. Within the
post, you spoke on how to seriously handle this problem with all ease.
It would be my pleasure to get some more strategies from your website and come up
to offer other individuals what I have benefited from you.
Thank you for your usual excellent effort.
I’m impressed, I have to admit. Seldom do I come across a blog that’s equally educative and engaging, and let me tell you,
you’ve hit the nail on the head. The issue is something which not enough people are speaking intelligently about.
I’m very happy that I came across this during my hunt for something concerning this.
I’ll immediately grasp your rss feed as I can’t find your email subscription link or newsletter
service. Do you’ve any? Please permit me realize in order that
I may just subscribe. Thanks.
You should be a part of a contest for one of the
best blogs on the internet. I most certainly will highly
recommend this site!