VBA - MS Access - Text to Speech - Other Language (1 Viewer)

IGB

New member
Local time
Today, 13:13
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

..forever waiting... waiting for jellybean!
Local time
Today, 20:13
Joined
May 7, 2009
Messages
19,169
aside from Zira (female voice), i have David (Male voice).
both speak english only.
 

isladogs

MVP / VIP
Local time
Today, 12:13
Joined
Jan 14, 2017
Messages
18,186
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, 13:13
Joined
Sep 9, 2020
Messages
6
isladogs,
Can you make Frank talking in access?
 

isladogs

MVP / VIP
Local time
Today, 12:13
Joined
Jan 14, 2017
Messages
18,186
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, 13:13
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

MVP / VIP
Local time
Today, 12:13
Joined
Jan 14, 2017
Messages
18,186
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

MVP / VIP
Local time
Today, 12:13
Joined
Jan 14, 2017
Messages
18,186
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

MVP / VIP
Local time
Today, 12:13
Joined
Jan 14, 2017
Messages
18,186
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, 13:13
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
Today, 05:13
Joined
Mar 14, 2017
Messages
8,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, 13:13
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, 12:13
Joined
Jul 9, 2003
Messages
16,244
This is vb6, thought it may offer some insight:-

 

Isaac

Lifelong Learner
Local time
Today, 05:13
Joined
Mar 14, 2017
Messages
8,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:

isladogs

MVP / VIP
Local time
Today, 12:13
Joined
Jan 14, 2017
Messages
18,186
I just rediscovered this thread one year on and I now know the answer to the issue described by the OP.
There are two types of voice available and only a few are automatically available to all applications.
However you can make all voices available in Access by a simple registry fix as I discovered when I had the same issues as you

For full details of the registry fix and a working app, see Translate & Speak | Access World Forums (access-programmers.co.uk)
Hopefully it is still of use to the OP
 

Users who are viewing this thread

Top Bottom