atomic14 / diy-alexa

DIY Alexa
MIT License
495 stars 178 forks source link

Issue while running the Jupyter notebook Generate Training data #65

Open naveenneog opened 5 months ago

naveenneog commented 5 months ago

Hi ,

I have followed the venv and created the environment , Code block no : 8 is giving this issue

image

Code

def` process_files(file_names, label, repeat=1):
    file_names = tf.repeat(file_names, repeat).numpy()
    return [(process_file(file_name), label) for file_name in tqdm(file_names, desc=f"{word} ({label})", leave=False)]

# process the files for a word into the spectrogram and one hot encoding word value
def process_word(word, repeat=1):
    # the index of the word word we are processing
    label = words.index(word)
    # get a list of files names for the word
    file_names = [file_name for file_name in tqdm(get_files(word), desc="Checking", leave=False) if is_valid_file(file_name)]
    # randomly shuffle the filenames
    np.random.shuffle(file_names)
    # split the files into train, validate and test buckets
    train_size=int(TRAIN_SIZE*len(file_names))
    validation_size=int(VALIDATION_SIZE*len(file_names))
    test_size=int(TEST_SIZE*len(file_names))
    # get the training samples
    train.extend(
        process_files(
            file_names[:train_size],
            label,
            repeat=repeat
        )
    )
    # and the validation samples
    validate.extend(
        process_files(
            file_names[train_size:train_size+validation_size],
            label,
            repeat=repeat
        )
    )
    # and the test samples
    test.extend(
        process_files(
            file_names[train_size+validation_size:],
            label,
            repeat=repeat
        )
    )

# process all the words and all the files
for word in tqdm(words, desc="Processing words"):
    if '_' not in word:
        # add more examples of marvin to balance our training set
        repeat = 70 if word == 'marvin' else 1
        process_word(word, repeat=repeat)

print(len(train), len(test), len(validate)) 

Following is the error

ERROR


`--------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[8], line 47
     44     if '_' not in word:
     45         # add more examples of marvin to balance our training set
     46         repeat = 70 if word == 'marvin' else 1
---> 47         process_word(word, repeat=repeat)
     49 print(len(train), len(test), len(validate))

Cell In[8], line 10, in process_word(word, repeat)
      8 label = words.index(word)
      9 # get a list of files names for the word
---> 10 file_names = [file_name for file_name in tqdm(get_files(word), desc="Checking", leave=False) if is_valid_file(file_name)]
     11 # randomly shuffle the filenames
     12 np.random.shuffle(file_names)

Cell In[8], line 10, in <listcomp>(.0)
      8 label = words.index(word)
      9 # get a list of files names for the word
---> 10 file_names = [file_name for file_name in tqdm(get_files(word), desc="Checking", leave=False) if is_valid_file(file_name)]
     11 # randomly shuffle the filenames
     12 np.random.shuffle(file_names)

Cell In[5], line 28, in is_valid_file(file_name)
     26 def is_valid_file(file_name):
     27     # load the audio file
---> 28     audio_tensor = tfio.audio.AudioIOTensor(file_name)
     29     # check the file is long enough
     30     if not is_correct_length(audio_tensor, EXPECTED_SAMPLES):

File ~\Documents\TinyML\diy-alexa\model\.venv\Lib\site-packages\tensorflow_io\python\ops\audio_ops.py:664, in AudioIOTensor.__init__(self, filename, dtype)
    662 if not tf.executing_eagerly():
    663     assert dtype is not None, "dtype must be provided in graph mode"
--> 664 resource = core_ops.io_audio_readable_init(filename)
    665 if tf.executing_eagerly():
    666     shape, dtype, rate = core_ops.io_audio_readable_spec(resource)

File ~\Documents\TinyML\diy-alexa\model\.venv\Lib\site-packages\tensorflow_io\python\ops\__init__.py:88, in LazyLoader.__getattr__(self, attrb)
     87 def __getattr__(self, attrb):
---> 88     return getattr(self._load(), attrb)

File ~\Documents\TinyML\diy-alexa\model\.venv\Lib\site-packages\tensorflow_io\python\ops\__init__.py:84, in LazyLoader._load(self)
     82 def _load(self):
     83     if self._mod is None:
---> 84         self._mod = _load_library(self._library)
     85     return self._mod

File ~\Documents\TinyML\diy-alexa\model\.venv\Lib\site-packages\tensorflow_io\python\ops\__init__.py:69, in _load_library(filename, lib)
     67     except (tf.errors.NotFoundError, OSError) as e:
     68         errs.append(str(e))
---> 69 raise NotImplementedError(
     70     "unable to open file: "
     71     + f"{filename}, from paths: {filenames}\ncaused by: {errs}"
     72 )

NotImplementedError: unable to open file: libtensorflow_io.so, from paths: ['C:\\Users\\nag\\Documents\\TinyML\\diy-alexa\\model\\.venv\\Lib\\site-packages\\tensorflow_io\\python\\ops\\libtensorflow_io.so']
caused by: ['C:\\Users\\nag\\Documents\\TinyML\\diy-alexa\\model\\.venv\\Lib\\site-packages\\tensorflow_io\\python\\ops\\libtensorflow_io.so not found']`
Bravewave commented 1 month ago

I am having this exact same issue myself. Have already tried a few workarounds, uninstallations and reinstallations. All to no avail