我正在尝试使用Python代码将WIN10文本语音转换从Windows Default更改为英语。
提到了将SetVoice命令与SAPI.Spvoice一起使用,但找不到示例
from win32com.client import Dispatch
Windows_Speak = Dispatch('SAPI.Spvoice')
Windows_Speak.Speak('Tomato')
以上代码将使用Windows默认语言设置,但我需要能够使用Python中的命令更改语言。有什么想法吗?
答案 0 :(得分:0)
尝试一下:
def x_demension(custom_settings, star):
available_x = custom_settings.width - 2*star.rect.width #available space along abscissa axis
count_numbers = int(available_x / (2*star.rect.width)) #quantity of stars throught weight
return count_numbers
def y_demension(custom_settings, star, spaceship):
available_y = custom_settings.height - 2*star.rect.height - spaceship.rect.height #available space along ordinate axis
number_rows = int(available_y / (2*star.rect.height)) #quantity of rows throught height
return number_rows
def create_star(screen, custom_settings, number, row_number, stars):
star = Star(screen, custom_settings) #create an instance of a star
star.rect.x = star.rect.width + 2*star.rect.width * randint(0,number) #coordinate x of a star
x = randint(0, star.rect.x)
star.rect.x = x
star.rect.y = star.rect.height + 2*star.rect.height * randint(0,row_number) #coordinate y of a star
y = randint(0,star.rect.y)
star.rect.y = y
stars.add(star) #added stars
if len(stars) > 50: #limiter of the star adding
stars.remove(star)
else:
stars.add(star)
def starsky(custom_settings, screen, spaceship, stars):
star = Star(custom_settings, screen) #created as an instance of a random star
number_stars = x_demension(custom_settings, star)
number_rows = y_demension(custom_settings, star, spaceship)
for row_number in range(number_rows):
for number in range(number_stars):
create_star(screen, custom_settings, number, row_number, stars)
如果有语音识别,那就玩耍