o
    p’×i€  ã                   @   sR   d Z ddlZddlmZ ddlZddlmZ eeƒZdee	 fdd„Z
dd	„ ZdS )
zNLibrary for checking the torchaudio backend.

Authors
 * Mirco Ravanelli 2021
é    N)ÚOptional)Ú
get_loggerÚreturnc                  C   sR   t tdƒsdS tj d¡} t| ƒdkrdS z	t| d ƒ}W |S  ty(   Y dS w )z{Tries parsing the torchaudio major version.

    Returns
    -------
    The parsed major version, otherwise ``None``.
    Ú__version__NÚ.é   r   )ÚhasattrÚ
torchaudior   ÚsplitÚlenÚintÚ	Exception)Úversion_splitÚversion© r   úc/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/speechbrain/utils/torch_audio_backend.pyÚ"try_parse_torchaudio_major_version   s   
ýÿr   c                  C   s€   t ƒ } | du rt d¡ dS | dkr%t ¡ }t|ƒdkr#t d¡ dS dS t d¡ t ¡ }|dkr>t d¡ t d	¡ dS dS )
zWChecks the torchaudio backend and sets it to soundfile if
    windows is detected.
    Nz|Failed to detect torchaudio major version; unsure how to check your setup. We recommend that you keep torchaudio up-to-date.r   r   zÎSpeechBrain could not find any working torchaudio backend. Audio files may fail to load. Follow this link for instructions and troubleshooting: https://speechbrain.readthedocs.io/en/latest/audioloading.htmlz§This version of torchaudio is old. SpeechBrain no longer tries using the torchaudio global backend mechanism in recipes, so if you encounter issues, update torchaudio.ÚWindowsztSwitched audio backend to "soundfile" because you are running Windows and you are running an old torchaudio version.Ú	soundfile)	r   ÚloggerÚwarningr	   Úlist_audio_backendsr   ÚplatformÚsystemÚset_audio_backend)Útorchaudio_majorÚavailable_backendsÚcurrent_systemr   r   r   Úcheck_torchaudio_backend+   s,   ÿÿÿÿÿür   )Ú__doc__r   Útypingr   r	   Úspeechbrain.utils.loggerr   Ú__name__r   r   r   r   r   r   r   r   Ú<module>   s    