利用python发音

import sys
from win32com.client import constants
import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
 while 1:
	try:
		s = input('put your world here!')
		if s == "exit speaker":
			break
		speaker.Speak(s)
	except:
		if sys.exc_type is EOFError:
			sys.exit()


也可以发中文,需要装中文包:

微软语音开发包 SpeechSDK51.exe
微软语音开发-语言包 SpeechSDK51LangPack.exe

例子:

import win32com.client
import os
content = '中国!'
sp = win32com.client.Dispatch('SAPI.SpVoice')
voice_list = sp.GetVoices()
voices = dict([(os.path.basename(voice.Id), voice) for voice in voice_list])
sp.Rate = -5
sp.Voice = voices['MSSimplifiedChineseVoice']
sp.Speak(content)


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值