I try to load a umap_2.sav with the same environment with which I create the file but on another PC. I get an EOFError by using 50% of my memory.
umap_model_plot = umap.UMAP(n_neighbors=15,
n_components=2,
metric='cosine', low_memory=True).fit(emb)
joblib.dump(umap_model_plot,'umap_2.sav')
On a other pc
umap_model_plot = joblib.load('umap_2.sav')
Error
umap_model_plot = joblib.load('umap_2.sav')
Traceback (most recent call last):
File "<ipython-input-5-f6a4b963c45a>", line 1, in <module>
umap_model_plot = joblib.load('umap_2.sav')
File "C:\Users\Administrator\anaconda3\envs\top2vec_final_\lib\site-packages\joblib\numpy_pickle.py", line 585, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "C:\Users\Administrator\anaconda3\envs\top2vec_final_\lib\site-packages\joblib\numpy_pickle.py", line 504, in _unpickle
obj = unpickler.load()
File "C:\Users\Administrator\anaconda3\envs\top2vec_final_\lib\pickle.py", line 1086, in load
raise EOFError
EOFError
Related
The Code:
import speech_recognition as sr
file_name = "tts.wav"
speech_engine = sr.Recognizer()
def from_file(file_name):
with sr.AudioFile(file_name) as f:
data = speech_engine.record(f)
text = speech_engine.recognize_google(data, language="de-DE")
return text
def from_microphone():
with sr.Microphone() as micro:
print("Recording...")
audio = speech_engine.record(micro, duration=5)
print("Recognition...")
text = speech_engine.recognize_google(audio, language="de-DE")
return text
from_file(file_name)
print(from_microphone())
Terminal:
PS C:\Users\schne\Desktop\Jarvis> &
C:/Users/schne/AppData/Local/Microsoft/WindowsApps/python3.10.exe
"c:/Users/schne/Desktop/Jarvis/speech to text copy.py" Traceback (most
recent call last): File
"C:\Users\schne\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition_init_.py",
line 253, in enter
self.audio_reader = wave.open(self.filename_or_fileobject, "rb") File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\wave.py",
line 509, in open
return Wave_read(f) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\wave.py",
line 163, in init
self.initfp(f) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\wave.py",
line 130, in initfp
raise Error('file does not start with RIFF id') wave.Error: file does not start with RIFF id
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\schne\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition_init_.py",
line 258, in enter
self.audio_reader = aifc.open(self.filename_or_fileobject, "rb") File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\aifc.py",
line 917, in open
return Aifc_read(f) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\aifc.py",
line 352, in init
self.initfp(file_object) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\aifc.py",
line 316, in initfp
raise Error('file does not start with FORM id') aifc.Error: file does not start with FORM id
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\schne\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition_init_.py",
line 284, in enter
self.audio_reader = aifc.open(aiff_file, "rb") File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\aifc.py",
line 917, in open
return Aifc_read(f) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\aifc.py",
line 358, in init
self.initfp(f) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\aifc.py",
line 314, in initfp
chunk = Chunk(file) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\chunk.py",
line 63, in init
raise EOFError EOFError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:\Users\schne\Desktop\Jarvis\speech to text copy.py", line 17, in
from_file(file_name) File "c:\Users\schne\Desktop\Jarvis\speech to text copy.py", line 5, in from_file
with sr.AudioFile(file_name) as f: File "C:\Users\schne\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition_init_.py",
line 286, in enter
raise ValueError("Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another
format") ValueError: Audio file could not be read as PCM WAV,
AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another
format
The program should recognize text from a file or directly from the microphone, but the terminal does not recognize it or something (I'm a beginner).
I write a little program which writes the audio to text. But it throws an error and I don't know how to fix it.
import speech_recognition as sr
file_name = "halloWelt.wav"
speech_engine = sr.Recognizer()
with sr.AudioFile(file_name) as file:
data = speech_engine.record()
text = speech_engine.recognize_google(data, language='de-DE')
print(text)
The error:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\speech_recognition\__init__.py", line 203, in __enter__
self.audio_reader = wave.open(self.filename_or_fileobject, "rb")
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\wave.py", line 509, in open
return Wave_read(f)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\wave.py", line 163, in __init__
self.initfp(f)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\wave.py", line 130, in initfp
raise Error('file does not start with RIFF id')
wave.Error: file does not start with RIFF id
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\speech_recognition\__init__.py", line 208, in __enter__
self.audio_reader = aifc.open(self.filename_or_fileobject, "rb")
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\aifc.py", line 917, in open
return Aifc_read(f)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\aifc.py", line 352, in __init__
self.initfp(file_object)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\aifc.py", line 316, in initfp
raise Error('file does not start with FORM id')
aifc.Error: file does not start with FORM id
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\speech_recognition\__init__.py", line 234, in __enter__
self.audio_reader = aifc.open(aiff_file, "rb")
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\aifc.py", line 917, in open
return Aifc_read(f)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\aifc.py", line 358, in __init__
self.initfp(f)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\aifc.py", line 314, in initfp
chunk = Chunk(file)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\chunk.py", line 63, in __init__
raise EOFError
EOFError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\\OneDrive\Dokumente\Programming\Python\Lets code\speech.py", line 6, in <module>
with sr.AudioFile(file_name) as file:
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\speech_recognition\__init__.py", line 236, in __enter__
raise ValueError("Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format")
ValueError: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format
I use joblib.load to load trained model file xgboost.m(other win10 computer trains the model),but it does not work:
model = joblib.load('xgboost.m')
my computer is win10 too, but error occured when execute the codeļ¼
2020-06-16 20:47:48 [1832] ERROR XgboostAlgObj.py:70: - Traceback (most recent call last):
File "D:/iWork/pp/python-schedule/oritek/task/component/XgboostAlgObj.py", line 67, in execute
return self.xgboost(chk_date, dest_equips, busi_type, equip_code,flag)
File "D:/iWork/pp/python-schedule/oritek/task/component/XgboostAlgObj.py", line 37, in xgboost
pred = model_predict.predict(busi_type,equip_code,chk_date[0:7],self.predict_time,equip_code)
File "D:\iWork\pp\python-schedule\oritek\task\component\model_predict.py", line 156, in predict
model = joblib.load('xgboost.m')
File "C:\ProgramData\Anaconda3\lib\site-packages\joblib\numpy_pickle.py", line 585, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "C:\ProgramData\Anaconda3\lib\site-packages\joblib\numpy_pickle.py", line 504, in _unpickle
obj = unpickler.load()
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 1085, in load
dispatch[key[0]](self)
File "C:\ProgramData\Anaconda3\lib\site-packages\joblib\numpy_pickle.py", line 329, in load_build
Unpickler.load_build(self)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 1549, in load_build
setstate(state)
File "C:\ProgramData\Anaconda3\lib\site-packages\xgboost\core.py", line 981, in __setstate__
_check_call(_LIB.XGBoosterLoadModelFromBuffer(handle, ptr, length))
File "C:\ProgramData\Anaconda3\lib\site-packages\xgboost\core.py", line 176, in _check_call
raise XGBoostError(py_str(_LIB.XGBGetLastError()))
xgboost.core.XGBoostError: [20:47:48] C:\Jenkins\workspace\xgboost-win64_release_0.90\src\gbm\gbm.cc:20: Unknown gbm type
Exception ignored in: <function Booster.__del__ at 0x0000020E4CC3F730>
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\xgboost\core.py", line 957, in __del__
AttributeError: 'Booster' object has no attribute 'handle'
what may cause the problem? Thank you!
It may be because the model was trained in a xgboost version that is different than the xgboost version being used in your environe
I have some issues while trying to load saved models back into keras. Saving the model goes fine:
In [6]: model.save('savefile', save_format='tf')
INFO:tensorflow:Assets written to: savefile/assets
But when loading the model, I got the following error:
In [7]: tf.keras.models.load_model('savefile')
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-7-ddb252fa0c51>", line 1, in <module>
tf.keras.models.load_model('lofasz.xx')
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/saving/save.py", line 190, in load_model
return saved_model_load.load(filepath, compile)
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/saving/saved_model/load.py", line 105, in load
model = tf_load.load_internal(path, loader_cls=KerasObjectLoader)
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/saved_model/load.py", line 599, in load_internal
export_dir)
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/saving/saved_model/load.py", line 170, in __init__
super(KerasObjectLoader, self).__init__(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/saved_model/load.py", line 122, in __init__
self._load_all()
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/saving/saved_model/load.py", line 183, in _load_all
self._finalize_objects()
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/saving/saved_model/load.py", line 394, in _finalize_objects
self._reconstruct_all_models()
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/saving/saved_model/load.py", line 412, in _reconstruct_all_models
self._reconstruct_model(model_id, model, layers)
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/saving/saved_model/load.py", line 442, in _reconstruct_model
model._set_inputs(input_shape) # pylint: disable=protected-access
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/engine/training.py", line 2448, in _set_inputs
inputs = self._set_input_attrs(inputs)
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/training/tracking/base.py", line 456, in _method_wrapper
result = method(self, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/keras/engine/training.py", line 2487, in _set_input_attrs
input_shape = (None,) + tuple(inputs.shape[1:])
AttributeError: 'list' object has no attribute 'shape'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 1821, in showtraceback
stb = value._render_traceback_()
AttributeError: 'AttributeError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/IPython/core/ultratb.py", line 1132, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "/usr/lib/python3/dist-packages/IPython/core/ultratb.py", line 313, in wrapped
return f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/IPython/core/ultratb.py", line 358, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "/usr/lib/python3.5/inspect.py", line 1454, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
File "/usr/lib/python3.5/inspect.py", line 1411, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
File "/usr/lib/python3.5/inspect.py", line 671, in getsourcefile
if getattr(getmodule(object, filename), '__loader__', None) is not None:
File "/usr/lib/python3.5/inspect.py", line 717, in getmodule
os.path.realpath(f)] = module.__name__
AttributeError: module has no attribute '__name__'
---------------------------------------------------------------------------
Loading with tf.saved_model.load does work:
In [9]: qq=tf.saved_model.load('savefile')
In [10]: qq
Out[10]: <tensorflow.python.saved_model.load.Loader._recreate_base_user_object.<locals>._UserObject at 0x7fdff155feb8>
but I didn't find anything on how to get this back as a keras model. Any ideas?
I am using the most lightweight/simple dask multiprocessing which is the non-cluster local Client:
from distributed import Client
client = Client()
Even so: the first instance of invoking dask.bag.compute() results in the following:
Connected to pydev debugger (build 191.7141.48)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
The result is that you can more or less flip a coin on whether the program will proceed or error out with a communication exception. Here is what happens when the flip comes up "tails":
Connected to pydev debugger (build 191.7141.48)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
Process ForkServerProcess-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/distributed/core.py", line 178, in __init__
from .counter import Digest
ImportError: cannot import name 'Digest' from 'distributed.counter' (/usr/local/lib/python3.7/site-packages/distributed/counter.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/process.py", line 181, in _run
target(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/nanny.py", line 587, in _run
worker = Worker(*worker_args, **worker_kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/worker.py", line 552, in __init__
**kwargs
File "/usr/local/lib/python3.7/site-packages/distributed/node.py", line 76, in __init__
io_loop=self.io_loop,
File "/usr/local/lib/python3.7/site-packages/distributed/core.py", line 180, in __init__
self.digests = defaultdict(partial(Digest, loop=self.io_loop))
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.7/site-packages/distributed/utils.py", line 179, in ignoring
yield
SystemError: error return without exception set
distributed.nanny - WARNING - Worker process 20417 exited with status 1
Traceback (most recent call last):
File "_pydevd_frame_eval/pydevd_frame_evaluator_darwin_37_64.pyx", line 95, in _pydevd_frame_eval.pydevd_frame_evaluator_darwin_37_64.get_bytecode_while_frame_eval
KeyError: '/usr/local/lib/python3.7/site-packages/distributed/bokeh/__init__.py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1758, in <module>
main()
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1752, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1147, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/git/huddl/python/hamspam/enron.py", line 205, in <module>
client = Client()
File "/usr/local/lib/python3.7/site-packages/distributed/client.py", line 712, in __init__
self.start(timeout=timeout)
File "/usr/local/lib/python3.7/site-packages/distributed/client.py", line 858, in start
sync(self.loop, self._start, **kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/utils.py", line 331, in sync
six.reraise(*error[0])
File "/usr/local/lib/python3.7/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/distributed/utils.py", line 316, in f
result[0] = yield future
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/usr/local/lib/python3.7/site-packages/distributed/client.py", line 928, in _start
yield self.cluster
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/tasks.py", line 603, in _wrap_awaitable
return (yield from awaitable.__await__())
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/usr/local/lib/python3.7/site-packages/distributed/deploy/local.py", line 284, in _start
yield [self._start_worker(**self.worker_kwargs) for i in range(n_workers)]
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 501, in callback
result_list.append(f.result())
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.send(value)
File "/usr/local/lib/python3.7/site-packages/distributed/deploy/local.py", line 316, in _start_worker
raise gen.TimeoutError("Worker failed to start")
tornado.util.TimeoutError: Worker failed to start
Any advice on this?
There will be even more issues/complications when trying to use a LocalCluster mode -but that will be saved for a different question.