def tokenize_audio(tokenizer: AudioTokenizer, audio_path: str):
    """
    Tokenize the audio waveform using the given AudioTokenizer.

    Args:
        tokenizer: An instance of AudioTokenizer.
        audio_path: Path to the audio file.

    Returns:
        A tensor of encoded frames from the audio.

    Raises:
        FileNotFoundError: If the audio file is not found.
        RuntimeError: If there's an error processing the audio data.
    """
    # try:
    # Load and preprocess the audio waveform
    wav, sr = torchaudio.load(audio_path)
    wav = convert_audio(wav, sr, tokenizer.sample_rate, tokenizer.channels)
    wav = wav.unsqueeze(0)

    # Extract discrete codes from EnCodec
    with torch.no_grad():
        encoded_frames = tokenizer.encode(wav)
    return encoded_frames
Tokenize the audio waveform using the given AudioTokenizer.

Args:
tokenizer: An instance of AudioTokenizer.
audio_path: Path to the audio file.

Returns:
A tensor of encoded frames from the audio.

Raises:
FileNotFoundError: If the audio file is not found.
RuntimeError: If there's an error processing the audio data.
models/tts/debatts/utils/tokenizer.py