Update basic_training_notebook.ipynb

This commit is contained in:
MasterPhooey
2025-01-02 23:43:12 -06:00
committed by GitHub
parent 5c9585e784
commit 12c1323829

View File

@@ -60,39 +60,49 @@
"id": "dEluu7nL7ywd" "id": "dEluu7nL7ywd"
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Generates 1 sample of the target word for manual verification.\n", "# Generates 1 sample of the target word for manual verification.\n",
"\n", "\n",
"target_word = 'khum_puter' # Phonetic spellings may produce better samples\n", "target_word = 'khum_puter' # Phonetic spellings may produce better samples\n",
"\n", "\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import platform\n", "import platform\n",
"\n", "\n",
"from IPython.display import Audio\n", "from IPython.display import Audio\n",
"\n", "\n",
"if not os.path.exists(\"./-m piper-sample-generator\"):\n", "# Ensure the repository is cloned correctly\n",
" if platform.system() == \"Darwin\":\n", "if not os.path.exists(\"./piper-sample-generator\"):\n",
" !git clone -b mps-support https://github.com/kahrendt/piper-sample-generator\n", " if platform.system() == \"Darwin\":\n",
" else:\n", " !git clone -b mps-support https://github.com/kahrendt/piper-sample-generator\n",
" !git clone https://github.com/rhasspy/piper-sample-generator\n", " else:\n",
"\n", " !git clone https://github.com/rhasspy/piper-sample-generator\n",
" !wget -O -m piper-sample-generator/models/en_US-libritts_r-medium.pt 'https://github.com/rhasspy/-m piper-sample-generator/releases/download/v2.0.0/en_US-libritts_r-medium.pt'\n", "\n",
"\n", "# Download the required model\n",
" # Install system dependencies\n", "if not os.path.exists(\"piper-sample-generator/models/en_US-libritts_r-medium.pt\"):\n",
" !\"{sys.executable}\" -m pip install torch torchaudio -m piper-phonemize-cross==1.2.1\n", " !wget -O piper-sample-generator/models/en_US-libritts_r-medium.pt 'https://github.com/rhasspy/piper-sample-generator/releases/download/v2.0.0/en_US-libritts_r-medium.pt'\n",
"\n", "\n",
" if \"-m piper-sample-generator/\" not in sys.path:\n", "# Install system dependencies\n",
" sys.path.append(\"-m piper-sample-generator/\")\n", "!\"{sys.executable}\" -m pip install torch torchaudio piper-phonemize-cross==1.2.1\n",
"\n", "\n",
"!\"{sys.executable}\" pyrhon3 -m piper-sample-generator/generate_samples.py \"{target_word}\" \\\n", "# Ensure the repository path is in sys.path\n",
"--max-samples 1 \\\n", "if \"piper-sample-generator/\" not in sys.path:\n",
"--batch-size 1 \\\n", " sys.path.append(\"piper-sample-generator/\")\n",
"--output-dir generated_samples\n", "\n",
"\n", "# Generate sample\n",
"Audio(\"generated_samples/0.wav\", autoplay=True)" "!\"{sys.executable}\" piper-sample-generator/generate_samples.py \"{target_word}\" \\\n",
] "--max-samples 1 \\\n",
}, "--batch-size 1 \\\n",
"--output-dir generated_samples\n",
"\n",
"# Play the generated audio sample\n",
"audio_path = \"generated_samples/0.wav\"\n",
"if os.path.exists(audio_path):\n",
" display(Audio(audio_path, autoplay=True))\n",
"else:\n",
" print(f\"Audio file not found at {audio_path}\")"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -108,7 +118,7 @@
"# generating negative samples similar to the wake word, and generating many more\n", "# generating negative samples similar to the wake word, and generating many more\n",
"# wake word samples, possibly with different phonetic pronunciations.\n", "# wake word samples, possibly with different phonetic pronunciations.\n",
"\n", "\n",
"!\"{sys.executable}\" pyrhon3 -m piper-sample-generator/generate_samples.py \"{target_word}\" \\\n", "!\"{sys.executable}\" -m piper-sample-generator/generate_samples.py \"{target_word}\" \\\n",
"--max-samples 1000 \\\n", "--max-samples 1000 \\\n",
"--batch-size 100 \\\n", "--batch-size 100 \\\n",
"--output-dir generated_samples" "--output-dir generated_samples"