street-lab-tech / street-whisper-app

STREET Lab Whisper App - a tool that transcribes and translates audio files into CSV files.
MIT License
2 stars 0 forks source link

URGENT Bug: Silence torchaudio warnings #12

Closed carmen-chau closed 4 months ago

carmen-chau commented 4 months ago

Silence the torchaudio warnings appearing prior to the CLI initializing:

Sample display message:

/path_to_env/lib/python3.9/site-packages/pyannote/audio/core/io.py:43: UserWarning: torchaudio._backend.set_audio_backend has been deprecated. With dispatcher enabled, this function is no-op. You can remove the function call. torchaudio.set_audio_backend("soundfile")

carmen-chau commented 4 months ago

Resolved.

Formalized solution

According to this post and this post can utilize the following lines to silence all UserWarnings (including this one)

import warnings warnings.filterwarnings('ignore')


Alternate solution

Similar to #8 , this warning was caused by a depreciated call in one of the dependency files.

On MacOS, the file could be found at the path /path_to_env/lib/python3.9/site-packages/pyannote/audio/core/io.py, where _path_toenv specifies the absolute path to the env.

In io.py, comment out the line: torchaudio.set_audio_backend("soundfile"). This is found at line 43 (see reference here).

In other words, the header of io.py should now be:

/*.... omitted some lines near the beginning*/

import math
import random
import warnings
from io import IOBase
from pathlib import Path
from typing import Mapping, Optional, Text, Tuple, Union

import numpy as np
import torch.nn.functional as F
import torchaudio
from pyannote.core import Segment
from torch import Tensor

#torchaudio.set_audio_backend("soundfile")