Home > VB.NET > Make Your Computer Talk with VB.NET Application (and Source Code)

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.

Download SpeakToMe App

Download SpeakToMe App

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")
Categories: VB.NET Tags: , , , , ,
  1. No comments yet.
Comment pages
  1. April 24th, 2020 at 17:56 | #1
  2. April 26th, 2020 at 02:52 | #2
  3. April 26th, 2020 at 05:20 | #3
  4. April 26th, 2020 at 06:42 | #4
  5. April 26th, 2020 at 22:28 | #5
  6. April 27th, 2020 at 06:49 | #6
  7. April 27th, 2020 at 13:30 | #7
  8. April 27th, 2020 at 14:53 | #8
  9. April 27th, 2020 at 23:05 | #9
  10. April 28th, 2020 at 01:58 | #10
  11. April 29th, 2020 at 12:39 | #11
  12. April 29th, 2020 at 15:49 | #12
  13. April 29th, 2020 at 18:20 | #13
  14. April 29th, 2020 at 19:53 | #14
  15. April 30th, 2020 at 02:28 | #15
  16. April 30th, 2020 at 07:40 | #16
  17. April 30th, 2020 at 12:18 | #17
  18. April 30th, 2020 at 12:43 | #18
  19. April 30th, 2020 at 14:01 | #19
  20. April 30th, 2020 at 14:20 | #20
  21. April 30th, 2020 at 16:43 | #21
  22. April 30th, 2020 at 19:39 | #22
  23. April 30th, 2020 at 20:40 | #23
  24. May 1st, 2020 at 02:40 | #24
  25. May 1st, 2020 at 04:00 | #25
  26. May 1st, 2020 at 07:10 | #26
  27. May 1st, 2020 at 08:28 | #27
  28. May 1st, 2020 at 08:43 | #28
  29. May 1st, 2020 at 09:01 | #29
  30. May 1st, 2020 at 11:42 | #30
  31. May 1st, 2020 at 14:44 | #31
  32. May 1st, 2020 at 17:21 | #32
  33. May 1st, 2020 at 19:10 | #33
  34. May 1st, 2020 at 21:01 | #34
  35. May 1st, 2020 at 21:24 | #35
  36. May 2nd, 2020 at 01:32 | #36
  37. May 2nd, 2020 at 01:35 | #37
  38. May 2nd, 2020 at 02:36 | #38
  39. May 2nd, 2020 at 02:46 | #39
  40. May 2nd, 2020 at 05:32 | #40
  41. May 2nd, 2020 at 05:39 | #41
  42. May 2nd, 2020 at 06:25 | #42
  43. May 2nd, 2020 at 06:44 | #43
  44. May 2nd, 2020 at 09:03 | #44
  45. May 2nd, 2020 at 11:58 | #45
  46. May 2nd, 2020 at 13:09 | #46
  47. May 2nd, 2020 at 14:05 | #47
  48. May 2nd, 2020 at 15:28 | #48
  49. May 2nd, 2020 at 17:10 | #49
  50. May 2nd, 2020 at 18:23 | #50
You must be logged in to post a comment.