3

I'm trying to use windows SAPI from python for Text-to-Spech purposes. And I'm totally new with win32com package. With English language everything is ok.

import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak("Hello!")

But for other languages not.

# that code doesn't work
import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak("Привет!")

I googled example on VB which uses "Speech.SpVoice" and it works only with Russian language.(this is what I need to)

CreateObject("Speech.SpVoice").Speak"Привет!"

I tried use "Speech.SpVoice" but in fails

import win32com.client
speaker = win32com.client.Dispatch("Speech.SpVoice")
speaker.Speak("Привет!")
#pywintypes.com_error: (-2147221164, 'Class not registered', None, None)

What the difference between "Speech.SpVoice" and "SAPI.SpVoice"? Why can't I use "Speech.SpVoice" instead of "SAPI.SpVoice" with python and win32com?

Or how can I run VB oneliner without creating vbs file? That will be the solution for me to.

rooltak
  • 33
  • 1
  • 7

1 Answers1

0

I think that your SAPI voice isn't working because it is an English speaking SAPI voice, and you haven't changed to a Russian one. There are several ways of getting Russian voices in SAPI.

The first way is to install a Russian language pack for Windows which can be done if you have an Ultimate or Enterprise version of Windows.

The second way is to install windows speech server voices, and hack the registry so that you can get additional voices in SAPI as seen here.

A third option is to purchase a third party voice.

There are important differences between Speech.SpVoice and SAPI.SpVoice. Even though they have similar usage, they are not the same libraries and will not have the exact same functionality. This touches a little bit on the differences.

Community
  • 1
  • 1
Lesley Gushurst
  • 664
  • 4
  • 15