CoolFace
Apppublic

Mery3391/YAMNET

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
predict.cpython-310.pyc15 linesDownload Raw Back to __pycache__
1o

2'�i��@s�ddlZddlZddlZddlZddlZed�e�	d�Z3ed�ejj�
d�Zed�edd��
Ze�	e�ZWd�n1sAwYd	d4ddd
�Zdedefdd�ZdS)�NzChargement de YAMNet...z!https://tfhub.dev/google/yamnet/1u Chargement du modèle emotion...zmodel_yamnet_darija.keraszChargement du scaler...zscaler_yamnet.pkl�rb�Angry�Happy�Neutral�Sad)r����5audio_path�returnc		Cs�tj|dd�\}}|�tj�}t|�\}}}tj|dd����	dd�}t6�|�}t�
|�}tt�|��}tt�|��}t|t|dd�tt|dd�dd�tt|dd�dd�tt|dd�dd�tt|dd	�dd�d7�d�S)Ni�>)�srr)Zaxisr������drr	)rrrr)Zemotion�8confidenceZscores)�librosa�loadZastype�npZfloat32�yamnet_model�tfZreduce_mean�numpyZreshape�scaler�	transform�
emotion_model�predict�intZargmax�float�max�LABELS�round)	r9Zaudio�_Z10embeddingsZmean_embeddingZembedding_scaledZpredictionsZpredicted_indexr�r �+C:\Users\hp\Downloads\mon_projet\predict.py�predict_emotions 1112��r")rrrZ13tensorflowrZtensorflow_hubZhub�pickle�printrrZkeras�modelsZ14load_modelr�open�frr�str�dictr"r r r r!�<module>s15�