Whisper

The purpose of this page is to experiment with openai's whisper cli tool.

Installation

Install OpenAI's whisper using Nix (not NixOS) on Debian:

nix-shell -p openai-whisper

Notes on the above command:

I used Audacity to record and export a flac audio file, and then, I used the following command to transcribe it:

whisper ~/Documents/story-with-space.flac > /tmp/story.txt

You can transcribe mp4, wav, flac, ...

Using ffmpeg, Whisper and aichat Together

ffmpeg -f alsa -i default /tmp/output.flac && \
whisper /tmp/output.flac > /tmp/output.txt && \
cat /tmp/output.txt | aichat

Reference: aichat github discussion

Using the GPU

Tried using the following nix-shell; however, I have not had success yet:

{ pkgs ? import  {} }:
 pkgs.mkShell {
   buildInputs = with pkgs; [
     openai-whisper
     cudatoolkit
     linuxPackages.nvidia_x11
     libGLU libGL
     xorg.libXi xorg.libXmu freeglut
     xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib
     ncurses5
     stdenv.cc
     binutils
   ];
 shellHook = ''
     export CUDA_PATH=${pkgs.cudatoolkit}
     # Append CUDA libraries to LD_LIBRARY_PATH
     export LD_LIBRARY_PATH=${pkgs.linuxPackages.nvidia_x11}/lib:${pkgs.ncurses5}/lib:$LD_LIBRARY_PATH
     export EXTRA_LDFLAGS="-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib"
     export EXTRA_CCFLAGS="-I/usr/include"
   '';
 }

Testing if NVIDIA cuda driver installed:

nvcc --version

Test if using GPU using new python file named test.py:

import torch
 if torch.cuda.is_available():
     print(f"CUDA is available. Using GPU: {torch.cuda.get_device_name(0)}")
 else:
     print("CUDA is not available. Using CPU.")

Execute test.py using:

python3 test.py