简体   繁体   English

如何解决“没有可用的 package espeak”。 尝试在 AWS ec2 linux 上安装 speak 时出错?

[英]How to solve “No package espeak available.” error when trying to install speak on AWS ec2 linux?

The same code is working on my local machine(Windows) but when running the same on AWS Linux after installing Pyttsx3, it is not working.相同的代码在我的本地机器(Windows)上运行,但是在安装 Pyttsx3 后在 AWS Linux 上运行相同的代码时,它不起作用。

    import pyttsx3
    engine = pyttsx3.init() 
    engine.say("I will speak this text")
    engine.runAndWait()

this is the sample code.这是示例代码。 I am new to AWS and LINUX.我是 AWS 和 LINUX 的新手。

And this is the error:这是错误:

Traceback (most recent call last):
  File "/home/ec2-user/st_env/env/lib64/python3.6/site-packages/pyttsx3/__init__.py", line 20, in init
    eng = _activeEngines[driverName]
  File "/usr/lib64/python3.6/weakref.py", line 137, in __getitem__
    o = self.data[key]()
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/st_env/env/lib64/python3.6/site-packages/pyttsx3/__init__.py", line 22, in init
    eng = Engine(driverName, debug)
  File "/home/ec2-user/st_env/env/lib64/python3.6/site-packages/pyttsx3/engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "/home/ec2-user/st_env/env/lib64/python3.6/site-packages/pyttsx3/driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ec2-user/st_env/env/lib64/python3.6/site-packages/pyttsx3/drivers/espeak.py", line 9, in <module>
    from . import _espeak, toUtf8, fromUtf8
  File "/home/ec2-user/st_env/env/lib64/python3.6/site-packages/pyttsx3/drivers/_espeak.py", line 18, in <module>
    dll = cdll.LoadLibrary('libespeak.so.1')
  File "/usr/lib64/python3.6/ctypes/__init__.py", line 421, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libespeak.so.1: cannot open shared object file: No such file or directory
    

EDIT: this OSError: libespeak.so.1: error is there because the espeak engine is not installed on the machine(as suggested by other Stackoverflow post), is there any way to install espeak than sudo yum install espeak?编辑:这个OSError:libespeak.so.1:错误是因为机器上没有安装espeak引擎(正如其他Stackoverflow帖子所建议的那样),有没有比sudo yum install espeak安装espeak的方法?

I have tested the below commands on the amazon ec2 instance with host os Amazon Linux 2 and also tested your sample python code which runs successfully.我已经在主机操作系统Amazon Linux 2的亚马逊ec2实例上测试了以下命令,并且还测试了成功运行的示例 python 代码。

If your host system is Amazon Linux 2 then you can install espeak using the below commands:如果您的主机系统是Amazon Linux 2 ,那么您可以使用以下命令安装espeak

   __|  __|_  )
   _|  (     /   Amazon Linux 2 AMI
  ___|\___|___|

[ec2-user@aws ~]$ rpm -E %{rhel}
7                                            --> as you can see here its based on RHEL 7

[ec2-user@aws ~]$ yum list espeak
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Available Packages
espeak.i686                                                            1.47.11-4.amzn2.0.2                                                          amzn2-core
espeak.x86_64                                                          1.47.11-4.amzn2.0.2                                                          amzn2-core

Here you can see the espeak package is available on Amazon Linux.在这里,您可以看到espeak package 在 Amazon Linux 上可用。 So you need to install it using the below command:因此,您需要使用以下命令安装它:

ec2-user@aws ~]$ sudo yum -y install espeak
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package espeak.x86_64 0:1.47.11-4.amzn2.0.2 will be installed
--> Processing Dependency: libpulse.so.0(PULSE_0)(64bit) for package: espeak-1.47.11-4.amzn2.0.2.x86_64
--> Processing Dependency: libpulse.so.0()(64bit) for package: espeak-1.47.11-4.amzn2.0.2.x86_64
--> Running transaction check
---> Package pulseaudio-libs.x86_64 0:10.0-3.amzn2.0.3 will be installed
--> Processing Dependency: libsndfile.so.1(libsndfile.so.1.0)(64bit) for package: pulseaudio-libs-10.0-3.amzn2.0.3.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: pulseaudio-libs-10.0-3.amzn2.0.3.x86_64
--> Processing Dependency: libsndfile.so.1()(64bit) for package: pulseaudio-libs-10.0-3.amzn2.0.3.x86_64
--> Processing Dependency: libasyncns.so.0()(64bit) for package: pulseaudio-libs-10.0-3.amzn2.0.3.x86_64
--> Processing Dependency: libXtst.so.6()(64bit) for package: pulseaudio-libs-10.0-3.amzn2.0.3.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: pulseaudio-libs-10.0-3.amzn2.0.3.x86_64
--> Processing Dependency: libX11-xcb.so.1()(64bit) for package: pulseaudio-libs-10.0-3.amzn2.0.3.x86_64
...

OR或者

yum localinstall http://mirror.centos.org/centos/7/os/x86_64/Packages/espeak-1.47.11-4.el7.x86_64.rpm

And it will install the package espeak .它将安装 package espeak

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

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