docs icon indicating copy to clipboard operation
docs copied to clipboard

ADDED- A command to move mini_speech_commands directory so that the simple_audio.ipynb runs

Open ya0002 opened this issue 8 months ago • 1 comments

The current notebook doesn't work after

DATASET_PATH = 'data/mini_speech_commands'

data_dir = pathlib.Path(DATASET_PATH)
if not data_dir.exists():
  tf.keras.utils.get_file(
      'mini_speech_commands.zip',
      origin="http://storage.googleapis.com/download.tensorflow.org/data/mini_speech_commands.zip",
      extract=True,
      cache_dir='.', cache_subdir='data')

The snippet

commands = np.array(tf.io.gfile.listdir(str(data_dir)))
commands = commands[(commands != 'README.md') & (commands != '.DS_Store')]
print('Commands:', commands)

gives the error

---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
[<ipython-input-5-5c3ad82a2720>](https://localhost:8080/#) in <cell line: 0>()
----> 1 commands = np.array(tf.io.gfile.listdir(str(data_dir)))
      2 commands = commands[(commands != 'README.md') & (commands != '.DS_Store')]
      3 print('Commands:', commands)

[/usr/local/lib/python3.11/dist-packages/tensorflow/python/lib/io/file_io.py](https://localhost:8080/#) in list_directory_v2(path)
    766   """
    767   if not is_directory(path):
--> 768     raise errors.NotFoundError(
    769         node_def=None,
    770         op=None,

NotFoundError: Could not find directory data/mini_speech_commands

This fix moves the mini_speech_commands dir from /content/data/mini_speech_commands_extracted/mini_speech_commands to /content/data/mini_speech_commands.

ya0002 avatar Apr 22 '25 11:04 ya0002

Preview

Preview and run these notebook edits with Google Colab: Rendered notebook diffs available on ReviewNB.com.

Format and style

Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:
$ python3 -m pip install -U --user git+https://github.com/tensorflow/docs

$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
If commits are added to the pull request, synchronize your local branch: git pull origin Fix-simple_audio-tutorial-notebook-dataset-dir

github-actions[bot] avatar Apr 22 '25 11:04 github-actions[bot]