简体   繁体   English

在 python 中使用 Espeak 和 os

[英]Using Espeak with os in python

When I open up my command prompt, i am able to type espeak and then the text i want to be said, however when i try to do this through my python code using os it says当我打开命令提示符时,我可以输入 espeak,然后输入我想说的文本,但是当我尝试使用操作系统通过 python 代码执行此操作时,它说

'espeak' is not recognized as an internal or external command, operable program or batch file.

import os
text = "Apples"
os.system('espeak "{}"'.format(text))

I've tinkered with the code a fair amount but there is not much to tinker我已经对代码进行了相当多的修改,但没有太多需要修改的地方

try /usr/bin/espeak instead of espeak .尝试/usr/bin/espeak而不是espeak That works for my machine.这适用于我的机器。

In order to be sure it works for your host I suggest you open a console and type为了确保它适用于您的主机,我建议您打开一个控制台并输入

type espeak

This will output the absolute path of espeak.这将 output espeak 的绝对路径。 Copy that one into your system command将其复制到您的系统命令中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM