{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "gpuType": "T4" }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "source": [ "# ADAPTING THE ADAPTERS FOR CODE-SWITCHING IN MULTILINGUAL ASR" ], "metadata": { "id": "d8Xbx-NnPRb5" } }, { "cell_type": "markdown", "source": [ "### Clone the repo\n" ], "metadata": { "id": "8YyJ22u_GvHL" } }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "wkX5HmEcM9fm", "outputId": "c1022ab5-c638-45a4-9a3f-deef589310c6" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Cloning into 'MMS-Code-Switching'...\n", "remote: Enumerating objects: 3819, done.\u001b[K\n", "remote: Counting objects: 100% (3819/3819), done.\u001b[K\n", "remote: Compressing objects: 100% (2739/2739), done.\u001b[K\n", "remote: Total 3819 (delta 1030), reused 3816 (delta 1027), pack-reused 0\u001b[K\n", "Receiving objects: 100% (3819/3819), 25.59 MiB | 21.63 MiB/s, done.\n", "Resolving deltas: 100% (1030/1030), done.\n" ] } ], "source": [ "!git clone https://github.com/Atharva7K/MMS-Code-Switching.git" ] }, { "cell_type": "markdown", "source": [ "## Install modified transformers code" ], "metadata": { "id": "FXUijlVFGzcE" } }, { "cell_type": "code", "source": [ "%cd /content/MMS-Code-Switching/transformers\n", "%pip install -e ." ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Y8Frf-UJPEMA", "outputId": "79bb8dec-dd0b-47e6-c6fa-175e5dfb2668" }, "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/content/MMS-Code-Switching/transformers\n", "Obtaining file:///content/MMS-Code-Switching/transformers\n", " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", " Checking if build backend supports build_editable ... \u001b[?25l\u001b[?25hdone\n", " Getting requirements to build editable ... \u001b[?25l\u001b[?25hdone\n", " Preparing editable metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers==4.32.0.dev0) (3.12.2)\n", "Collecting huggingface-hub<1.0,>=0.14.1 (from transformers==4.32.0.dev0)\n", " Downloading huggingface_hub-0.17.2-py3-none-any.whl (294 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m294.9/294.9 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from transformers==4.32.0.dev0) (1.23.5)\n", "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers==4.32.0.dev0) (23.1)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers==4.32.0.dev0) (6.0.1)\n", "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers==4.32.0.dev0) (2023.6.3)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers==4.32.0.dev0) (2.31.0)\n", "Collecting tokenizers!=0.11.3,<0.14,>=0.11.1 (from transformers==4.32.0.dev0)\n", " Downloading tokenizers-0.13.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.8 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m33.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting safetensors>=0.3.1 (from transformers==4.32.0.dev0)\n", " Downloading safetensors-0.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m59.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers==4.32.0.dev0) (4.66.1)\n", "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.14.1->transformers==4.32.0.dev0) (2023.6.0)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.14.1->transformers==4.32.0.dev0) (4.5.0)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.32.0.dev0) (3.2.0)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.32.0.dev0) (3.4)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.32.0.dev0) (2.0.4)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.32.0.dev0) (2023.7.22)\n", "Building wheels for collected packages: transformers\n", " Building editable for transformers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", " Created wheel for transformers: filename=transformers-4.32.0.dev0-0.editable-py3-none-any.whl size=37394 sha256=210e0a90432f70f6a3c8109a0b080f164da9ae18f76943a9cabdbce401f893ea\n", " Stored in directory: /tmp/pip-ephem-wheel-cache-f6ao8vw8/wheels/f0/96/a2/a4b90b4ff787d05e44e338fda6a4d3056126e50df2d8f9b60e\n", "Successfully built transformers\n", "Installing collected packages: tokenizers, safetensors, huggingface-hub, transformers\n", "Successfully installed huggingface-hub-0.17.2 safetensors-0.3.3 tokenizers-0.13.3 transformers-4.32.0.dev0\n" ] } ] }, { "cell_type": "markdown", "source": [ "### Install other dependancies" ], "metadata": { "id": "5i5LSpyhG61L" } }, { "cell_type": "code", "source": [ "%cd /content/MMS-Code-Switching/\n", "%pip install -r requirements.txt" ], "metadata": { "id": "qlWioBLqNB2M", "colab": { "base_uri": "https://localhost:8080/", "height": 1000 }, "outputId": "16cff193-c3de-494c-840d-5e7e1daf3bd8" }, "execution_count": 3, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/content/MMS-Code-Switching\n", "Collecting accelerate==0.20.3 (from -r requirements.txt (line 1))\n", " Downloading accelerate-0.20.3-py3-none-any.whl (227 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m227.6/227.6 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting datasets==2.14.4 (from -r requirements.txt (line 2))\n", " Downloading datasets-2.14.4-py3-none-any.whl (519 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m519.3/519.3 kB\u001b[0m \u001b[31m11.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: editdistance==0.6.2 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 3)) (0.6.2)\n", "Collecting evaluate==0.4.0 (from -r requirements.txt (line 4))\n", " Downloading evaluate-0.4.0-py3-none-any.whl (81 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m81.4/81.4 kB\u001b[0m \u001b[31m6.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: jieba==0.42.1 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 5)) (0.42.1)\n", "Collecting jiwer==3.0.2 (from -r requirements.txt (line 6))\n", " Downloading jiwer-3.0.2-py3-none-any.whl (21 kB)\n", "Collecting librosa==0.10.0.post2 (from -r requirements.txt (line 7))\n", " Downloading librosa-0.10.0.post2-py3-none-any.whl (253 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m253.0/253.0 kB\u001b[0m \u001b[31m12.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting numba==0.57.1 (from -r requirements.txt (line 8))\n", " Downloading numba-0.57.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.6 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.6/3.6 MB\u001b[0m \u001b[31m31.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting numpy==1.24.4 (from -r requirements.txt (line 9))\n", " Downloading numpy-1.24.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m17.3/17.3 MB\u001b[0m \u001b[31m75.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting pandas==2.0.3 (from -r requirements.txt (line 10))\n", " Downloading pandas-2.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.3/12.3 MB\u001b[0m \u001b[31m72.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting safetensors==0.3.2 (from -r requirements.txt (line 11))\n", " Downloading safetensors-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m72.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting scikit-learn==1.3.0 (from -r requirements.txt (line 12))\n", " Downloading scikit_learn-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.8 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.8/10.8 MB\u001b[0m \u001b[31m114.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: soundfile==0.12.1 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 13)) (0.12.1)\n", "Requirement already satisfied: torch==2.0.1 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 14)) (2.0.1+cu118)\n", "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from accelerate==0.20.3->-r requirements.txt (line 1)) (23.1)\n", "Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from accelerate==0.20.3->-r requirements.txt (line 1)) (5.9.5)\n", "Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from accelerate==0.20.3->-r requirements.txt (line 1)) (6.0.1)\n", "Requirement already satisfied: pyarrow>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets==2.14.4->-r requirements.txt (line 2)) (9.0.0)\n", "Collecting dill<0.3.8,>=0.3.0 (from datasets==2.14.4->-r requirements.txt (line 2))\n", " Downloading dill-0.3.7-py3-none-any.whl (115 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m115.3/115.3 kB\u001b[0m \u001b[31m12.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.10/dist-packages (from datasets==2.14.4->-r requirements.txt (line 2)) (2.31.0)\n", "Requirement already satisfied: tqdm>=4.62.1 in /usr/local/lib/python3.10/dist-packages (from datasets==2.14.4->-r requirements.txt (line 2)) (4.66.1)\n", "Collecting xxhash (from datasets==2.14.4->-r requirements.txt (line 2))\n", " Downloading xxhash-3.3.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[31m19.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting multiprocess (from datasets==2.14.4->-r requirements.txt (line 2))\n", " Downloading multiprocess-0.70.15-py310-none-any.whl (134 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.8/134.8 kB\u001b[0m \u001b[31m17.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: fsspec[http]>=2021.11.1 in /usr/local/lib/python3.10/dist-packages (from datasets==2.14.4->-r requirements.txt (line 2)) (2023.6.0)\n", "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets==2.14.4->-r requirements.txt (line 2)) (3.8.5)\n", "Requirement already satisfied: huggingface-hub<1.0.0,>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from datasets==2.14.4->-r requirements.txt (line 2)) (0.17.2)\n", "Collecting responses<0.19 (from evaluate==0.4.0->-r requirements.txt (line 4))\n", " Downloading responses-0.18.0-py3-none-any.whl (38 kB)\n", "Requirement already satisfied: click<9.0.0,>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from jiwer==3.0.2->-r requirements.txt (line 6)) (8.1.7)\n", "Collecting rapidfuzz==2.13.7 (from jiwer==3.0.2->-r requirements.txt (line 6))\n", " Downloading rapidfuzz-2.13.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.2/2.2 MB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: audioread>=2.1.9 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (3.0.0)\n", "Requirement already satisfied: scipy>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (1.11.2)\n", "Requirement already satisfied: joblib>=0.14 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (1.3.2)\n", "Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (4.4.2)\n", "Collecting pooch<1.7,>=1.0 (from librosa==0.10.0.post2->-r requirements.txt (line 7))\n", " Downloading pooch-1.6.0-py3-none-any.whl (56 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 kB\u001b[0m \u001b[31m6.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: soxr>=0.3.2 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (0.3.6)\n", "Requirement already satisfied: typing-extensions>=4.1.1 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (4.5.0)\n", "Requirement already satisfied: lazy-loader>=0.1 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (0.3)\n", "Requirement already satisfied: msgpack>=1.0 in /usr/local/lib/python3.10/dist-packages (from librosa==0.10.0.post2->-r requirements.txt (line 7)) (1.0.5)\n", "Collecting llvmlite<0.41,>=0.40.0dev0 (from numba==0.57.1->-r requirements.txt (line 8))\n", " Downloading llvmlite-0.40.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (42.1 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m42.1/42.1 MB\u001b[0m \u001b[31m12.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas==2.0.3->-r requirements.txt (line 10)) (2.8.2)\n", "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas==2.0.3->-r requirements.txt (line 10)) (2023.3.post1)\n", "Collecting tzdata>=2022.1 (from pandas==2.0.3->-r requirements.txt (line 10))\n", " Downloading tzdata-2023.3-py2.py3-none-any.whl (341 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m341.8/341.8 kB\u001b[0m \u001b[31m32.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn==1.3.0->-r requirements.txt (line 12)) (3.2.0)\n", "Requirement already satisfied: cffi>=1.0 in /usr/local/lib/python3.10/dist-packages (from soundfile==0.12.1->-r requirements.txt (line 13)) (1.15.1)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch==2.0.1->-r requirements.txt (line 14)) (3.12.2)\n", "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch==2.0.1->-r requirements.txt (line 14)) (1.12)\n", "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch==2.0.1->-r requirements.txt (line 14)) (3.1)\n", "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch==2.0.1->-r requirements.txt (line 14)) (3.1.2)\n", "Requirement already satisfied: triton==2.0.0 in /usr/local/lib/python3.10/dist-packages (from torch==2.0.1->-r requirements.txt (line 14)) (2.0.0)\n", "Requirement already satisfied: cmake in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch==2.0.1->-r requirements.txt (line 14)) (3.27.4.1)\n", "Requirement already satisfied: lit in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch==2.0.1->-r requirements.txt (line 14)) (16.0.6)\n", "Requirement already satisfied: pycparser in /usr/local/lib/python3.10/dist-packages (from cffi>=1.0->soundfile==0.12.1->-r requirements.txt (line 13)) (2.21)\n", "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets==2.14.4->-r requirements.txt (line 2)) (23.1.0)\n", "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets==2.14.4->-r requirements.txt (line 2)) (3.2.0)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets==2.14.4->-r requirements.txt (line 2)) (6.0.4)\n", "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets==2.14.4->-r requirements.txt (line 2)) (4.0.3)\n", "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets==2.14.4->-r requirements.txt (line 2)) (1.9.2)\n", "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets==2.14.4->-r requirements.txt (line 2)) (1.4.0)\n", "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets==2.14.4->-r requirements.txt (line 2)) (1.3.1)\n", "Requirement already satisfied: appdirs>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from pooch<1.7,>=1.0->librosa==0.10.0.post2->-r requirements.txt (line 7)) (1.4.4)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas==2.0.3->-r requirements.txt (line 10)) (1.16.0)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets==2.14.4->-r requirements.txt (line 2)) (3.4)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets==2.14.4->-r requirements.txt (line 2)) (2.0.4)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets==2.14.4->-r requirements.txt (line 2)) (2023.7.22)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch==2.0.1->-r requirements.txt (line 14)) (2.1.3)\n", "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch==2.0.1->-r requirements.txt (line 14)) (1.3.0)\n", "Installing collected packages: safetensors, xxhash, tzdata, rapidfuzz, numpy, llvmlite, dill, responses, pooch, pandas, numba, multiprocess, jiwer, scikit-learn, librosa, datasets, evaluate, accelerate\n", " Attempting uninstall: safetensors\n", " Found existing installation: safetensors 0.3.3\n", " Uninstalling safetensors-0.3.3:\n", " Successfully uninstalled safetensors-0.3.3\n", " Attempting uninstall: numpy\n", " Found existing installation: numpy 1.23.5\n", " Uninstalling numpy-1.23.5:\n", " Successfully uninstalled numpy-1.23.5\n", " Attempting uninstall: llvmlite\n", " Found existing installation: llvmlite 0.39.1\n", " Uninstalling llvmlite-0.39.1:\n", " Successfully uninstalled llvmlite-0.39.1\n", " Attempting uninstall: pooch\n", " Found existing installation: pooch 1.7.0\n", " Uninstalling pooch-1.7.0:\n", " Successfully uninstalled pooch-1.7.0\n", " Attempting uninstall: pandas\n", " Found existing installation: pandas 1.5.3\n", " Uninstalling pandas-1.5.3:\n", " Successfully uninstalled pandas-1.5.3\n", " Attempting uninstall: numba\n", " Found existing installation: numba 0.56.4\n", " Uninstalling numba-0.56.4:\n", " Successfully uninstalled numba-0.56.4\n", " Attempting uninstall: scikit-learn\n", " Found existing installation: scikit-learn 1.2.2\n", " Uninstalling scikit-learn-1.2.2:\n", " Successfully uninstalled scikit-learn-1.2.2\n", " Attempting uninstall: librosa\n", " Found existing installation: librosa 0.10.1\n", " Uninstalling librosa-0.10.1:\n", " Successfully uninstalled librosa-0.10.1\n", "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", "google-colab 1.0.0 requires pandas==1.5.3, but you have pandas 2.0.3 which is incompatible.\n", "tensorflow 2.13.0 requires numpy<=1.24.3,>=1.22, but you have numpy 1.24.4 which is incompatible.\u001b[0m\u001b[31m\n", "\u001b[0mSuccessfully installed accelerate-0.20.3 datasets-2.14.4 dill-0.3.7 evaluate-0.4.0 jiwer-3.0.2 librosa-0.10.0.post2 llvmlite-0.40.1 multiprocess-0.70.15 numba-0.57.1 numpy-1.24.4 pandas-2.0.3 pooch-1.6.0 rapidfuzz-2.13.7 responses-0.18.0 safetensors-0.3.2 scikit-learn-1.3.0 tzdata-2023.3 xxhash-3.3.0\n" ] }, { "output_type": "display_data", "data": { "application/vnd.colab-display-data+json": { "pip_warning": { "packages": [ "numpy" ] } } }, "metadata": {} } ] }, { "cell_type": "code", "source": [ "!pip install gdown" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rvaPyzXiPU_5", "outputId": "f1698a7b-0af8-4935-cb6e-56512c8db350" }, "execution_count": 4, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: gdown in /usr/local/lib/python3.10/dist-packages (4.6.6)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from gdown) (3.12.2)\n", "Requirement already satisfied: requests[socks] in /usr/local/lib/python3.10/dist-packages (from gdown) (2.31.0)\n", "Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from gdown) (1.16.0)\n", "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from gdown) (4.66.1)\n", "Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.10/dist-packages (from gdown) (4.11.2)\n", "Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4->gdown) (2.5)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (3.2.0)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (3.4)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (2.0.4)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (2023.7.22)\n", "Requirement already satisfied: PySocks!=1.5.7,>=1.5.6 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (1.7.1)\n" ] } ] }, { "cell_type": "markdown", "source": [ "### Download MUCS Transformer Code Switcher checkpoint" ], "metadata": { "id": "kIB4NyCHHBSL" } }, { "cell_type": "code", "source": [ "!gdown --fuzzy https://drive.google.com/file/d/1qs9cWSzNtFpA3Grqu_YoQl0c1uj1WvyI/view?usp=drive_link\n", "!mv /content/MMS-Code-Switching/pytorch_model.bin checkpoints/" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "iN_vuALhRNqG", "outputId": "9236837d-07d0-406e-95ae-4698dd7f11c0" }, "execution_count": 14, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Downloading...\n", "From: https://drive.google.com/uc?id=1qs9cWSzNtFpA3Grqu_YoQl0c1uj1WvyI\n", "To: /content/MMS-Code-Switching/pytorch_model.bin\n", "100% 3.92G/3.92G [00:45<00:00, 85.6MB/s]\n" ] } ] }, { "cell_type": "markdown", "source": [], "metadata": { "id": "h2SYpiuyZABY" } }, { "cell_type": "markdown", "source": [ "### Use inference script to generate transcripts. We use 6 audio samples from MUCS validation set for this demo." ], "metadata": { "id": "oTI6cQIDHHNR" } }, { "cell_type": "code", "source": [ "!python inference.py --test_metadata_csv_path \"sample_audio_mucs/metadata.csv\" --target_lang_1 eng --target_lang_2 hin --prefix_path \"/content/MMS-Code-Switching/sample_audio_mucs/\" --checkpoint_path \"/content/MMS-Code-Switching/checkpoints/\" --batch_size 32 --outfile_path \"output.csv\"" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ibphU4cbSR25", "outputId": "6088839f-b042-44bb-b701-a528605a8a42" }, "execution_count": 15, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Loading Dependancies..\n", "2023-09-19 20:17:48.215252: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n", "Loading Model and Processor..\n", "num_proc must be <= 6. Reducing num_proc to 6 for dataset of size 6.\n", "Map (num_proc=6): 100% 6/6 [00:09<00:00, 1.64s/ examples]\n", "vocab size ===== 219\n", "Wav2Vec2ForCTCWithAdapterSwitching(\n", " (wav2vec2): Wav2Vec2Model(\n", " (feature_extractor): Wav2Vec2FeatureEncoder(\n", " (conv_layers): ModuleList(\n", " (0): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(1, 512, kernel_size=(10,), stride=(5,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " (activation): GELUActivation()\n", " )\n", " (1-4): 4 x Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " (activation): GELUActivation()\n", " )\n", " (5-6): 2 x Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(2,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " (activation): GELUActivation()\n", " )\n", " )\n", " )\n", " (feature_projection): Wav2Vec2FeatureProjection(\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " (projection): Linear(in_features=512, out_features=1280, bias=True)\n", " (dropout): Dropout(p=0.0, inplace=False)\n", " )\n", " (encoder): Wav2Vec2EncoderStableLayerNorm(\n", " (pos_conv_embed): Wav2Vec2PositionalConvEmbedding(\n", " (conv): Conv1d(1280, 1280, kernel_size=(128,), stride=(1,), padding=(64,), groups=16)\n", " (padding): Wav2Vec2SamePadLayer()\n", " (activation): GELUActivation()\n", " )\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (dropout): Dropout(p=0.0, inplace=False)\n", " (code_switcher): TransformerCodeSwitcher(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.0, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): CodeSwitcherFeedForward(\n", " (sigmoid): Sigmoid()\n", " (intermediate_dropout): Dropout(p=0.05, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (intermediate_act_fn): GELUActivation()\n", " (output_dense): Linear(in_features=5120, out_features=1, bias=True)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (layers): ModuleList(\n", " (0-47): 48 x Wav2Vec2EncoderLayerStableLayerNormForCodeSwitching(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.0, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.05, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (intermediate_act_fn): GELUActivation()\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.0, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (adapter_layer_1): Wav2Vec2AttnAdapterLayer(\n", " (norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (linear_1): Linear(in_features=1280, out_features=16, bias=True)\n", " (act_fn): ReLU()\n", " (linear_2): Linear(in_features=16, out_features=1280, bias=True)\n", " )\n", " (adapter_layer_2): Wav2Vec2AttnAdapterLayer(\n", " (norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (linear_1): Linear(in_features=1280, out_features=16, bias=True)\n", " (act_fn): ReLU()\n", " (linear_2): Linear(in_features=16, out_features=1280, bias=True)\n", " )\n", " )\n", " )\n", " )\n", " )\n", " (dropout): Dropout(p=0.05, inplace=False)\n", " (lm_head): Linear(in_features=1280, out_features=219, bias=True)\n", ")\n", "Setting up training..\n", "Staring evaluation..\n", " 0% 0/1 [00:00\n", "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0file_nametranscriptionmms_model_transcription
00/content/MMS-Code-Switching/sample_audio_mucs/...लिबर ऑफिस impress में एक प्रस्तुति document बन...liberoffice impress में एक परस्तुति document ब...
11/content/MMS-Code-Switching/sample_audio_mucs/...इस tutorial में हम impress window के भागों के ...इस चीturl में हम impress वindoं के भागों के बा...
22/content/MMS-Code-Switching/sample_audio_mucs/...यहाँ हम अपने ऑपरेटिंग सिस्टम के रूप में gnu/li...यहाँ हम अपने oprating सystem के रूप में genu l...
33/content/MMS-Code-Switching/sample_audio_mucs/...चलिए अपनी प्रस्तुति प्रेजैटेशन sample impress ...चलिए अपनी प्रसतुति sample impres oपn करते हैंज...
44/content/MMS-Code-Switching/sample_audio_mucs/...चलिए देखते हैं कि screen पर क्या क्या हैबनय चलिए देखते हैं कि sकren पर कया कया है
55/content/MMS-Code-Switching/sample_audio_mucs/...मध्य में हम खाली जगह देखते है जोकि workspace ह...मध्य में हम खाली जगह देखते हैं जोकि work space...
\n", "
\n", "
\n", "\n", "
\n", " \n", "\n", " \n", "\n", " \n", "
\n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", " \n", "
\n", "
\n", " \n" ] }, "metadata": {}, "execution_count": 17 } ] } ] }