Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions examples/audio/speaker_recognition_using_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,33 @@
os.environ["KERAS_BACKEND"] = "tensorflow"

import shutil
import zipfile
import numpy as np

import tensorflow as tf
import keras

from pathlib import Path
from IPython.display import display, Audio

# Get the data from https://www.kaggle.com/kongaevans/speaker-recognition-dataset/
# and save it to ./speaker-recognition-dataset.zip
# then unzip it to ./16000_pcm_speeches
"""shell
kaggle datasets download -d kongaevans/speaker-recognition-dataset
unzip -qq speaker-recognition-dataset.zip
"""

DATASET_ROOT = "16000_pcm_speeches"
ZIP_FILE = "speaker-recognition-dataset.zip"

DATASET_ROOT = Path("16000_pcm_speeches")
ZIP_FILE = Path("speaker-recognition-dataset.zip")

# Check if the dataset is already extracted
if not DATASET_ROOT.exists():
# Check if the zip file is present
if ZIP_FILE.exists():
print(f"Extracting {ZIP_FILE}...")
with zipfile.ZipFile(ZIP_FILE, "r") as zip_ref:
zip_ref.extractall(DATASET_ROOT)
print("Extraction complete.")
else:
# If neither exists, guide the user
print(f"Dataset not found. Please download it from:")
print("https://www.kaggle.com/kongaevans/speaker-recognition-dataset")
print(f"Save it as '{ZIP_FILE}' in this directory and run again.")
exit()
DATASET_ROOT = "16000_pcm_speeches"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The DATASET_ROOT variable is already defined on line 56. This re-definition is redundant and can be safely removed.


# The folders in which we will put the audio samples and the noise samples
Expand Down