{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "gpuType": "T4" }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU", "widgets": { "application/vnd.jupyter.widget-state+json": { "6c3dd62b8cd14e91b8d47d734dbbaced": { "model_module": "@jupyter-widgets/controls", "model_name": "VBoxModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "VBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "VBoxView", "box_style": "", "children": [ "IPY_MODEL_9d8f8793e20c4fa2a3c371f3b3812611", "IPY_MODEL_41a1a574b4b249d89f5f8760f6050a2d", "IPY_MODEL_ed8cedae4db6442f9937d2ffb5233ffa", "IPY_MODEL_8bccf75943dc43f985572f454ee7b09c" ], "layout": "IPY_MODEL_a13585e1bcd84f5a8786d34882e3c762" } }, "34d191d760cc4c0888e08bab1a99e281": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2cef5d7da100426e8dfd33dbffa658fa", "placeholder": "", "style": "IPY_MODEL_d9225211b21744ffb45276704bbe809c", "value": "
Step | \n", "Training Loss | \n", "Validation Loss | \n", "
---|---|---|
100 | \n", "3.772000 | \n", "0.420103 | \n", "
200 | \n", "3.591200 | \n", "0.405249 | \n", "
300 | \n", "3.460400 | \n", "0.394766 | \n", "
400 | \n", "3.389400 | \n", "0.390611 | \n", "
500 | \n", "3.373700 | \n", "0.386506 | \n", "
600 | \n", "3.362800 | \n", "0.385102 | \n", "
700 | \n", "3.323600 | \n", "0.382134 | \n", "
800 | \n", "3.306000 | \n", "0.381117 | \n", "
900 | \n", "3.285900 | \n", "0.379681 | \n", "
1000 | \n", "3.266300 | \n", "0.376319 | \n", "
1100 | \n", "3.236800 | \n", "0.375682 | \n", "
1200 | \n", "3.210700 | \n", "0.374939 | \n", "
1300 | \n", "3.203500 | \n", "0.372964 | \n", "
1400 | \n", "3.196900 | \n", "0.372788 | \n", "
1500 | \n", "3.210700 | \n", "0.371661 | \n", "
"
]
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py:2816: UserWarning: Moving the following attributes in the config to the generation config: {'max_length': 1876}. You are seeing this warning because you've set generation parameters in the model config, as opposed to in the generation config.\n",
" warnings.warn(\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n",
" with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"TrainOutput(global_step=1500, training_loss=3.39983762105306, metrics={'train_runtime': 4837.6694, 'train_samples_per_second': 9.922, 'train_steps_per_second': 0.31, 'total_flos': 5483826441583776.0, 'train_loss': 3.39983762105306, 'epoch': 4.580152671755725})"
]
},
"metadata": {},
"execution_count": 34
}
]
},
{
"cell_type": "code",
"source": [
"trainer.push_to_hub()"
],
"metadata": {
"id": "T3aPr-chnqM_",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 52
},
"outputId": "288fef0f-ba56-478a-8dcc-264dd6ddd90a"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"CommitInfo(commit_url='https://huggingface.co/DeepDiveDev/speecht5_finetuned_English/commit/8bbc92b5968125e1ff51b8fea16e90aa40c5f267', commit_message='End of training', commit_description='', oid='8bbc92b5968125e1ff51b8fea16e90aa40c5f267', pr_url=None, pr_revision=None, pr_num=None)"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 35
}
]
},
{
"cell_type": "markdown",
"source": [
"#Dataset on Technical Term"
],
"metadata": {
"id": "yoOXf1BXOdg4"
}
},
{
"cell_type": "code",
"source": [
"!pip install datasets\n",
"import pandas as pd\n",
"from datasets import Dataset, load_dataset\n",
"\n",
"# Load your dataset from Excel file using pd.read_excel\n",
"df = pd.read_excel('/content/drive/MyDrive/TTS_Eng/TTS-English.xlsx')\n",
"# Convert the pandas DataFrame to a Hugging Face Dataset\n",
"dataset = Dataset.from_pandas(df)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "K8YzZRrPf6mz",
"outputId": "109e7328-faa4-4274-fef3-ae2c1e628106"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting datasets\n",
" Downloading datasets-3.0.2-py3-none-any.whl.metadata (20 kB)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from datasets) (3.16.1)\n",
"Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from datasets) (1.26.4)\n",
"Requirement already satisfied: pyarrow>=15.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (16.1.0)\n",
"Collecting dill<0.3.9,>=0.3.0 (from datasets)\n",
" Downloading dill-0.3.8-py3-none-any.whl.metadata (10 kB)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets) (2.2.2)\n",
"Requirement already satisfied: requests>=2.32.2 in /usr/local/lib/python3.10/dist-packages (from datasets) (2.32.3)\n",
"Requirement already satisfied: tqdm>=4.66.3 in /usr/local/lib/python3.10/dist-packages (from datasets) (4.66.5)\n",
"Collecting xxhash (from datasets)\n",
" Downloading xxhash-3.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (12 kB)\n",
"Collecting multiprocess<0.70.17 (from datasets)\n",
" Downloading multiprocess-0.70.16-py310-none-any.whl.metadata (7.2 kB)\n",
"Requirement already satisfied: fsspec<=2024.9.0,>=2023.1.0 in /usr/local/lib/python3.10/dist-packages (from fsspec[http]<=2024.9.0,>=2023.1.0->datasets) (2024.6.1)\n",
"Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets) (3.10.10)\n",
"Requirement already satisfied: huggingface-hub>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.24.7)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from datasets) (24.1)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (6.0.2)\n",
"Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (2.4.3)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.3.1)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (24.2.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.4.1)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (6.1.0)\n",
"Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.15.4)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (4.0.3)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.23.0->datasets) (4.12.2)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (3.4.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (3.10)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (2.2.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (2024.8.30)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2024.2)\n",
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2024.2)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas->datasets) (1.16.0)\n",
"Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.12.0->aiohttp->datasets) (0.2.0)\n",
"Downloading datasets-3.0.2-py3-none-any.whl (472 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m472.7/472.7 kB\u001b[0m \u001b[31m12.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading dill-0.3.8-py3-none-any.whl (116 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m116.3/116.3 kB\u001b[0m \u001b[31m7.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading multiprocess-0.70.16-py310-none-any.whl (134 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.8/134.8 kB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading xxhash-3.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (194 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m194.1/194.1 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hInstalling collected packages: xxhash, dill, multiprocess, datasets\n",
"Successfully installed datasets-3.0.2 dill-0.3.8 multiprocess-0.70.16 xxhash-3.5.0\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"len(dataset)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "k7SgmYMUUSSj",
"outputId": "1a9f1ee6-58d5-406a-a921-a39647c5e0c3"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"133"
]
},
"metadata": {},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"source": [
"!pip install transformers\n",
"from transformers import AutoProcessor\n",
"\n",
"# Assuming you want to use a specific processor, replace \"facebook/wav2vec2-base-960h\" with the desired model\n",
"processor = AutoProcessor.from_pretrained(\"facebook/wav2vec2-base-960h\")\n",
"\n",
"tokenizer = processor.tokenizer"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 527,
"referenced_widgets": [
"bf0d33ef88d6454a9a4ea5a78883d9e9",
"b0700ca20203401fa7e2eb9a2b60aa0f",
"4225f3ecaa9046519340846aaba8616a",
"09b941636ca64b238d3e0a761573f45e",
"f2c3e3edbf5040be97bc87c1711d31bc",
"9b6cbb6586b24fa095476410bc1d80b9",
"cd3f004541194be29b29c99864fcf146",
"d4f6744cd7ce4a57aa784fbbee4c0621",
"7aaba4f57f7d4effbbf66933c1ebc61b",
"9f8c7e1a0b5e4942855b6a2143e1eed7",
"3805153ecfb743ffbb0e337a77004560",
"36f8c5fce0fb4b93be7295042913e208",
"7f3217a296c04423804d8290a17e946a",
"0429e54da0404f4298c47efe1c6b66e2",
"50b8cc6f892b4a149494951839bd3993",
"42e0f0238e9149468a716b765dc8baff",
"a81d5a2e37f945fca8b0cda4bdab0b91",
"22c4ce4eac7542409c62d058825e761c",
"2294bcb50eef48e698d6723958af9c94",
"56dc4123de544d50a9d5dde76876e00b",
"151b4d2db3bc4797ad977f722806ed64",
"692a45c766aa43acb1b7f7ad7ee1772d",
"4f20b5912c994e3986d3c4d30eb99143",
"a1c4cf9ad32b49a4996fbb3f321745a9",
"60183325ec9c4bb1967e83fe3be5dd32",
"369ff789de224c6f910cf8758420f0c8",
"f42a309ff1994451b50cf9d49d1f7a6d",
"f115fc561c044c8c9d79f1a189766fcf",
"5f5a995405d84c1b80ee0b22ad955696",
"79c5b6542ba34375a8f44d54709bab45",
"95ce8dec3e7f49b4b3311e7739da70d5",
"0d5030b6ed24403da75989467066f260",
"ef78e68136b448d3b8b603040e2de130",
"520715b2218b45068326603a6639746c",
"d30d15c3d0b745eda19f46e4c9c1d6c6",
"9f452748eb134bc0ac00f4038fd45a88",
"a3d6d1ae1a764fa782c5e42bc07823ba",
"db4f5325442b47f68cc0dfe18a4113b1",
"37dc19476c7c466482cac9c4509b3ad5",
"d01f1c3db49845a8bdb69a2cd8613018",
"48b70ae7b3a346ceac5a48b36fbddffc",
"e7716f8922284f30bd33b605ba90940e",
"38c3bbe6735e4bdf99263c6251a79eeb",
"6e90888770ce4e919567ec299fe5c28e",
"ef48464237604789b200054eaa4a23d9",
"5bc9d68ab2a04312a5a9d4b5977fd691",
"7586d1a50f924338887b3d66b6a7947a",
"c6cbd5b7493746299e01d7b7a3a1e3be",
"ab76bf76b190487b96317ce4f4583ae6",
"b37be5cbddd94530bac98f7f2301ac6d",
"8f51b4c1f2b043d4b640baf4a8cec808",
"c62b866ecf204cb3803f0226d166d213",
"f0aa4b397e3c402cbfb4d1c3af8aacf6",
"d05fe02294354059a6ce512f94ff1b17",
"1397290d20c44f67b51176023c0090bb"
]
},
"id": "ZyUozQcJV0w2",
"outputId": "44da5f87-59e3-4bc1-a64f-3582c58602af"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.44.2)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers) (3.16.1)\n",
"Requirement already satisfied: huggingface-hub<1.0,>=0.23.2 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.24.7)\n",
"Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (1.26.4)\n",
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers) (24.1)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (6.0.2)\n",
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2024.9.11)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers) (2.32.3)\n",
"Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.4.5)\n",
"Requirement already satisfied: tokenizers<0.20,>=0.19 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.19.1)\n",
"Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers) (4.66.5)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.23.2->transformers) (2024.6.1)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.23.2->transformers) (4.12.2)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.4.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.10)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2.2.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2024.8.30)\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"preprocessor_config.json: 0%| | 0.00/159 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "bf0d33ef88d6454a9a4ea5a78883d9e9"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"tokenizer_config.json: 0%| | 0.00/163 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "36f8c5fce0fb4b93be7295042913e208"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"config.json: 0%| | 0.00/1.60k [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "4f20b5912c994e3986d3c4d30eb99143"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"vocab.json: 0%| | 0.00/291 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "520715b2218b45068326603a6639746c"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"special_tokens_map.json: 0%| | 0.00/85.0 [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "ef48464237604789b200054eaa4a23d9"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted in transformers v4.45, and will be then set to `False` by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884\n",
" warnings.warn(\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"import pandas as pd\n",
"from datasets import Dataset, load_dataset\n",
"\n",
"# Load your dataset from Excel file using pd.read_excel\n",
"df = pd.read_excel('/content/drive/MyDrive/TTS_Eng/TTS-English.xlsx')\n",
"# Convert the pandas DataFrame to a Hugging Face Dataset\n",
"dataset = Dataset.from_pandas(df)\n",
"\n",
"tokenizer = processor.tokenizer\n",
"\n",
"def extract_all_chars(batch):\n",
" text_examples = [text for text in batch[\"Text Example\"] if text is not None]\n",
" all_text = \" \".join(text_examples)\n",
" vocab = list(set(all_text))\n",
" return {\"vocab\": [vocab], \"all_text\": [all_text]}\n",
"\n",
"# Only remove unnecessary columns, but keep the text column\n",
"vocabs = dataset.map(\n",
" extract_all_chars,\n",
" batched=True,\n",
" batch_size=-1,\n",
" keep_in_memory=True,\n",
" # Instead of removing all columns, specify only the ones you want to remove.\n",
" # Replace with the actual columns you want to remove if needed.\n",
" remove_columns=[col for col in dataset.column_names if col != \"transcript\"],\n",
")\n",
"\n",
"dataset_vocab = set(vocabs[\"vocab\"][0])\n",
"tokenizer_vocab = {k for k,_ in tokenizer.get_vocab().items()}"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 49,
"referenced_widgets": [
"3659e5c8996d42ccbd6b165960b6ebcb",
"221fa7adbd3046fa813a272a333f0a58",
"1c65128e06bd45ddafbb996947f4746d",
"11faa4b79c774470a6256e5bed9fc606",
"038fbc256aa943818c51112507e502f7",
"f3ba4f7daed0414b8c28cc7354af8d99",
"d17f3eb739dd479b80a7ef85471b7937",
"ed20aaccf62041a6a3fdaef43fc0b9f7",
"ae882f381a714169a48f4d34124c6d02",
"c1f6fb263ee04e1482b3d95414abb0a1",
"c607e763b8b940e6afbe677799d79fa6"
]
},
"id": "_7K8SGgLgohy",
"outputId": "b1e65d74-316e-4fda-eeb5-b461dca82aa5"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Map: 0%| | 0/133 [00:00, ? examples/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "3659e5c8996d42ccbd6b165960b6ebcb"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"dataset_vocab - tokenizer_vocab"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "KuF4QM_DV8RK",
"outputId": "17ef0ff3-3914-4a50-dd66-475b943df7a9"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"{' ',\n",
" '\"',\n",
" '%',\n",
" ',',\n",
" '-',\n",
" '.',\n",
" '0',\n",
" '2',\n",
" '4',\n",
" '5',\n",
" 'a',\n",
" 'b',\n",
" 'c',\n",
" 'd',\n",
" 'e',\n",
" 'f',\n",
" 'g',\n",
" 'h',\n",
" 'i',\n",
" 'j',\n",
" 'k',\n",
" 'l',\n",
" 'm',\n",
" 'n',\n",
" 'o',\n",
" 'p',\n",
" 'q',\n",
" 'r',\n",
" 's',\n",
" 't',\n",
" 'u',\n",
" 'v',\n",
" 'w',\n",
" 'x',\n",
" 'y',\n",
" 'z',\n",
" '’'}"
]
},
"metadata": {},
"execution_count": 16
}
]
},
{
"cell_type": "code",
"source": [
"replacements = [\n",
" ('à', 'a'),\n",
" ('ç', 'c'),\n",
" ('è', 'e'),\n",
" ('ë', 'e'),\n",
" ('í', 'i'),\n",
" ('ï', 'i'),\n",
" ('ö', 'o'),\n",
" ('ü', 'u'),\n",
" ('’', \"'\"), # Replacing curly apostrophe with a standard one\n",
" ('%', ''), # Option to remove the percentage symbol\n",
" ('0', '0'), # Keep 0 as it is (no change)\n",
" ('2', '2'), # Keep 2 as it is (no change)\n",
" ('4', '4'), # Keep 4 as it is (no change)\n",
" ('5', '5'), # Keep 5 as it is (no change)\n",
" (' ', ' ') # Ensure spaces remain unchanged\n",
"]\n",
"\n",
"def cleanup_text(inputs):\n",
" text_column_name = \"Text Example\" # Update with the correct column name from your dataset\n",
" # Check if the value is not None using the correct column name\n",
" if inputs[text_column_name] is not None:\n",
" for src, dst in replacements:\n",
" # Update this line to use the correct column name\n",
" inputs[text_column_name] = inputs[text_column_name].replace(src, dst)\n",
" return inputs\n",
"\n",
"# Apply the function to the dataset\n",
"dataset = dataset.map(cleanup_text)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 49,
"referenced_widgets": [
"25e3bbaabea54530b09017d1b89614c2",
"bc2c8c6b5a63418cbf967553012c6fb2",
"1838da789aae4c07874c9d3b777dde5a",
"a6b1e677a10b4d2ca91dd2e9da1d7aea",
"cceb7ceda8f94f9d87c62562f6803efe",
"35d690584d9942c5922d17b3d6efda15",
"ec18c6121c734b7788387cb7eb903657",
"370e5ff52db4411d914bbaa5a2ccc5d3",
"6a467e0fbed14e63b7884a8abd3c802b",
"b0f3fa5644784a39b02491fd820d4868",
"d413f0963826479cabada7a15c680ce5"
]
},
"id": "0snxxfPdje6w",
"outputId": "46aed7b0-d27b-42f2-fd33-d45547d40a50"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Map: 0%| | 0/133 [00:00, ? examples/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "25e3bbaabea54530b09017d1b89614c2"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"!pip install speechbrain\n",
"import os\n",
"import torch\n",
"from speechbrain.pretrained import EncoderClassifier\n",
"\n",
"spk_model_name = \"speechbrain/spkrec-xvect-voxceleb\"\n",
"\n",
"device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
"speaker_model = EncoderClassifier.from_hparams(\n",
" source=spk_model_name,\n",
" run_opts={\"device\": device},\n",
" savedir=os.path.join(\"/tmp\", spk_model_name),\n",
")\n",
"\n",
"\n",
"def create_speaker_embedding(waveform):\n",
" with torch.no_grad():\n",
" speaker_embeddings = speaker_model.encode_batch(torch.tensor(waveform))\n",
" speaker_embeddings = torch.nn.functional.normalize(speaker_embeddings, dim=2)\n",
" speaker_embeddings = speaker_embeddings.squeeze().cpu().numpy()\n",
" return speaker_embeddings"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000,
"referenced_widgets": [
"fa8757aaa0a741cf839b9241c827d971",
"b13821240ecc45a385b2a2b1effa86f7",
"e68376643bcf4350b60e91f57784a5bd",
"c43dde973e8e437185ae3fc4a70223e7",
"408e99ba3be2433eaed5461ad9f09867",
"e62bf5257aec4e688b52a275fd157da3",
"cab5270d6de94e1592d9bda2e2cdfe1a",
"624ab1702ede421682fa47530ed99913",
"e58492565fa045fbaf0d9052e8574922",
"6dafbc1cdbbd4a099ded9ed44e88fc50",
"ea9dc779cb664fb7835a0d5a132f82f1",
"1289e1adffb040c79930ab4709dc7224",
"bbf4f9046aa24a69b65d2361081f0288",
"50dae551f435430f9e95905c36a5d9e3",
"c33e6a32b0634c7ea1b1131127475fdf",
"92e09ba91998416a9797b0f1def75add",
"ff4914ff0f924cb18d743ecb8f10fec4",
"74d02c59834942b69fa4c9b80b09f48a",
"50d58beaee4442b4a69197fea3f1d442",
"942355e5534f4404899e18436e07fa30",
"d158d0fac7674b45a58d83924abbc07c",
"fc0e64fad426421896620ac66dcafa63",
"2d381129b2474b9ca0227cd790c4439b",
"14bbec4c5e7f4f11b4bf1c6387991a7d",
"a85c5408987049d893af6c46b40b4ee6",
"b962c1297c6540659780411a92632a5f",
"737785d6a113473c8e7aec888505713b",
"630d28962ac542659f4c424f385a65f4",
"d39893e895c54010bf6f2aa00ec1d8d2",
"2263fcc46a3346c499619903ef1309c8",
"8c4a3e2f5e0241b5bb88c2871d2bfb10",
"1de033bae98c4f718c133b34c74f07a6",
"32804329bfe34cc0adb781561a371878",
"30b68f4079514c8db53790ed98a57a0f",
"fd93f9dfc78e495f8d8c1de4ad4399fe",
"73576e72b9164e7f87ff44b0200e4b7e",
"b4e4186c328147d3b71ef5444f59f78f",
"72e6d7b5d2b0416a8014b15f2c0f131d",
"d8e396928f8e4cd49bb56fab121e0195",
"13de4de37676426b95639c1b1eb6cc90",
"e5f0d98066fa4f28851baa54938c861a",
"9bcba59f919341f7973cc6e842016a6d",
"09cba933c19345538cfe6985485f3f28",
"1980e08341ad43f4aab42dd43f033d09",
"8c4a1685d4af4fd2bd4e403a7c333744",
"d03b3cb3e8444b4f83ce92c4c8a12195",
"97c5de7959924eb39c57ec305cb7043d",
"28dc36b8a8b341e2adedefd37b394d00",
"e5dc20b4193d4bc2afe967914d46a7dd",
"ad2247b2855b4660a2e08ebb1f005182",
"331fb19489804a7097effd9eca84a310",
"b9c1f6499f214190b4b9f90fa32c9049",
"95f57a74b13b4d0ab1102be0f45e3c3d",
"27a28aff2f464af58bf82bb65f4662ab",
"d610309145cf47fcbf587ba4ea6f6c10"
]
},
"id": "j-izN78sjlR9",
"outputId": "0518403a-2cbc-4d96-e7fc-e8611c1e5263"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting speechbrain\n",
" Downloading speechbrain-1.0.1-py3-none-any.whl.metadata (24 kB)\n",
"Collecting hyperpyyaml (from speechbrain)\n",
" Downloading HyperPyYAML-1.2.2-py3-none-any.whl.metadata (7.6 kB)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from speechbrain) (1.4.2)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from speechbrain) (1.26.4)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from speechbrain) (24.1)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from speechbrain) (1.13.1)\n",
"Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (from speechbrain) (0.2.0)\n",
"Requirement already satisfied: torch>=1.9 in /usr/local/lib/python3.10/dist-packages (from speechbrain) (2.4.1+cu121)\n",
"Requirement already satisfied: torchaudio in /usr/local/lib/python3.10/dist-packages (from speechbrain) (2.4.1+cu121)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from speechbrain) (4.66.5)\n",
"Requirement already satisfied: huggingface-hub in /usr/local/lib/python3.10/dist-packages (from speechbrain) (0.24.7)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch>=1.9->speechbrain) (3.16.1)\n",
"Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.10/dist-packages (from torch>=1.9->speechbrain) (4.12.2)\n",
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch>=1.9->speechbrain) (1.13.3)\n",
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch>=1.9->speechbrain) (3.4.1)\n",
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=1.9->speechbrain) (3.1.4)\n",
"Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch>=1.9->speechbrain) (2024.6.1)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub->speechbrain) (6.0.2)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub->speechbrain) (2.32.3)\n",
"Collecting ruamel.yaml>=0.17.28 (from hyperpyyaml->speechbrain)\n",
" Downloading ruamel.yaml-0.18.6-py3-none-any.whl.metadata (23 kB)\n",
"Collecting ruamel.yaml.clib>=0.2.7 (from ruamel.yaml>=0.17.28->hyperpyyaml->speechbrain)\n",
" Downloading ruamel.yaml.clib-0.2.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.7 kB)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.9->speechbrain) (3.0.2)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub->speechbrain) (3.4.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub->speechbrain) (3.10)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub->speechbrain) (2.2.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub->speechbrain) (2024.8.30)\n",
"Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from sympy->torch>=1.9->speechbrain) (1.3.0)\n",
"Downloading speechbrain-1.0.1-py3-none-any.whl (807 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m807.2/807.2 kB\u001b[0m \u001b[31m16.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading HyperPyYAML-1.2.2-py3-none-any.whl (16 kB)\n",
"Downloading ruamel.yaml-0.18.6-py3-none-any.whl (117 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m117.8/117.8 kB\u001b[0m \u001b[31m9.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading ruamel.yaml.clib-0.2.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (722 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m722.2/722.2 kB\u001b[0m \u001b[31m30.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hInstalling collected packages: ruamel.yaml.clib, ruamel.yaml, hyperpyyaml, speechbrain\n",
"Successfully installed hyperpyyaml-1.2.2 ruamel.yaml-0.18.6 ruamel.yaml.clib-0.2.12 speechbrain-1.0.1\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"