SAPI text to speech change language setting in VBA (1 Viewer)

bruceblack

Registered User.
Local time
Today, 14:05
Joined
Jun 30, 2017
Messages
119
Hi everyone!

I'm using the following code to have some text to speech in my database:

Code:
Dim objSpeech As Object
Dim strPhrase As String
Dim intPitch As Integer
Dim intRate As Integer
Set objSpeech = CreateObject("SAPI.SpVoice")
intRate = 1
strPhrase = "Hello World"
intPitch = 1
objSpeech.Speak "<pitch middle = '" & intPitch & "'/>" & strPhrase
Set objSpeech = Nothing

Works great!

But i would like to use a Dutch language to be spoken for Dutch text.
I have no clue how to change these or where to find the settings if possible.

What i did found was the following code for SAPI in Greek, but i dont know how to use it for my vba code above.

Code:
SpVoice voice = new SpVoice();
voice.Speak(
"<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='el-GR'>"
+ "Να ενα κειμενο"
+ "</speak>",
 SpeechVoiceSpeakFlags.SVSFlagsAsync|SpeechVoiceSpeakFlags.SVSFIsXML);
voice.WaitUntilDone(30000);
 

bruceblack

Registered User.
Local time
Today, 14:05
Joined
Jun 30, 2017
Messages
119
Ah cool! Thanks for that. Its useful.

Yet, i cant find anything about changing the language in VBA.
 

isladogs

MVP / VIP
Local time
Today, 14:05
Joined
Jan 14, 2017
Messages
18,209
Hi Bruce

Your Greek example is just for a specific snippet of Greek text

I just experimented with my own TTS example database: https://www.access-programmers.co.uk/forums/showthread.php?t=296135

I typed various snippets of French, German, Italian & Spanish into the textbox & played play. Where the word was recognised in the English dictionary e.g. Je m'appelle, arrivederci) on my PC it was spoken using an English voice.
If not (e.g. Ich) the word was spelt out.

Changing to a different voices will improve the pronunciation, but you will still, I believe, need to change Windows language settings and so load the corresponding language dictionary. Of course, it still won't manage all words if you use a mixture of languages but if all you need is Dutch that won't be an issue

The (not very practical) alternative would be to add all your Dutch words into a custom English dictionary. The pronunciation using an English voice would be fairly awful but perhaps that would be sufficient for you?

Hope that helps
 

bruceblack

Registered User.
Local time
Today, 14:05
Joined
Jun 30, 2017
Messages
119
Hi Isla!
Thanks for your help.

The problem is that i can not set any other language on the windows systems. They NEED to be in English. That's one of the reasons i wanted to try if i could do it with VBA. Because i am able install language packs strangely enough.

Yes, for Dutch users, i will only need Dutch. But i need to be able to switch in the Access application. First i need to know if its possible at all.

On another note, when i do change windows 10 text to speech voice (from a guy to woman) it will do that in windows, but my Access application stays with the default. I know how to change that though.

But there is no point to continue building if i cant have it speaking some Dutch. :)
 

isladogs

MVP / VIP
Local time
Today, 14:05
Joined
Jan 14, 2017
Messages
18,209
Have you tried typing some Dutch into my utility. I would be interested to know the outcome if you have the Dutch dictionary installed.
If still no good, try again using the Dutch voice in case that forces the use of that dictionary.

I also remember having difficulty changing the SAPI voice in Access. Can't remember if I solved it.
Perhaps you could post the code needed
 

Users who are viewing this thread

Top Bottom