尽管Mac OSX拥有可以说的say命令,或者说有什么类似Python的命令? [英] While Mac OSX has the say command to speak, or so to say, is there any command that is similar for Python?

查看:99
本文介绍了尽管Mac OSX拥有可以说的say命令,或者说有什么类似Python的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然Mac OSX 10.11.5(El Capitan)具有"say"命令以系统生成的声音讲话,或者可以这么说,是否有任何类似Python的命令可以在Python中使用?如果使用Subprocess,请说明如何使用.

While Mac OSX 10.11.5 (El Capitan) has the "say" command to speak in a system generated voice, or so to say, is there any command that is similar for Python that can be used in Python? If Subprocess is utilized, please explain on how to use that.

推荐答案

您可以按如下方式使用子流程:

You can use subprocess as follows:

import subprocess

my_message = "hello there"
subprocess.call(["say", my_message])

这篇关于尽管Mac OSX拥有可以说的say命令,或者说有什么类似Python的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆