rolczynski / Automatic-Speech-Recognition

🎧 Automatic Speech Recognition: DeepSpeech & Seq2Seq (TensorFlow)
GNU Affero General Public License v3.0
223 stars 63 forks source link

OSError: Unable to open file #14

Closed liviasalgueiro closed 4 years ago

liviasalgueiro commented 4 years ago

Hello, thank you for sharing this project!

I'm trying to run the code but I'm getting the following error. Could someone help me please? ------- INPUT import automatic_speech_recognition as asr pipeline = asr.load('deepspeech2', lang='en')

------- OUTPUT OSError: Unable to open file (truncated file: eof = 19259392, sblock->base_addr = 0, stored_eof = 454666120)


OSError Traceback (most recent call last)

in ----> 1 pipeline = asr.load('deepspeech2', lang='en') ~/anaconda3/lib/python3.7/site-packages/automatic_speech_recognition/load/load.py in load(name, lang, version) 11 def load(name: str, lang: str, version=0.1) -> pipeline.Pipeline: 12 if name == 'deepspeech2' and lang == 'en' and version == 0.1: ---> 13 return load_deepspeech2_en() 14 raise ValueError('Specified model is not supported') 15 ~/anaconda3/lib/python3.7/site-packages/automatic_speech_recognition/load/load.py in wrapper() 25 local_path = f'{os.path.dirname(__file__)}/models/{file_name}' 26 utils.maybe_download_from_bucket(bucket, remote_path, local_path) ---> 27 return loader(weights_path=local_path) 28 return wrapper 29 return closure ~/anaconda3/lib/python3.7/site-packages/automatic_speech_recognition/load/load.py in load_deepspeech2_en(weights_path) 33 def load_deepspeech2_en(weights_path: str) -> pipeline.CTCPipeline: 34 deepspeech2 = model.get_deepspeech2(input_dim=160, output_dim=29) ---> 35 deepspeech2.load_weights(weights_path) 36 alphabet_en = text.Alphabet(lang='en') 37 spectrogram = features.Spectrogram( ~/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in load_weights(self, filepath, by_name, skip_mismatch) 232 raise ValueError('Load weights is not yet supported with TPUStrategy ' 233 'with steps_per_run greater than 1.') --> 234 return super(Model, self).load_weights(filepath, by_name, skip_mismatch) 235 236 @trackable.no_automatic_dependency_tracking ~/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch) 1213 'first, then load the weights.') 1214 self._assert_weights_created() -> 1215 with h5py.File(filepath, 'r') as f: 1216 if 'layer_names' not in f.attrs and 'model_weights' in f: 1217 f = f['model_weights'] ~/anaconda3/lib/python3.7/site-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds) 392 fid = make_fid(name, mode, userblock_size, 393 fapl, fcpl=make_fcpl(track_order=track_order), --> 394 swmr=swmr) 395 396 if swmr_support: ~/anaconda3/lib/python3.7/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr) 168 if swmr and swmr_support: 169 flags |= h5f.ACC_SWMR_READ --> 170 fid = h5f.open(name, flags, fapl=fapl) 171 elif mode == 'r+': 172 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl) h5py/_objects.pyx in h5py._objects.with_phil.wrapper() h5py/_objects.pyx in h5py._objects.with_phil.wrapper() h5py/h5f.pyx in h5py.h5f.open() OSError: Unable to open file (truncated file: eof = 19259392, sblock->base_addr = 0, stored_eof = 454666120)
rolczynski commented 4 years ago

hey @liviasalgueiro hmm, I think the HDF file, which the program tries to open is broken. There are many potential causes. Please reinstall the package or locate the HDF file and remove it. 👍

liviasalgueiro commented 4 years ago

hey @liviasalgueiro hmm, I think the HDF file, which the program tries to open is broken. There are many potential causes. Please reinstall the package or locate the HDF file and remove it. 👍

It worked, thank you!

jimmychordia commented 3 years ago

Hi,

I am trying to use automatic_speech_recognition from PyPi repository. Below is the code I am using.

import automatic_speech_recognition as asr file = 'sample.wav' # sample rate 16 kHz, and 16 bit depth sample = asr.utils.read_audio(file) pipeline = asr.load('deepspeech2', lang='en') pipeline.model.summary() # TensorFlow model sentences = pipeline.predict([sample])

I get the below error on loading deepspeech model. Can anyone please guide me on the resolution for this.

##########################################################################

OSError Traceback (most recent call last)

in ~\Anaconda3\lib\site-packages\automatic_speech_recognition\load\load.py in load(name, lang, version) 11 def load(name: str, lang: str, version=0.1) -> pipeline.Pipeline: 12 if name == 'deepspeech2' and lang == 'en' and version == 0.1: ---> 13 return load_deepspeech2_en() 14 raise ValueError('Specified model is not supported') 15 ~\Anaconda3\lib\site-packages\automatic_speech_recognition\load\load.py in wrapper() 25 local_path = f'{os.path.dirname(__file__)}/models/{file_name}' 26 utils.maybe_download_from_bucket(bucket, remote_path, local_path) ---> 27 return loader(weights_path=local_path) 28 return wrapper 29 return closure ~\Anaconda3\lib\site-packages\automatic_speech_recognition\load\load.py in load_deepspeech2_en(weights_path) 33 def load_deepspeech2_en(weights_path: str) -> pipeline.CTCPipeline: 34 deepspeech2 = model.get_deepspeech2(input_dim=160, output_dim=29) ---> 35 deepspeech2.load_weights(weights_path) 36 alphabet_en = text.Alphabet(lang='en') 37 spectrogram = features.Spectrogram( ~\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in load_weights(self, filepath, by_name, skip_mismatch, options) 2202 'first, then load the weights.') 2203 self._assert_weights_created() -> 2204 with h5py.File(filepath, 'r') as f: 2205 if 'layer_names' not in f.attrs and 'model_weights' in f: 2206 f = f['model_weights'] ~\Anaconda3\lib\site-packages\h5py\_hl\files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, **kwds) 425 fapl, fcpl=make_fcpl(track_order=track_order, fs_strategy=fs_strategy, 426 fs_persist=fs_persist, fs_threshold=fs_threshold), --> 427 swmr=swmr) 428 429 if isinstance(libver, tuple): ~\Anaconda3\lib\site-packages\h5py\_hl\files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr) 188 if swmr and swmr_support: 189 flags |= h5f.ACC_SWMR_READ --> 190 fid = h5f.open(name, flags, fapl=fapl) 191 elif mode == 'r+': 192 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl) h5py\_objects.pyx in h5py._objects.with_phil.wrapper() h5py\_objects.pyx in h5py._objects.with_phil.wrapper() h5py\h5f.pyx in h5py.h5f.open() OSError: Unable to open file (truncated file: eof = 46546944, sblock->base_addr = 0, stored_eof = 454666120) ###############################################################################