CoolFace
Apppublic

devilent2/whisper-v3-zero-canary

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes
app.cpython-310.pyc46 linesDownload Raw Back to __pycache__
1o

2�f��3@s@ddlZddlZddlmZddlZddlZddlZddl	m4Z5ddlmZdZ
dZej��r1dndZedkr9dZ
dd	�Zee
�aejd6d��ZddlmZd
d�Zdd�Zdd�Zdd�Zdd�Ze��Zejeej dd�ej!ddgddd�ej"de
ddd�gej#d d!�ej#d"d!�gd#d$d%d&d'�Z$ejeej dd(d)�ej!ddgddd�ej"de
dd*d�gej#d d!�ej#d"d!�gd#d$d%d&d'�Z%e�Ne�&e$e%gd+d(g�e�'��
e�(d,�Z)Wd�n1s�wYej"d-d.d/�Z*ej"d0d.d/�Z+e)�,ede*e+g�ej-ede*e+gd1d.d2�Wd�n	1�swYej.d3d4�dS)5�N)�pipeline)�ffmpeg_readzdistil-whisper/distil-large-v3��cpuzopenai/whisper-tinycCstd|dtd�S)Nzautomatic-speech-recognition�)�task�model�chunk_length_s�device)rr7)�8model_name�r�5/teamspace/studios/this_studio/whisper-v3-zero/app.py�
load_pipelines�rc9	Cs�|dur	t�d��|tjjkrt|�at��}t�|�}|j	}t|t10d|idd�d}t��}||}d|d�d|d�d	|�d11tj�
�rFdnd��}	||	fS)
Nz^No audio file submitted! Please upload or record an audio file before submitting your request.rT)�12batch_size�generate_kwargs�return_timestamps�textzTranscription Time: �.2fz seconds13Audio Duration: z seconds14Model Used: z15Device Used: �GPU�CPU)�gr�Error�piper�name_or_pathr�time�mp�
AudioFileClip�duration�16BATCH_SIZE�torch�cuda�is_available)17�inputsrr�18start_time�audio�audio_durationr�end_time�transcription_time�transcription_time_outputrrr
�19transcribes&202122����r))�GPUStatCollectionc23Cs�tj��dkr	dSz;t��}|D]1}|j}|j}|j}|j}|j	}||d}d|�d|�d|�d|�d|�d	|d24�d�
}|WSWdSt25y`}	ztd|	���t�WYd}	~	Sd}	~	ww)
NFzNo Nviadia Device�dzGPU z: z, Utilization: z%, Memory Used: zMB, Memory Total: zMB, Memory Utilization: r�%zError getting GPU stats: )
rr r!r*�	new_query�index�name�utilization�memory_used�memory_total�	Exception�print�torch_update_gpu_status)26�	gpu_stats�gpu�gpu_id�gpu_name�gpu_utilizationr1r2�memory_utilization�27gpu_status�errr
�update_gpu_status;s&,28���r>cCsjtj��r1tj�d�}tj�d�}|dd}|d|dd}d|�d|d�d|d�d�}|Sd	}|S)29Nr�izGPU: z30Total Memory: rz MB31Used Memory: z MBzNo GPU available)rr r!�get_device_name�mem_get_info)�gpu_infoZ32gpu_memory�total_memoryZused_memoryr<rrr
r5Os33�r5cCs<ddl}|j����}|�d�}t��}d|�d|��}|S)Nrz%H:%M:%SzCPU Usage: z% )�datetime�nowr�strftime�psutil�cpu_percent)rD�current_time�time_strrH�34cpu_statusrrr
�update_cpu_status[s35rLcCst�}t�}||fS�N)r>rL)r<rKrrr
�
update_statusfsrNcCst�SrM)rNrrrr
�refresh_statusksrO�filepath)�type�	translate�Task)�label�valuez36Model NamezEnter the model nameaSome available models: distil-whisper/distil-large-v3 distil-whisper/distil-medium.en Systran/faster-distil-whisper-large-v3 Systran/faster-whisper-large-v3 Systran/faster-whisper-medium openai/whisper-tiny, openai/whisper-base, openai/whisper-medium, openai/whisper-large-v3)rTrU�placeholder�info�
Transcription)rTzTranscription Info�huggingfacezWhisper Transcriptionu�Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the specified OpenAI Whisper checkpoint and 🤗 Transformers to transcribe audio files of arbitrary length.�never)�fnr"�outputs�theme�title�description�allow_flaggingz37Audio file)rQrTzoSome available models: openai/whisper-tiny, openai/whisper-base, openai/whisper-medium, openai/whisper-large-v2�38MicrophonezRefresh Statusz39GPU StatusF)rT�interactivez40CPU Status�)r"r\�every�queueT)�share)/rr�moviepy.editor�editorrrG�gradior�spaces�transformersr�"transformers.pipelines.audio_utilsr�DEFAULT_MODEL_NAMErr r!r41rrrr)�gpustatr*r>r5rLrNrO�Blocks�demo�	Interface�Audio�Radio�Textbox�TextArea�
mf_transcribe�file_transcribe�TabbedInterface�Row�Button�refresh_button�gpu_status_output�cpu_status_output�click�load�launchrrrr
�<module>s�4243��44���45�46��