Troubleshooting of whisperX: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 106: Line 106:
* '''Compatibility:''' Ensure that the versions of CUDA, cuDNN, and PyTorch are compatible with each other. Refer to the [https://pytorch.org/get-started/previous-versions/ PyTorch documentation] for version compatibility details.
* '''Compatibility:''' Ensure that the versions of CUDA, cuDNN, and PyTorch are compatible with each other. Refer to the [https://pytorch.org/get-started/previous-versions/ PyTorch documentation] for version compatibility details.
* '''Virtual Environments:''' If you’re using a virtual environment, make sure it has access to the system’s CUDA and cuDNN installations. You might need to install CUDA and cuDNN within the virtual environment or ensure that the environment variables are correctly set.
* '''Virtual Environments:''' If you’re using a virtual environment, make sure it has access to the system’s CUDA and cuDNN installations. You might need to install CUDA and cuDNN within the virtual environment or ensure that the environment variables are correctly set.
=== WhisperX Audio Transcription Commands for Multiple Languages ===
Standard Command: English transcription output
<pre>
whisperx /path/to/audio/file.wav \
        --model large-v3 \
        --language en \
        --diarize \
        --batch_size 24 \
        --no_align \
        --chunk_size 10 \
        --hf_token your_huggingface_token \
        --output_dir /path/to/output/directory \
        --output_format all
</pre>
To change output to Thai, modify the following parameters:
Method 1: Set language to Thai {{kbd | key=<nowiki>--language th</nowiki>}}
<pre>
whisperx /path/to/audio/file.wav \
        --model large-v3 \
        --language th \
        --diarize \
        --batch_size 24 \
        --no_align \
        --chunk_size 10 \
        --hf_token your_huggingface_token \
        --output_dir /path/to/output/directory \
        --output_format all
</pre>
Method 2: Auto-detect language (remove the {{kbd | key=<nowiki>--language</nowiki>}} parameter)
<pre>
whisperx /path/to/audio/file.wav \
        --model large-v3 \
        --diarize \
        --batch_size 24 \
        --no_align \
        --chunk_size 10 \
        --hf_token your_huggingface_token \
        --output_dir /path/to/output/directory \
        --output_format all
</pre>
Common Language Code Reference:
# th = Thai
# zh = Chinese
# en = English
# ja = Japanese
# ko = Korean
# es = Spanish
# fr = French
Supported language codes can be found in the [https://github.com/openai/whisper/blob/main/whisper/tokenizer.py Whisper tokenizer documentation] & [https://github.com/m-bain/whisperX/blob/main/EXAMPLES.md whisperX/EXAMPLES.md at main · m-bain/whisperX]


== whisperX Transcript File Format Guide ==
== whisperX Transcript File Format Guide ==
Line 117: Line 173:
If using for the first time, it's recommended to directly open the srt format
If using for the first time, it's recommended to directly open the srt format


== Further reading ==
* [https://medium.com/@planetoid/how-to-add-punctuation-to-whisper-transcripts-using-ai-619362c9160c How to Add Punctuation to Whisper Transcripts Using AI | Medium]


[[Category: Generative AI]] [[Category: Software]] [[Category: Revised with LLMs]]
[[Category: Generative AI]] [[Category: Software]] [[Category: Revised with LLMs]]

Latest revision as of 13:13, 26 January 2026

whisperX is an enhanced version of OpenAI's Whisper, offering fast automatic speech recognition with word-level timestamps and speaker diarization. It uses the faster-whisper backend and can run the large-v2 model on less than 8GB of GPU memory. whisperX also includes voice activity detection (VAD) preprocessing, reducing hallucinations and supporting batch processing.

whisperX Troubleshooting Guide[edit]

Error: HF_TOKEN environment variable is not set[edit]

Problematic command:

whisperx input.mp3 --model large-v3 --language zh --diarize --batch_size 24 --no_align --chunk_size 10 --hf_token <token>


When running the bash command, you encounter the error:

Error: HF_TOKEN environment variable is not set
Please run: export HF_TOKEN='your Hugging Face token'

Solution:

  1. Log in to Hugging Face – The AI community building the future. https://huggingface.co/settings/tokens to obtain an access token
  2. Return to terminal * Activate virtual environment by running conda activate whisperx
  3. Enter export HF_TOKEN='your Hugging Face token'
  4. Run bash command

Repeated Same Dialog Issue[edit]

Problematic command:

whisperx input.wav --model large-v2 --diarize --highlight_words True

Fixed command:

whisperx input.mp3 --model large-v3 --language zh --diarize --batch_size 24 --no_align --chunk_size 10 

ImportError: libcudnn.so.9: cannot open shared object file: No such file or directory[edit]

When running:

$ whisperx input.mp3 --model large-v2 --diarize --highlight_words True

You encounter a long error trace ending with:

ImportError: libcudnn.so.9: cannot open shared object file: No such file or directory

This error indicates that the libcudnn.so.9 library is missing or not accessible in your system’s library path. This library is part of NVIDIA’s cuDNN (CUDA Deep Neural Network) package, which is essential for GPU-accelerated deep learning applications.

Possible Causes:

  1. cuDNN Not Installed: The cuDNN library might not be installed on your system.
  2. Version Mismatch: The installed cuDNN version may not match the version required by your application.
  3. Library Path Issues: The system might not be able to locate the cuDNN library due to incorrect environment variables.

Steps to Resolve:

  1. Verify cuDNN Installation:
    • Check if cuDNN is installed by listing the contents of the CUDA library directory:

      ls /usr/local/cuda/lib64 | grep libcudnn
    • If the libcudnn.so.9 file is not present, proceed to install or update cuDNN.

  2. Install or Update cuDNN:
    • Download the appropriate cuDNN version compatible with your CUDA installation from NVIDIA’s cuDNN download page.
      • Operating System: Linux
      • Architecture: x86_64 (uname -a)
      • Distribution: Ubuntu
      • Version: 22_04 (cat /etc/lsb-release)
      • Installer Type: deb (network)
      • cuda version: 12 (nvcc --version)
      • sudo apt-get -y install cudnn-cuda-12
    • Follow the installation instructions provided by NVIDIA to install or update cuDNN.

Installation Instructions:

# Download and install CUDA keyring
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update

# Install cuDNN (choose one of the following based on your CUDA version)
# For CUDA 11:
sudo apt-get -y install cudnn-cuda-11

# For CUDA 12:
sudo apt-get -y install cudnn-cuda-12
  1. Set Environment Variables:
    • Ensure that the CUDA and cuDNN libraries are included in your system’s library path.

    • Add the following lines to your ~/.bashrc or ~/.zshrc file:

      export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
      export PATH=/usr/local/cuda/bin:$PATH
    • Apply the changes by sourcing the file:

      source ~/.bashrc
    • This step ensures that the system can locate the CUDA and cuDNN libraries during execution.

  2. Verify Installation:
    • After installation, verify that the system recognizes the cuDNN version:

      python -c "import torch; print(torch.backends.cudnn.version())"
    • This command should display the installed cuDNN version, confirming that PyTorch can access it.

Additional Considerations:

  • Compatibility: Ensure that the versions of CUDA, cuDNN, and PyTorch are compatible with each other. Refer to the PyTorch documentation for version compatibility details.
  • Virtual Environments: If you’re using a virtual environment, make sure it has access to the system’s CUDA and cuDNN installations. You might need to install CUDA and cuDNN within the virtual environment or ensure that the environment variables are correctly set.


WhisperX Audio Transcription Commands for Multiple Languages[edit]

Standard Command: English transcription output

whisperx /path/to/audio/file.wav \
        --model large-v3 \
        --language en \
        --diarize \
        --batch_size 24 \
        --no_align \
        --chunk_size 10 \
        --hf_token your_huggingface_token \
        --output_dir /path/to/output/directory \
        --output_format all

To change output to Thai, modify the following parameters:

Method 1: Set language to Thai --language th

whisperx /path/to/audio/file.wav \
        --model large-v3 \
        --language th \
        --diarize \
        --batch_size 24 \
        --no_align \
        --chunk_size 10 \
        --hf_token your_huggingface_token \
        --output_dir /path/to/output/directory \
        --output_format all

Method 2: Auto-detect language (remove the --language parameter)

whisperx /path/to/audio/file.wav \
        --model large-v3 \
        --diarize \
        --batch_size 24 \
        --no_align \
        --chunk_size 10 \
        --hf_token your_huggingface_token \
        --output_dir /path/to/output/directory \
        --output_format all

Common Language Code Reference:

  1. th = Thai
  2. zh = Chinese
  3. en = English
  4. ja = Japanese
  5. ko = Korean
  6. es = Spanish
  7. fr = French

Supported language codes can be found in the Whisper tokenizer documentation & whisperX/EXAMPLES.md at main · m-bain/whisperX

whisperX Transcript File Format Guide[edit]

Transcripts come in different file formats:

  1. txt - all content combined together
  2. srt, vtt - different subtitle formats: distinguished by time, speaker, and speech content
  3. tsv - distinguished by time and speech content
  4. json - distinguished by time, speaker, and speech content, suitable for programming processing

If using for the first time, it's recommended to directly open the srt format

Further reading[edit]