### TensorRT Installation Output Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_TensorRT_LLM.ipynb This output shows the process of downloading the TensorRT installation script and the subsequent installation of build tools and other necessary packages on an Ubuntu system. ```text Output: --2024-01-28 12:18:44-- https://github.com/shashikg/WhisperS2T/raw/main/install_tensorrt.sh Resolving github.com (github.com)... 140.82.114.3 Connecting to github.com (github.com)|140.82.114.3|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://raw.githubusercontent.com/shashikg/WhisperS2T/main/install_tensorrt.sh [following] --2024-01-28 12:18:44-- https://raw.githubusercontent.com/shashikg/WhisperS2T/main/install_tensorrt.sh Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1206 (1.2K) [text/plain] Saving to: ‘install_tensorrt.sh’ install_tensorrt.sh 100%[===================>] 1.18K --.-KB/s in 0s 2024-01-28 12:18:45 (68.4 MB/s) - ‘install_tensorrt.sh’ saved [1206/1206] ###########################[ Installing Build Tools ]########################## Hit:1 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ InRelease Hit:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease Hit:3 http://archive.ubuntu.com/ubuntu jammy InRelease Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease Hit:5 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:6 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Hit:7 https://ppa.launchpadcontent.net/c2d4u.team/c2d4u4.0+/ubuntu jammy InRelease Hit:8 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease Hit:9 https://ppa.launchpadcontent.net/graphics-drivers/ppa/ubuntu jammy InRelease Hit:10 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy InRelease Reading package lists... Done Reading package lists... Done Building dependency tree... Done Reading state information... Done build-essential is already the newest version (12.9ubuntu3). wget is already the newest version (1.21.2-2ubuntu1). ca-certificates is already the newest version (20230311ubuntu0.22.04.1). cmake is already the newest version (3.22.1-1ubuntu1.22.04.1). curl is already the newest version (7.81.0-1ubuntu1.15). gnupg2 is already the newest version (2.2.27-3ubuntu2.1). The following additional packages will be installed: libbabeltrace1 libc6-dbg libdebuginfod-common libdebuginfod1 libhiredis0.14 libipt2 libsource-highlight-common libsource-highlight4v5 Suggested packages: distcc | icecc gdb-doc gdbserver The following NEW packages will be installed: ccache gdb libbabeltrace1 libc6-dbg libdebuginfod-common libdebuginfod1 libhiredis0.14 libipt2 libsource-highlight-common libsource-highlight4v5 0 upgraded, 10 newly installed, 0 to remove and 81 not upgraded. Need to get 18.8 MB of archives. After this operation, 33.4 MB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libdebuginfod-common all 0.186-1build1 [7,878 B] Get:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libhiredis0.14 amd64 0.14.1-2 [32.8 kB] Get:3 http://archive.ubuntu.com/ubuntu jammy/universe amd64 ccache amd64 4.5.1-1 [495 kB] Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libbabeltrace1 amd64 1.5.8-2build1 [160 kB] ``` -------------------------------- ### Install system dependencies and WhisperS2T Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_CTranslate2.ipynb Updates the system's package list and installs essential libraries like libsndfile1 and ffmpeg. It then installs the WhisperS2T package from its GitHub repository. ```bash !apt-get update && apt-get install -y libsndfile1 ffmpeg !pip install -U git+https://github.com/shashikg/WhisperS2T.git ``` -------------------------------- ### Install MPI4PY Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_TensorRT_LLM.ipynb Installs the mpi4py library from a local source directory. ```bash Processing /tmp/mpi4py-3.1.5 Installing build dependencies ... [?25l[?25hdone Getting requirements to build wheel ... [?25l[?25hdone Installing backend dependencies ... [?25l[?25hdone Preparing metadata (pyproject.toml) ... [?25l[?25hdone Building wheels for collected packages: mpi4py Building wheel for mpi4py (pyproject.toml) ... [?25l[?25hdone Created wheel for mpi4py: filename=mpi4py-3.1.5-cp310-cp310-linux_x86_64.whl size=2746210 sha256=adb8e616a82eb29c5277bbcba9d0e195e5a470911b78680f18368c6e55216d97 Stored in directory: /root/.cache/pip/wheels/54/23/8d/2c18465d0c7f5d94d6b3ceca3fbbd63e823e38a7f012793810 Successfully built mpi4py Installing collected packages: mpi4py Successfully installed mpi4py-3.1.5 ``` -------------------------------- ### Install TensorRT-LLM Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_TensorRT_LLM.ipynb Installs the TensorRT-LLM package and its dependencies from the NVIDIA PyPI index. ```bash Looking in indexes: https://pypi.org/simple, https://pypi.nvidia.com Collecting tensorrt_llm==0.8.0.dev2024012301 Downloading https://pypi.nvidia.com/tensorrt-llm/tensorrt_llm-0.8.0.dev2024012301-cp310-cp310-linux_x86_64.whl (1063.3 MB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 GB 1.5 MB/s eta 0:00:00 [?25hCollecting accelerate==0.25.0 (from tensorrt_llm==0.8.0.dev2024012301) Downloading accelerate-0.25.0-py3-none-any.whl (265 kB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 265.7/265.7 kB 6.9 MB/s eta 0:00:00 [?25hRequirement already satisfied: build in /usr/local/lib/python3.10/dist-packages (from tensorrt_llm==0.8.0.dev2024012301) (1.0.3) Collecting colored (from tensorrt_llm==0.8.0.dev2024012301) Downloading colored-2.2.4-py3-none-any.whl (16 kB) Collecting cuda-python (from tensorrt_llm==0.8.0.dev2024012301) Downloading cuda_python-12.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.6 MB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23.6/23.6 MB 57.4 MB/s eta 0:00:00 [?25hCollecting diffusers==0.15.0 (from tensorrt_llm==0.8.0.dev2024012301) Downloading diffusers-0.15.0-py3-none-any.whl (851 kB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 851.8/851.8 kB 74.0 MB/s eta 0:00:00 [?25hCollecting lark (from tensorrt_llm==0.8.0.dev2024012301) Downloading lark-1.1.9-py3-none-any.whl (111 kB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 111.7/111.7 kB 17.3 MB/s eta 0:00:00 [?25hRequirement already satisfied: mpi4py in /usr/local/lib/python3.10/dist-packages (from tensorrt_llm==0.8.0.dev2024012301) (3.1.5) Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from tensorrt_llm==0.8.0.dev2024012301) (1.23.5) Collecting onnx>=1.12.0 (from tensorrt_llm==0.8.0.dev2024012301) Downloading onnx-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.7 MB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.7/15.7 MB 59.8 MB/s eta 0:00:00 [?25hCollecting polygraphy (from tensorrt_llm==0.8.0.dev2024012301) Downloading https://pypi.nvidia.com/polygraphy/polygraphy-0.49.0-py2.py3-none-any.whl (327 kB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 327.9/327.9 kB 35.2 MB/s eta 0:00:00 [?25hRequirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from tensorrt_llm==0.8.0.dev2024012301) (5.9.5) Collecting pynvml>=11.5.0 (from tensorrt_llm==0.8.0.dev2024012301) Downloading pynvml-11.5.0-py3-none-any.whl (53 kB)  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.1/53.1 kB 7.9 MB/s eta 0:00:00 ``` -------------------------------- ### Install Audio Packages on Ubuntu Source: https://github.com/shashikg/whispers2t/blob/main/README.md Install necessary audio packages (libsndfile1 and ffmpeg) on Ubuntu systems for audio file processing. ```sh apt-get install -y libsndfile1 ffmpeg ``` -------------------------------- ### Install TensorRT-LLM Backend Source: https://github.com/shashikg/whispers2t/blob/main/README.md Execute the provided bash script to install the TensorRT-LLM backend. For other systems or if the script fails, refer to the official TensorRT-LLM GitHub repository. ```sh bash /install_tensorrt.sh ``` -------------------------------- ### Install ipython_autotime Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_CTranslate2.ipynb Installs the ipython_autotime package, which can be used to automatically time code execution in IPython environments. Ensure you have pip installed. ```python !pip install ipython_autotime ``` -------------------------------- ### Install WhisperS2T from Latest Commit Source: https://github.com/shashikg/whispers2t/blob/main/README.md Install the WhisperS2T package directly from the latest commit in the GitHub repository using pip. ```sh pip install -U git+https://github.com/shashikg/WhisperS2T.git ``` -------------------------------- ### Download and Execute TensorRT Installation Script Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_TensorRT_LLM.ipynb Downloads the install_tensorrt.sh script using wget and then executes it with bash. This script is necessary for setting up TensorRT, which is a prerequisite for optimized performance. ```bash !wget https://github.com/shashikg/WhisperS2T/raw/main/install_tensorrt.sh !bash install_tensorrt.sh ``` -------------------------------- ### Install FFmpeg on MAC Source: https://github.com/shashikg/whispers2t/blob/main/README.md Install FFmpeg on macOS using Homebrew for audio file processing. ```sh brew install ffmpeg ``` -------------------------------- ### Install WhisperS2T and Dependencies Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_TensorRT_LLM.ipynb Installs the whisper-s2t and openai-whisper packages along with their dependencies using pip. It also notes potential dependency conflicts. ```bash pip install --upgrade pip pip install -r requirements.txt ``` -------------------------------- ### Transcribe Audio with VAD using TensorRT-LLM Backend Source: https://github.com/shashikg/whispers2t/blob/main/README.md Perform speech-to-text transcription on audio files using the loaded model with VAD enabled. This example demonstrates specifying language codes, tasks, and initial prompts. The output contains text, start, and end times for each utterance. ```python files = ['data/KINCAID46/audio/1.wav'] lang_codes = ['en'] tasks = ['transcribe'] initial_prompts = [None] out = model.transcribe_with_vad(files, lang_codes=lang_codes, tasks=tasks, initial_prompts=initial_prompts, batch_size=24) print(out[0][0]) # Print first utterance for first file ``` -------------------------------- ### Install FFmpeg with Conda Source: https://github.com/shashikg/whispers2t/blob/main/README.md Install FFmpeg using Conda, which is compatible with Ubuntu, MAC, Windows, and other systems. ```sh conda install conda-forge::ffmpeg ``` -------------------------------- ### Install Latest WhisperS2T Release Source: https://github.com/shashikg/whispers2t/blob/main/README.md Install or update to the latest released version of the WhisperS2T Python package using pip. ```sh pip install -U whisper-s2t ``` -------------------------------- ### Displaying Processing Time Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_CTranslate2.ipynb This output indicates the total time taken for a processing step, including the start time. ```text time: 39.6 s (started: 2024-01-28 12:02:33 +00:00) ``` -------------------------------- ### Build Docker Container with TensorRT-LLM Support Source: https://github.com/shashikg/whispers2t/blob/main/README.md Build a Docker container from the main branch with TensorRT-LLM support enabled. This command assumes the TensorRT-LLM installation script is available. ```sh docker build --build-arg WHISPER_S2T_VER=main -t whisper_s2t:main-trtllm . ``` -------------------------------- ### Load WhisperS2T Model with TensorRT-LLM Backend Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_TensorRT_LLM.ipynb Load the WhisperS2T model using the specified identifier and backend. Ensure TensorRT-LLM is installed and configured. ```python import whisper_s2t model = whisper_s2t.load_model(model_identifier="large-v2", backend='TensorRT-LLM') ``` -------------------------------- ### Displaying Total Transcription Time Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_CTranslate2.ipynb This output indicates the total time taken for the transcription process, including the start time. ```text time: 3min 22s (started: 2024-01-28 12:03:24 +00:00) ``` -------------------------------- ### Return Word-Alignments with CTranslate2/TensorRT Source: https://github.com/shashikg/whispers2t/blob/main/docs.md Use this for CTranslate2 and TensorRT backends to get word-level timestamps. Ensure 'word_timestamps': True is set in ASR options. ```python import whisper_s2t model = whisper_s2t.load_model(model_identifier="large-v2", asr_options={'word_timestamps': True}) files = ['sample_1.wav'] lang_codes = ['en'] tasks = ['transcribe'] initial_prompts = [None] out = model.transcribe_with_vad(files, lang_codes=lang_codes, # pass lang_codes for each file tasks=tasks, # pass transcribe/translate initial_prompts=initial_prompts, # to do prompting (currently only supported for CTranslate2 backend) batch_size=24) print(out[0][0]) # Print first utterance for first file ``` -------------------------------- ### Set LD_LIBRARY_PATH for CUDNN and CUBLAS Source: https://github.com/shashikg/whispers2t/blob/main/README.md Export the LD_LIBRARY_PATH environment variable to include CUDNN and CUBLAS library paths, typically needed when installations are done via pip wheels. ```sh export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:`python3 -c 'import os; import nvidia.cublas.lib; import nvidia.cudnn.lib; print(os.path.dirname(nvidia.cublas.lib.__file__) + ":" + os.path.dirname(nvidia.cudnn.lib.__file__))'` ``` -------------------------------- ### Transcription Result Output Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_CTranslate2.ipynb This is the output of the transcription, showing the transcribed text, average log probability, probability of no speech, start time, and end time for a segment of the audio. ```text {'text': 'We have been a misunderstood and badly mocked org for a long time. Like when we started, we like announced the org at the end of 2015 and said we were going to work on AGI, like people thought we were batshit insane. Yeah. You know, like I remember at the time an eminent AI scientist at a', 'avg_logprob': -0.26604661215906555, 'no_speech_prob': 0.0018663406372070312, 'start_time': 0.0, 'end_time': 21.26} time: 823 µs (started: 2024-01-28 12:10:14 +00:00) ``` -------------------------------- ### Download Audio File Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_CTranslate2.ipynb Downloads a sample audio file from Hugging Face using wget. ```bash !wget https://huggingface.co/datasets/reach-vb/random-audios/resolve/main/sam_altman_lex_podcast_367.flac ``` -------------------------------- ### Load and Preprocess Audio Files Source: https://context7.com/shashikg/whispers2t/llms.txt Utilize load_audio for automatic resampling and pad_or_trim to normalize audio length for model input. These utilities support various formats via FFmpeg. ```python from whisper_s2t.audio import load_audio, pad_or_trim from whisper_s2t.configs import N_SAMPLES, SAMPLE_RATE import numpy as np # Load audio file (automatically resamples to 16kHz mono) audio_signal = load_audio('audio.mp3', sr=16000) print(f"Audio shape: {audio_signal.shape}") print(f"Duration: {len(audio_signal) / 16000:.2f} seconds") # Load with duration info audio_signal, duration = load_audio('audio.wav', sr=16000, return_duration=True) print(f"Audio duration: {duration:.2f} seconds") # Pad or trim audio to expected length (30 seconds = 480000 samples) audio_padded = pad_or_trim(audio_signal, length=N_SAMPLES) print(f"Padded audio shape: {audio_padded.shape}") # (480000,) # Works with numpy arrays short_audio = np.random.randn(160000) # 10 seconds padded = pad_or_trim(short_audio, length=N_SAMPLES) print(f"Short audio padded: {padded.shape}") # (480000,) # Trim long audio long_audio = np.random.randn(800000) # 50 seconds trimmed = pad_or_trim(long_audio, length=N_SAMPLES) print(f"Long audio trimmed: {trimmed.shape}") # (480000,) ``` -------------------------------- ### Displaying Model File Download Progress Source: https://github.com/shashikg/whispers2t/blob/main/notebooks/WhisperS2T_CTranslate2.ipynb This output shows the download progress for a specific model file, 'model.bin'. It includes the file size and download speed. ```text model.bin: 0%| | 0.00/3.09G [00:00