how do i solve pyttsx3 error in pydroid3? - python

how to init pyttsx3 in pydroid3
when i tried to init it is raising OSError
can anyone help to solve this code
i tried this code
import pyttsx3
engine = pyttsx3.init()
engine.say("hello world")
engine.runAndWait()
but it raised this error
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pyttsx3/__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/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 "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 2, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pyttsx3/__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pyttsx3/engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pyttsx3/driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pyttsx3/drivers/espeak.py", line 9, in <module>
from . import _espeak, toUtf8, fromUtf8
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pyttsx3/drivers/_espeak.py", line 18, in <module>
dll = cdll.LoadLibrary('libespeak.so.1')
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen failed: library "libespeak.so.1" not found
how to solve this error?
do anyone knows how to solve this error?

To be honest, there is a way around this error, which is to put 'dummy' in init() inside the parentheses. It is not a big deal, since it will still not work, at least it removes the error (I say it in my case).

Related

How to include a file for importing objects in aws lambda that is a custom resource for cdk v2?

I am using python 3.8 as the lambda runtime for my lambda function which I am trying to deploy using cdk v2. This is a lambda as a custom resource that runs every time the stack deploys.
This is the folder structure
/Dynamics/cust_resource/__init__.py
/Dynamics/cust_resource/data_objects.py
/Dynamics/cust_resource/lambda.py
/Dynamics/cust_resource/requirements.txt
/Dynamics/__init__.py
/Dynamics/dyna_stack.py
app.py
This is the lambda code
import os
import boto3
import sys
print('before lambda import')
from data_objects import poco_data
This is how I am creating the function in the stack
cust_res_lambda = _lambda.Function(
self, 'crLambda',
runtime=_lambda.Runtime.PYTHON_3_8,
code=_lambda.Code.from_asset('Dynamics/cust_resource',
bundling=BundlingOptions(
image=_lambda.Runtime.PYTHON_3_8.bundling_image,
command=["bash", "-c", "pip install -r requirements.txt -t /asset-output && cp -au . /asset-output"]
)),
handler='lambda.lambda_handler',
function_name='crlambdaFn',
)
The lambda executes and I see the line before lambda import in cloudwatch logs followed by.
[ERROR] RuntimeError: generator didn't stop after throw()
Traceback (most recent call last):
File "/var/lang/lib/python3.8/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/var/lang/lib/python3.8/imp.py", line 171, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 702, in _load
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/task/lambda.py", line 12, in <module>
from data_objects import poco_data
File "/var/task/data_objects.py", line 1, in <module>
from aws_cdk import (
File "/var/task/aws_cdk/__init__.py", line 1257, in <module>
from ._jsii import *
File "/var/task/aws_cdk/_jsii/__init__.py", line 13, in <module>
import constructs._jsii
File "/var/task/constructs/__init__.py", line 43, in <module>
from ._jsii import *
File "/var/task/constructs/_jsii/__init__.py", line 13, in <module>
__jsii_assembly__ = jsii.JSIIAssembly.load(
File "/var/task/jsii/_runtime.py", line 54, in load
_kernel.load(assembly.name, assembly.version, os.fspath(assembly_path))
File "/var/lang/lib/python3.8/contextlib.py", line 162, in __exit__
raise RuntimeError("generator didn't stop after throw()")
[ERROR] RuntimeError: generator didn't stop after throw() Traceback (most recent call last): File "/var/lang/lib/python3.8/imp.py", line 234, in load_module return load_source(name, filename, file) File "/var/lang/lib/python3.8/imp.py", line 171, in load_source module = _load(spec) File "<frozen importlib._bootstrap>", line 702, in _load File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/var/task/lambda.py", line 12, in <module> from data_objects import poco_data File "/var/task/data_objects.py", line 1, in <module> from aws_cdk import ( File "/var/task/aws_cdk/__init__.py", line 1257, in <module> from ._jsii import * File "/var/task/aws_cdk/_jsii/__init__.py", line 13, in <module> import constructs._jsii File "/var/task/constructs/__init__.py", line 43, in <module> from ._jsii import * File "/var/task/constructs/_jsii/__init__.py", line 13, in <module> __jsii_assembly__ = jsii.JSIIAssembly.load( File "/var/task/jsii/_runtime.py", line 54, in load _kernel.load(assembly.name, assembly.version, os.fspath(assembly_path)) File "/var/lang/lib/python3.8/contextlib.py", line 162, in __exit__ raise RuntimeError("generator didn't stop after throw()")
What does this error mean and how to fix it?

Python : 'Doc2Vec' object has no attribute 'dv'

Thanks for advice, I have edited the question
I meet this: AttributeError: 'Doc2Vec' object has no attribute 'dv'
The error comes from
Traceback (most recent call last):
File "F:\Projects\项目代码\爬虫程序\headline\main.py", line 13, in <module>
execute(["scrapy", "crawl", "head_spider", '-a', 'key='+sys.argv[1]])
File "C:\Python310\lib\site-packages\scrapy\cmdline.py", line 144, in execute
cmd.crawler_process = CrawlerProcess(settings)
File "C:\Python310\lib\site-packages\scrapy\crawler.py", line 290, in __init__
super().__init__(settings)
File "C:\Python310\lib\site-packages\scrapy\crawler.py", line 167, in __init__
self.spider_loader = self._get_spider_loader(settings)
File "C:\Python310\lib\site-packages\scrapy\crawler.py", line 161, in _get_spider_loader
return loader_cls.from_settings(settings.frozencopy())
File "C:\Python310\lib\site-packages\scrapy\spiderloader.py", line 67, in from_settings
return cls(settings)
File "C:\Python310\lib\site-packages\scrapy\spiderloader.py", line 24, in __init__
self._load_all_spiders()
File "C:\Python310\lib\site-packages\scrapy\spiderloader.py", line 51, in _load_all_spiders
for module in walk_modules(name):
File "C:\Python310\lib\site-packages\scrapy\utils\misc.py", line 88, in walk_modules
submod = import_module(fullpath)
File "C:\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "F:\Projects\项目代码\爬虫程序\headline\headline\spiders\head_spider.py", line 6, in <module>
from headline.items import Artical
File "F:\Projects\项目代码\爬虫程序\headline\headline\items.py", line 20, in <module>
model = Doc2Vec.load('D:/pyspace/headline/headline/utils/model3/doc2vec.model')
File "C:\Python310\lib\site-packages\gensim\models\doc2vec.py", line 813, in load
raise ae
File "C:\Python310\lib\site-packages\gensim\models\doc2vec.py", line 807, in load
return super(Doc2Vec, cls).load(*args, rethrow=True, **kwargs)
File "C:\Python310\lib\site-packages\gensim\models\word2vec.py", line 1937, in load
raise ae
File "C:\Python310\lib\site-packages\gensim\models\word2vec.py", line 1930, in load
model = super(Word2Vec, cls).load(*args, **kwargs)
File "C:\Python310\lib\site-packages\gensim\utils.py", line 486, in load
obj._load_specials(fname, mmap, compress, subname)
File "C:\Python310\lib\site-packages\gensim\models\word2vec.py", line 1946, in _load_specials
super(Word2Vec, self)._load_specials(*args, **kwargs)
File "C:\Python310\lib\site-packages\gensim\utils.py", line 517, in _load_specials
getattr(self, attrib)._load_specials(cfname, mmap, compress, subname)
File "C:\Python310\lib\site-packages\gensim\utils.py", line 1521, in new_func1
return func(*args, **kwargs)
File "C:\Python310\lib\site-packages\gensim\models\doc2vec.py", line 326, in docvecs
return self.dv
AttributeError: 'Doc2Vec' object has no attribute 'dv'
the 'D:/pyspace/headline/headline/utils/model3/doc2vec.model' is an model that has ever been trained.
gensim version is 4.1.2
Django version is 4.0.3
I don't know what should I do to solve this problem. Thanks for help
It may be the problem of your version, or you can try to correct your code "model.doc2vec"

ImportError: [E048] Can't import language en from spacy.lang: No module named 'spacy.matcher' How do i fix this?

the title says all mostly, i'e been trying to make this package named chatterbot to work and then it shows this, i'm running ubuntu focal fossa
Full error log:
<frozen importlib._bootstrap>:219: RuntimeWarning: thinc.extra.search.Beam size changed, may indicate binary incompatibility. Expected 112 from C header, got 120 from PyObject
Traceback (most recent call last):
File "/home/arman/.local/lib/python3.8/site-packages/spacy/util.py", line 70, in get_lang_class
module = importlib.import_module(".lang.%s" % lang, "spacy")
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/arman/.local/lib/python3.8/site-packages/spacy/lang/en/__init__.py", line 15, in <module>
from ...language import Language
File "/home/arman/.local/lib/python3.8/site-packages/spacy/language.py", line 17, in <module>
from .pipeline import DependencyParser, Tagger
File "/home/arman/.local/lib/python3.8/site-packages/spacy/pipeline/__init__.py", line 4, in <module>
from .pipes import Tagger, DependencyParser, EntityRecognizer, EntityLinker
File "pipes.pyx", line 17, in init spacy.pipeline.pipes
File "/home/arman/.local/lib/python3.8/site-packages/spacy/pipeline/functions.py", line 4, in <module>
from ..matcher import Matcher
ModuleNotFoundError: No module named 'spacy.matcher'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 4, in <module>
bot = ChatBot('Test')
File "/usr/local/lib/python3.8/dist-packages/ChatterBot-1.1.0a7-py3.8.egg/chatterbot/chatterbot.py", line 28, in __init__
File "/usr/local/lib/python3.8/dist-packages/ChatterBot-1.1.0a7-py3.8.egg/chatterbot/utils.py", line 33, in initialize_class
File "/usr/local/lib/python3.8/dist-packages/ChatterBot-1.1.0a7-py3.8.egg/chatterbot/storage/sql_storage.py", line 20, in __init__
File "/usr/local/lib/python3.8/dist-packages/ChatterBot-1.1.0a7-py3.8.egg/chatterbot/storage/storage_adapter.py", line 22, in __init__
File "/usr/local/lib/python3.8/dist-packages/ChatterBot-1.1.0a7-py3.8.egg/chatterbot/tagging.py", line 26, in __init__
File "/home/arman/.local/lib/python3.8/site-packages/spacy/__init__.py", line 27, in load
return util.load_model(name, **overrides)
File "/home/arman/.local/lib/python3.8/site-packages/spacy/util.py", line 132, in load_model
return load_model_from_link(name, **overrides)
File "/home/arman/.local/lib/python3.8/site-packages/spacy/util.py", line 149, in load_model_from_link
return cls.load(**overrides)
File "/home/arman/.local/lib/python3.8/site-packages/spacy/data/en/__init__.py", line 12, in load
return load_model_from_init_py(__file__, **overrides)
File "/home/arman/.local/lib/python3.8/site-packages/spacy/util.py", line 196, in load_model_from_init_py
return load_model_from_path(data_path, meta, **overrides)
File "/home/arman/.local/lib/python3.8/site-packages/spacy/util.py", line 166, in load_model_from_path
cls = get_lang_class(lang)
File "/home/arman/.local/lib/python3.8/site-packages/spacy/util.py", line 72, in get_lang_class
raise ImportError(Errors.E048.format(lang=lang, err=err))
ImportError: [E048] Can't import language en from spacy.lang: No module named 'spacy.matcher'
I've tried all the other solutions on the internet none of them worked, it's been so many hours i don't even remember them all please forgive me
I don't Know what just happened or what was the problem but i fixed it, in case anyone encounters the issue i'll leave it here
Get spacy from github
Install everything on the requirements file
Install spacy from source
It's fixed somehow...

Error while upgrading ODOO from V11 to V12

While migrating my ODOO from version 11 to 12 using openUpgrade, I've encountered the following issue. I am using the community version of ODOO.
Traceback (most recent call last):
File "/home/user/company/version12/OpenUpgrade/odoo/service/server.py", line 1162, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/home/user/company/version12/OpenUpgrade/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/user/company/version12/OpenUpgrade/odoo/modules/loading.py", line 478, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/user/company/version12/OpenUpgrade/odoo/modules/loading.py", line 361, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/user/company/version12/OpenUpgrade/odoo/modules/loading.py", line 196, in load_module_graph
load_openerp_module(package.name)
File "/home/user/company/version12/OpenUpgrade/odoo/modules/module.py", line 368, in load_openerp_module
__import__('odoo.addons.' + module_name)
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
File "/home/user/company/version12/OpenUpgrade/odoo/modules/module.py", line 82, in load_module
exec(open(modfile, 'rb').read(), new_mod.__dict__)
File "<string>", line 3, in <module>
File "/home/user/company/erp12/company-erp-v3/mail_trail_message/models/__init__.py", line 5, in <module>
from . import mail_thread
File "/home/user/company/erp12/company-erp-v3/mail_trail_message/models/mail_thread.py", line 33, in <module>
class MailThread(models.AbstractModel):
File "/home/user/company/version12/OpenUpgrade/odoo/api.py", line 112, in _new_
value = guess(value)
File "/home/user/company/version12/OpenUpgrade/odoo/api.py", line 690, in guess
args, vname, kwname, defaults = getargspec(method)
File "/usr/lib/python3.8/inspect.py", line 1095, in getargspec
raise ValueError("Function has keyword-only parameters or annotations"
ValueError: Function has keyword-only parameters or annotations, use inspect.signature() API which can support them
File "/home/user/company/erp12/company-erp-v3/mail_trail_message/models/mail_thread.py", line 33, in <module>
This is where you should look at. I believe Odoo has no module name mail_trail_message

pyttsx3 python speech module throwing handling exceptions

i was trying to get audio output using pyttsx3 in python
here is the code:
import pyttsx3
def speak(text):
engine = pyttsx3.init()
engine.say(text)
engine.runAndWait()
speak("hello world")
It is throwing handling errors which i am not able to understand:
Traceback (most recent call last):
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\pyttsx3_init_.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\weakref.py", line 137, in getitem
o = self.datakey
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
from comtypes.gen import SpeechLib # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\gen\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 121, in WINFUNCTYPE
return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.automation.LP_tagVARIANT'>, <class 'ctypes.c_long'>), 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Learning/100dayscode/python/voice.py", line 132, in <module>
speak("Hello ")
File "D:/Learning/100dayscode/python/voice.py", line 23, in speak
engine = pyttsx3.init()
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in <module>
engine = comtypes.client.CreateObject("SAPI.SpVoice")
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
return _manage(obj, clsid, interface=interface)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
mod = GetModule(tlib)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\client\_generate.py", line 110, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\client\_generate.py", line 184, in _CreateWrapper
mod = _my_import(fullname)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\client\_generate.py", line 24, in _my_import
return __import__(fullname, globals(), locals(), ['DUMMY'])
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 365, in <module>
( ['out', 'retval'], POINTER(POINTER(ISpeechObjectTokens)), 'ObjectTokens' )),
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\__init__.py", line 329, in __setattr__
self._make_methods(value)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
prototype = WINFUNCTYPE(restype, *argtypes)
File "C:\Users\harshit\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported.
Well i figured it out.
It looks like the new version of pip have conflicts with updates.
This code worked for me
python -m pip install pyttsx3==2.71

Categories

Resources