Reading Text Aloud in Microsoft Access
Want to try something fun?
The following VBA method will read aloud the string that you pass to it:
Sub Speak(Msg As String, Optional Gender As String = "Male")
Dim Vox As Object ' SpeechLib.SpVoice
Set Vox = CreateObject("SAPI.SpVoice") ' New SpeechLib.SpVoice
Set Vox.Voice = Vox.GetVoices("Gender = " & Gender).Item(0)
Vox.Speak Msg
End Sub
The above code uses late binding so there is no need to add References to your project. You can set the voice's gender with the optional Gender parameter.
Here's a short video of the method in action:
I plan on going more in-depth on this topic in future articles, but this should be enough to whet your appetite for now. If you can't wait for those articles–or you really enjoy going down rabbit holes–check out Colin Riddington's Translate & Speak sample database.
External references
Image by Fabio Fabio from Pixabay