VBA Access text to speach other language (1 Viewer)

IGB

New member
Local time
Today, 05:53
Joined
Sep 9, 2020
Messages
6
In VBA, I have a buttom, when I click on it, it should give me de spoken text in Dutch of the textbox.

In windows/control panel/speech recognition/text to speach I have two languages (Bart-Dutch / Zira-English), however in VBA I have the following code (for testing), and I only get one language, Zira, the English one. How can I make Bart talking?

Dim i As Long
Dim voc As SpeechLib.SpVoice
Set voc = New SpVoice
Debug.Print voc.GetVoices.Count & " available voices:"
For i = 0 To voc.GetVoices.Count - 1
Set voc.Voice = voc.GetVoices.Item(i)
Debug.Print " " & i & " - " & voc.Voice.GetDescription
voc.Speak "test audio"
Next i


Result: 1 available voices: 0 - Microsoft Zira Desktop - English (United States)
 

arnelgp

error reading drive A:
Local time
Today, 12:53
Joined
May 7, 2009
Messages
10,858
aside from Zira (female voice), i have David (Male voice).
both speak english only.
 

isladogs

CID VIP
Local time
Today, 04:53
Joined
Jan 14, 2017
Messages
14,018
I get different results
Using English UK, I have George, Hazel & Susan. As a test I installed Dutch (Netherlands) and it added Frank who speaks Dutch
 

IGB

New member
Local time
Today, 05:53
Joined
Sep 9, 2020
Messages
6
isladogs,
Can you make Frank talking in access?
 

isladogs

CID VIP
Local time
Today, 04:53
Joined
Jan 14, 2017
Messages
14,018
Ah sorry. I uninstalled it again without testing that...but I doubt it.
However using my test Access TTS app, the voice didn't change when I changed the default English voice

Tested your code above & it won't compile. Looking at the SpeechLib code members, it should be GetVoice not GetVoices.
Tried changing that & got another compile error:
1599823141271.png
 

IGB

New member
Local time
Today, 05:53
Joined
Sep 9, 2020
Messages
6
isaldogs,
actually, the code of the test wasn't the problem, it was the result. In text to Speech, I can choose between two language. But the result of mu debug.print is only one result: 1 available voices: 0 - Microsoft Zira Desktop - English (United States). And it's not Zira that I want, it's Bart.
tekst.png
 

isladogs

CID VIP
Local time
Today, 04:53
Joined
Jan 14, 2017
Messages
14,018
Yes I understood that originally which is why I tried your code to test it...but as I said the code wouldn't run using GetVoices or GetVoice.
What references are listed in your app?
 

isladogs

CID VIP
Local time
Today, 04:53
Joined
Jan 14, 2017
Messages
14,018
I was typing this before I saw your post:

Mystery partly solved. In Windows 10, there are two MS speech library reference. I was using the newer sapi_onecore.dll.
Swopped to the older sapi.dll reference which dates back to Win7 days and your code then runs fine

I added TTS for English USA & Dutch (Belgium) and ended up with 8 voices in all:
1599827917267.png


I set Bart as default then ran your code with this result:

3 available voices:
0 - Microsoft Hazel Desktop - English (Great Britain)
1 - Microsoft David Desktop - English (United States)
2 - Microsoft Zira Desktop - English (United States)

Odd. Only one UK voice & nothing from Holland or Belgium

Next I installed all those languages for Windows display and ran the code again - but got the same result

Perhaps it is necessary to also install those as Office languages? Have you tried that?
 

isladogs

CID VIP
Local time
Today, 04:53
Joined
Jan 14, 2017
Messages
14,018
OK I've now tried changing the preferred Office language to Dutch in Access options.
Ran your code once more and still got the same 3 voices listed as in my last post.
I'm out of ideas... there isn't anything else I can think of changing. Sorry
 

IGB

New member
Local time
Today, 05:53
Joined
Sep 9, 2020
Messages
6
thank you for your efforts
I also downloaded Using the Speak feature with Multilingual TTS
Buth I don't know the effects, nothing happens.
prog.png
 

Isaac

Lifelong Learner
Local time
Yesterday, 20:53
Joined
Mar 14, 2017
Messages
2,738
Kind of an alternative idea to throw in here ... If Access isn't giving you what you want, know that Excel has its own set of Speech options.
3-5 lines of code from Access are capable of firing up Excel, dumping your text into a cell, and using Speech.Speak
...all in the background.

 

IGB

New member
Local time
Today, 05:53
Joined
Sep 9, 2020
Messages
6
Isaac,
I think I downloaded everything needed to make it possible to talk in an other language. (see above)
But which code do I use to make them talk?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 04:53
Joined
Jul 9, 2003
Messages
12,097
This is vb6, thought it may offer some insight:-

 

Isaac

Lifelong Learner
Local time
Yesterday, 20:53
Joined
Mar 14, 2017
Messages
2,738
Isaac,
I think I downloaded everything needed to make it possible to talk in an other language. (see above)
But which code do I use to make them talk?
You mean using excel?

Code:
dim objExcelApp as object, wb as object, ws as object

set objExcelApp=createobject("excel.application")
set wb=objExcelApp.workbooks.add
set ws=wb.sheets(1)
ws.range("A1").value = form_formname.controlname.value
ws.range("A1").Speak

..or, you could fire up excel and the new workbook near the beginning of app startup. then later all you have to code is use getobject(, "excel.application"), set the wb to the name of the known new book (like "set wb=objExcelApp.workbooks("name.xlsx"), and do it that way - that way it would be faster each time you need a speech. but try the above first, see if it's any good for you.
 
Last edited:

Users who are viewing this thread

Top Bottom