David_A
commited on
Commit
·
a7029db
1
Parent(s):
ba7fe85
deploiement de l'application
Browse files- .gitignore +1 -0
- Accueil.py +43 -0
- README.md +1 -1
- __pycache__/Transcription.cpython-39.pyc +0 -0
- __pycache__/logo.cpython-39.pyc +0 -0
- components/.env.exemple +4 -0
- components/__pycache__/fonctions_transcription.cpython-39.pyc +0 -0
- components/__pycache__/graphique_utilisateur.cpython-39.pyc +0 -0
- components/__pycache__/identification_aws.cpython-39.pyc +0 -0
- components/__pycache__/logo.cpython-39.pyc +0 -0
- components/fonctions_transcription.py +267 -0
- components/identification_aws.py +244 -0
- components/logo.py +10 -0
- logo-digitalix.png +0 -0
- logo_digitalixsa.png +0 -0
- pages/Limite_Usage.py +90 -0
- pages/Transcription.py +130 -0
- pages/__pycache__/Limite_Usage.cpython-39.pyc +0 -0
- requirements.txt +9 -0
- test_date.py +33 -0
- test_json.ipynb +1222 -0
- users_info.json +79 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.env
|
Accueil.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# pip install streamlit
|
2 |
+
import streamlit as st
|
3 |
+
import components.logo as logo
|
4 |
+
import components.identification_aws as authenticate
|
5 |
+
|
6 |
+
# Logo de la page
|
7 |
+
my_logo = logo.add_logo(logo_path="logo_digitalixsa.png", width=100, height=100)
|
8 |
+
st.image(my_logo)
|
9 |
+
|
10 |
+
# Titre de la page
|
11 |
+
st.title("TRANSCRIPTION AUDIO AUTOMATIQUE DIGITALIX")
|
12 |
+
st.write("# Bienvenue! 👋")
|
13 |
+
st.markdown(
|
14 |
+
"""
|
15 |
+
Transcrivez facilement vos fichiers audio en texte avec notre application.
|
16 |
+
Il vous suffit de télécharger votre fichier audio et nous nous occupons du reste
|
17 |
+
"""
|
18 |
+
)
|
19 |
+
st.write(
|
20 |
+
"""
|
21 |
+
## Comment faire la transcription?
|
22 |
+
|
23 |
+
- Sélectionner votre fichier audio à transcrire (dans la partie "charger l'audio", appuyer sur "Browse files",
|
24 |
+
choisir l'audio et attendre son chargement sur le site)
|
25 |
+
- Cliquer sur le bouton "Transcrire l'audio à gauche de la page"
|
26 |
+
- Attender que la transcription automatique soit effectuée
|
27 |
+
- Consultez le texte transcrit à l'écran et télécharger-le si nécessaire
|
28 |
+
- Formats de fichiers audio pris en charge : MP3,WAV,M4A.
|
29 |
+
|
30 |
+
### Confidentialité :
|
31 |
+
Nous comprenons l'importance de la confidentialité de vos données.
|
32 |
+
Votre fichier audio est utilisé uniquement pour la transcription et est supprimé de nos serveurs après le processus de transcription
|
33 |
+
Amuser-vous!
|
34 |
+
"""
|
35 |
+
)
|
36 |
+
|
37 |
+
# Check authentication
|
38 |
+
authenticate.set_st_state_vars()
|
39 |
+
# Add login/logout buttons
|
40 |
+
if st.session_state["authenticated"]:
|
41 |
+
authenticate.button_logout()
|
42 |
+
else:
|
43 |
+
authenticate.button_login()
|
README.md
CHANGED
@@ -5,7 +5,7 @@ colorFrom: green
|
|
5 |
colorTo: indigo
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.21.0
|
8 |
-
app_file:
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
|
|
5 |
colorTo: indigo
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.21.0
|
8 |
+
app_file: Accueil.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
__pycache__/Transcription.cpython-39.pyc
ADDED
Binary file (2.83 kB). View file
|
|
__pycache__/logo.cpython-39.pyc
ADDED
Binary file (477 Bytes). View file
|
|
components/.env.exemple
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
COGNITO_DOMAIN = "https://myappauthentication.auth.us-east-1.amazoncognito.com"
|
2 |
+
CLIENT_ID = "xyz"
|
3 |
+
CLIENT_SECRET = "secret-secret"
|
4 |
+
APP_URI = "http://localhost:8501/"
|
components/__pycache__/fonctions_transcription.cpython-39.pyc
ADDED
Binary file (3.44 kB). View file
|
|
components/__pycache__/graphique_utilisateur.cpython-39.pyc
ADDED
Binary file (1.69 kB). View file
|
|
components/__pycache__/identification_aws.cpython-39.pyc
ADDED
Binary file (6.23 kB). View file
|
|
components/__pycache__/logo.cpython-39.pyc
ADDED
Binary file (488 Bytes). View file
|
|
components/fonctions_transcription.py
ADDED
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# pip install streamlit
|
2 |
+
import streamlit as st
|
3 |
+
import soundfile as sf
|
4 |
+
import json
|
5 |
+
import datetime
|
6 |
+
from datetime import datetime as date
|
7 |
+
from datetime import timedelta as td
|
8 |
+
import math
|
9 |
+
import pandas as pd
|
10 |
+
import plotly.express as px
|
11 |
+
|
12 |
+
# # Chargement du fichier des utilisateurs
|
13 |
+
# with open("users_info.json", 'r') as file:
|
14 |
+
# dict_user = json.load(file)
|
15 |
+
|
16 |
+
# # Logo de la page
|
17 |
+
# my_logo = logo.add_logo(logo_path="logo-digitalix.png", width=100, height=100)
|
18 |
+
# st.image(my_logo)
|
19 |
+
|
20 |
+
# # Titre de la page
|
21 |
+
# st.title("TRANSCRIPTION AUDIO AUTOMATIQUE DIGITALIX")
|
22 |
+
# st.write("# Bienvenue! 👋")
|
23 |
+
# st.markdown(
|
24 |
+
# """
|
25 |
+
# Transcrivez facilement vos fichiers audio en texte avec notre application.
|
26 |
+
# Il vous suffit de télécharger votre fichier audio et nous nous occupons du reste
|
27 |
+
# """
|
28 |
+
# )
|
29 |
+
|
30 |
+
|
31 |
+
# # Check authentication
|
32 |
+
# authenticate.set_st_state_vars()
|
33 |
+
# # Add login/logout buttons
|
34 |
+
# if st.session_state["authenticated"]:
|
35 |
+
# authenticate.button_logout()
|
36 |
+
# else:
|
37 |
+
# authenticate.button_login()
|
38 |
+
|
39 |
+
# # user info
|
40 |
+
# auth_code = st.session_state["auth_code"]
|
41 |
+
# user_info = st.session_state["user_info"]
|
42 |
+
# maintenant = datetime.datetime.now()
|
43 |
+
# username = user_info['username']
|
44 |
+
# user_pool_name = 'transcription_streamlit'
|
45 |
+
|
46 |
+
# # add user to users_dict and group free
|
47 |
+
# if user_info['username'] not in dict_user.keys():
|
48 |
+
# dict_user[user_info['username']] = {"email": user_info['email'],
|
49 |
+
# "durees_audio_sec":[],
|
50 |
+
# "date_inscription":str(maintenant),
|
51 |
+
# "dates_transcription":[],
|
52 |
+
# "abonnement":1}
|
53 |
+
# #group_name = 'utilisateurs_gratuits'
|
54 |
+
# # get user pool id
|
55 |
+
# #user_pool_id = authenticate.get_user_pool_id(user_pool_name)
|
56 |
+
# #print("User Pool ID:", user_pool_id)
|
57 |
+
# #authenticate.add_user_to_group(user_pool_id, username, group_name)
|
58 |
+
|
59 |
+
# # Calcul annee-mois de trascription
|
60 |
+
# Year = maintenant.year
|
61 |
+
# Month = maintenant.month
|
62 |
+
# Year_Month = str(Year) + '_' + str(Month).zfill(2)
|
63 |
+
|
64 |
+
# #Definition quota utilisation
|
65 |
+
# quota_20H = 1000
|
66 |
+
|
67 |
+
|
68 |
+
# # Pour des groupes d'utilisateurs
|
69 |
+
# if (st.session_state["authenticated"] and "utilisateurs_sidwaya" in st.session_state["user_cognito_groups"]):
|
70 |
+
# #print("Code authentification:",auth_code)
|
71 |
+
# #print("information utilisateur:",user_info)
|
72 |
+
|
73 |
+
# st.write(
|
74 |
+
# """
|
75 |
+
# ## Comment faire la transcription?
|
76 |
+
|
77 |
+
# - Sélectionner votre fichier audio à transcrire (dans la partie "charger l'audio", appuyer sur "Browse files",
|
78 |
+
# choisir l'audio et attendre son chargement sur le site)
|
79 |
+
# - Cliquer sur le bouton "Transcrire l'audio à gauche de la page"
|
80 |
+
# - Attender que la transcription automatique soit effectuée
|
81 |
+
# - Consultez le texte transcrit à l'écran et télécharger-le si nécessaire
|
82 |
+
# - Formats de fichiers audio pris en charge : MP3,WAV,M4A.
|
83 |
+
|
84 |
+
# ### Confidentialité :
|
85 |
+
# Nous comprenons l'importance de la confidentialité de vos données.
|
86 |
+
# Votre fichier audio est utilisé uniquement pour la transcription et est supprimé de nos serveurs après le processus de transcription
|
87 |
+
# Amuser-vous!"""
|
88 |
+
# )
|
89 |
+
|
90 |
+
def graphique_utilisation(data, username, annee_mois):
|
91 |
+
# Copie des données
|
92 |
+
dict_user = data
|
93 |
+
# Transformation en dataframe
|
94 |
+
df_user = pd.DataFrame(dict_user).T.reset_index()
|
95 |
+
df_user.rename(columns={"index":"usernames"},inplace = True)
|
96 |
+
|
97 |
+
# Separation des lignes de listes en plusieurs lignes pour les colonees duree_audio_sec et dates_transcription
|
98 |
+
df_duree = df_user.drop(['dates_transcription'],axis=1)
|
99 |
+
df_duree = df_duree.explode('durees_audio_sec')
|
100 |
+
df_duree = df_duree.reset_index(drop=True)
|
101 |
+
|
102 |
+
df_transcription = df_user.drop(['durees_audio_sec'],axis=1)
|
103 |
+
df_transcription = df_transcription.explode('dates_transcription')
|
104 |
+
df_transcription = df_transcription.reset_index(drop=True)
|
105 |
+
|
106 |
+
# Regroupement des dataframes
|
107 |
+
df_user = df_duree.copy()
|
108 |
+
df_user["dates_transcription"] = df_transcription["dates_transcription"]
|
109 |
+
|
110 |
+
df_user['date_inscription'] = pd.to_datetime(df_user['date_inscription'],format = "%Y-%m-%d %H:%M:%S.%f")
|
111 |
+
df_user['dates_transcription'] = pd.to_datetime(df_user['dates_transcription'],format = "%Y-%m-%d %H:%M:%S.%f")
|
112 |
+
|
113 |
+
# Calcul annee-mois de trascription
|
114 |
+
df_user['Year'] = df_user['dates_transcription'].dt.year
|
115 |
+
df_user['Month'] = df_user['dates_transcription'].dt.month
|
116 |
+
df_user['Year_Month'] = df_user['Year'].astype(str) + '_' + df_user['Month'].astype(str).str.zfill(2)
|
117 |
+
|
118 |
+
# Selection utilisateur et mois d'utilisation
|
119 |
+
|
120 |
+
a =df_user[(df_user["usernames"] == username) & (df_user["Year_Month"] == annee_mois)]
|
121 |
+
a["Consommation_heures"] = a["durees_audio_sec"].cumsum()
|
122 |
+
a["Consommation_heures"] = a["Consommation_heures"].values / 3600
|
123 |
+
#print(a["Consommation_heures"])
|
124 |
+
fig = px.line(a, x='dates_transcription', y='Consommation_heures')
|
125 |
+
|
126 |
+
# Ajouter la limite de temps 20H = 72000 s
|
127 |
+
fig.add_shape(type="line",
|
128 |
+
x0=fig['data'][0]['x'][0],
|
129 |
+
x1=fig['data'][0]['x'][-1],
|
130 |
+
y0=20,
|
131 |
+
y1=20,
|
132 |
+
line=dict(color='red', width=2, dash='dash'))
|
133 |
+
|
134 |
+
# Afficher la légende de la limite SEUIL DE 20H = 72000 secondes
|
135 |
+
fig.add_annotation(x=fig['data'][0]['x'][-1],
|
136 |
+
y=20,
|
137 |
+
text="SEUIL DE 20H",
|
138 |
+
showarrow=False,
|
139 |
+
font=dict(color="red"),
|
140 |
+
xshift=-40, # Shift the label to the left
|
141 |
+
yshift=20) # Shift the label downwards
|
142 |
+
|
143 |
+
# Afficher la figure interactive
|
144 |
+
# fig.show()
|
145 |
+
|
146 |
+
# Calcul temps total de transcription en secondes du mois
|
147 |
+
temps = a["durees_audio_sec"].sum()
|
148 |
+
return fig,temps
|
149 |
+
|
150 |
+
|
151 |
+
def transcript(dict_user,username,user_group, audio_file,maintenant,Year_Month,quota_20H,model):
|
152 |
+
# Calcul consommation utilisateur
|
153 |
+
figure , consommation = graphique_utilisation(dict_user, username, Year_Month)
|
154 |
+
if audio_file is not None:
|
155 |
+
st.sidebar.header("Ecouter le fichier audio")
|
156 |
+
st.sidebar.audio(audio_file)
|
157 |
+
|
158 |
+
### Utilisateur SIDWAYA
|
159 |
+
if user_group == "utilisateurs_sidwaya":
|
160 |
+
date_inscription = dict_user[username]['date_inscription']
|
161 |
+
format = "%Y-%m-%d %H:%M:%S.%f"
|
162 |
+
datetime_obj = date.strptime(date_inscription, format)
|
163 |
+
# Calculate the difference between the two dates
|
164 |
+
difference = maintenant - datetime_obj
|
165 |
+
# print(type(difference))
|
166 |
+
# Compare if the difference is less than or equal to one year
|
167 |
+
one_year = td(days=365)
|
168 |
+
is_one_year_before = difference <= one_year
|
169 |
+
|
170 |
+
if (is_one_year_before):
|
171 |
+
if consommation > quota_20H:
|
172 |
+
st.text("Quota de transcription audio du mois dépassé")
|
173 |
+
text_transcript = ""
|
174 |
+
#audio_name = ""
|
175 |
+
else :
|
176 |
+
### Durée de l'audio ###
|
177 |
+
# Charger le fichier audio et obtenir les informations
|
178 |
+
infos_audio = sf.info(audio_file.name)
|
179 |
+
# Extraire la durée en secondes
|
180 |
+
duree_audio_sec = infos_audio.duration
|
181 |
+
# Afficher la durée
|
182 |
+
print(f'Durée audio : {duree_audio_sec} secondes')
|
183 |
+
|
184 |
+
# Mise à jour info utilisateurs
|
185 |
+
dict_user[username]["durees_audio_sec"].append(duree_audio_sec)
|
186 |
+
dict_user[username]["dates_transcription"].append(str(maintenant))
|
187 |
+
with open('users_info.json', 'w') as f:
|
188 |
+
json.dump(dict_user, f)
|
189 |
+
st.sidebar.success("Audio en cours de transcription")
|
190 |
+
audio_name = audio_file.name
|
191 |
+
transcription = model.transcribe(audio_name)
|
192 |
+
st.sidebar.success("Transcription terminée")
|
193 |
+
st.balloons()
|
194 |
+
text_transcript = transcription["text"]
|
195 |
+
st.markdown(text_transcript)
|
196 |
+
# Ajout boutton de téléchargement
|
197 |
+
st.download_button('Télécharger la transcription', text_transcript)
|
198 |
+
# Streamlit widgets automatically run the script from top to bottom. Since
|
199 |
+
# this button is not connected to any other logic, it just causes a plain
|
200 |
+
# rerun.
|
201 |
+
# st.button("Re-run")
|
202 |
+
|
203 |
+
|
204 |
+
|
205 |
+
# if st.sidebar.button("Enregistrer un audio") :
|
206 |
+
# audio_bytes = audio_recorder()
|
207 |
+
# if st.sidebar.button("Transcrire l'audio"):
|
208 |
+
# if audio_bytes is not None:
|
209 |
+
# st.sidebar.success("Audio en cours de transcription")
|
210 |
+
# transcription = model.transcribe(audio_bytes)
|
211 |
+
# st.sidebar.success("Transcription terminée")
|
212 |
+
# st.balloons()
|
213 |
+
# text_transcript = transcription["text"]
|
214 |
+
# st.markdown(text_transcript)
|
215 |
+
# # Ajout boutton de téléchargement
|
216 |
+
# st.download_button('Télécharger la transcription', text_transcript)
|
217 |
+
# # Streamlit widgets automatically run the script from top to bottom. Since
|
218 |
+
# # this button is not connected to any other logic, it just causes a plain
|
219 |
+
# # rerun.
|
220 |
+
# # st.button("Re-run")
|
221 |
+
# else:
|
222 |
+
# st.sidebar.error("Erreur : Charger un fichier audio")
|
223 |
+
# st.sidebar.header("Ecouter le fichier audio")
|
224 |
+
# st.sidebar.audio(audio_bytes)
|
225 |
+
|
226 |
+
### Utilisateurs gratuits et VIP ####
|
227 |
+
if ((user_group == "utilisateurs_vip") or (user_group == "utilisateurs_gratuits")):
|
228 |
+
if consommation > quota_20H:
|
229 |
+
st.text("Quota gratuit dépassé,veuillez contactez l'administrateur pour vous abonner")
|
230 |
+
text_transcript = ""
|
231 |
+
#audio_name = ""
|
232 |
+
else :
|
233 |
+
### Durée de l'audio ###
|
234 |
+
# Charger le fichier audio et obtenir les informations
|
235 |
+
infos_audio = sf.info(audio_file.name)
|
236 |
+
# Extraire la durée en secondes
|
237 |
+
duree_audio_sec = infos_audio.duration
|
238 |
+
# Afficher la durée
|
239 |
+
print(f'Durée audio : {duree_audio_sec} secondes')
|
240 |
+
|
241 |
+
# Mise à jour info utilisateurs
|
242 |
+
dict_user[username]["durees_audio_sec"].append(duree_audio_sec)
|
243 |
+
dict_user[username]["dates_transcription"].append(str(maintenant))
|
244 |
+
with open('users_info.json', 'w') as f:
|
245 |
+
json.dump(dict_user, f)
|
246 |
+
st.sidebar.success("Audio en cours de transcription")
|
247 |
+
audio_name = audio_file.name
|
248 |
+
transcription = model.transcribe(audio_name)
|
249 |
+
st.sidebar.success("Transcription terminée")
|
250 |
+
st.balloons()
|
251 |
+
text_transcript = transcription["text"]
|
252 |
+
st.markdown(text_transcript)
|
253 |
+
# Ajout boutton de téléchargement
|
254 |
+
st.download_button('Télécharger la transcription', text_transcript)
|
255 |
+
# Streamlit widgets automatically run the script from top to bottom. Since
|
256 |
+
# this button is not connected to any other logic, it just causes a plain
|
257 |
+
# rerun.
|
258 |
+
# st.button("Re-run")
|
259 |
+
|
260 |
+
else:
|
261 |
+
st.sidebar.error("Erreur : Charger un fichier audio")
|
262 |
+
text_transcript = ""
|
263 |
+
#audio_name = ""
|
264 |
+
|
265 |
+
return text_transcript
|
266 |
+
|
267 |
+
|
components/identification_aws.py
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
import requests
|
5 |
+
import base64
|
6 |
+
import json
|
7 |
+
import boto3
|
8 |
+
|
9 |
+
# ------------------------------------
|
10 |
+
# Read constants from environment file
|
11 |
+
# ------------------------------------
|
12 |
+
load_dotenv()
|
13 |
+
COGNITO_DOMAIN = os.environ.get("COGNITO_DOMAIN")
|
14 |
+
CLIENT_ID = os.environ.get("CLIENT_ID")
|
15 |
+
CLIENT_SECRET = os.environ.get("CLIENT_SECRET")
|
16 |
+
APP_URI = os.environ.get("APP_URI")
|
17 |
+
# ------------------------------------
|
18 |
+
# Initialise Streamlit state variables
|
19 |
+
# ------------------------------------
|
20 |
+
def initialise_st_state_vars():
|
21 |
+
"""
|
22 |
+
Initialise Streamlit state variables.
|
23 |
+
Returns:
|
24 |
+
Nothing.
|
25 |
+
"""
|
26 |
+
if "auth_code" not in st.session_state:
|
27 |
+
st.session_state["auth_code"] = ""
|
28 |
+
if "authenticated" not in st.session_state:
|
29 |
+
st.session_state["authenticated"] = False
|
30 |
+
if "user_cognito_groups" not in st.session_state:
|
31 |
+
st.session_state["user_cognito_groups"] = []
|
32 |
+
if "user_info" not in st.session_state:
|
33 |
+
st.session_state["user_info"] = {}
|
34 |
+
# ----------------------------------
|
35 |
+
# Get authorization code after login
|
36 |
+
# ----------------------------------
|
37 |
+
def get_auth_code():
|
38 |
+
"""
|
39 |
+
Gets auth_code state variable.
|
40 |
+
Returns:
|
41 |
+
Nothing.
|
42 |
+
"""
|
43 |
+
auth_query_params = st.experimental_get_query_params()
|
44 |
+
try:
|
45 |
+
auth_code = dict(auth_query_params)["code"][0]
|
46 |
+
except (KeyError, TypeError):
|
47 |
+
auth_code = ""
|
48 |
+
return auth_code
|
49 |
+
# ----------------------------------
|
50 |
+
# Set authorization code after login
|
51 |
+
# ----------------------------------
|
52 |
+
def set_auth_code():
|
53 |
+
"""
|
54 |
+
Sets auth_code state variable.
|
55 |
+
Returns:
|
56 |
+
Nothing.
|
57 |
+
"""
|
58 |
+
initialise_st_state_vars()
|
59 |
+
auth_code = get_auth_code()
|
60 |
+
st.session_state["auth_code"] = auth_code
|
61 |
+
# -------------------------------------------------------
|
62 |
+
# Use authorization code to get user access and id tokens
|
63 |
+
# -------------------------------------------------------
|
64 |
+
def get_user_tokens(auth_code):
|
65 |
+
"""
|
66 |
+
Gets user tokens by making a post request call.
|
67 |
+
Args:
|
68 |
+
auth_code: Authorization code from cognito server.
|
69 |
+
Returns:
|
70 |
+
{
|
71 |
+
'access_token': access token from cognito server if user is successfully authenticated.
|
72 |
+
'id_token': access token from cognito server if user is successfully authenticated.
|
73 |
+
}
|
74 |
+
"""
|
75 |
+
# Variables to make a post request
|
76 |
+
token_url = f"{COGNITO_DOMAIN}/oauth2/token"
|
77 |
+
client_secret_string = f"{CLIENT_ID}:{CLIENT_SECRET}"
|
78 |
+
client_secret_encoded = str(
|
79 |
+
base64.b64encode(client_secret_string.encode("utf-8")), "utf-8"
|
80 |
+
)
|
81 |
+
headers = {
|
82 |
+
"Content-Type": "application/x-www-form-urlencoded",
|
83 |
+
"Authorization": f"Basic {client_secret_encoded}",
|
84 |
+
}
|
85 |
+
body = {
|
86 |
+
"grant_type": "authorization_code",
|
87 |
+
"client_id": CLIENT_ID,
|
88 |
+
"code": auth_code,
|
89 |
+
"redirect_uri": APP_URI,
|
90 |
+
}
|
91 |
+
token_response = requests.post(token_url, headers=headers, data=body)
|
92 |
+
try:
|
93 |
+
access_token = token_response.json()["access_token"]
|
94 |
+
id_token = token_response.json()["id_token"]
|
95 |
+
except (KeyError, TypeError):
|
96 |
+
access_token = ""
|
97 |
+
id_token = ""
|
98 |
+
return access_token, id_token
|
99 |
+
# ---------------------------------------------
|
100 |
+
# Use access token to retrieve user information
|
101 |
+
# ---------------------------------------------
|
102 |
+
def get_user_info(access_token):
|
103 |
+
"""
|
104 |
+
Gets user info from aws cognito server.
|
105 |
+
Args:
|
106 |
+
access_token: string access token from the aws cognito user pool
|
107 |
+
retrieved using the access code.
|
108 |
+
Returns:
|
109 |
+
userinfo_response: json object.
|
110 |
+
"""
|
111 |
+
userinfo_url = f"{COGNITO_DOMAIN}/oauth2/userInfo"
|
112 |
+
headers = {
|
113 |
+
"Content-Type": "application/json;charset=UTF-8",
|
114 |
+
"Authorization": f"Bearer {access_token}",
|
115 |
+
}
|
116 |
+
userinfo_response = requests.get(userinfo_url, headers=headers)
|
117 |
+
return userinfo_response.json()
|
118 |
+
|
119 |
+
### Add user to a group
|
120 |
+
def add_user_to_group(user_pool_id, username, group_name):
|
121 |
+
client = boto3.client('cognito-idp')
|
122 |
+
|
123 |
+
response = client.admin_add_user_to_group(
|
124 |
+
UserPoolId=user_pool_id,
|
125 |
+
Username=username,
|
126 |
+
GroupName=group_name
|
127 |
+
)
|
128 |
+
|
129 |
+
# Check the response for any errors
|
130 |
+
if 'ResponseMetadata' in response and response['ResponseMetadata']['HTTPStatusCode'] == 200:
|
131 |
+
print("User added to group successfully.")
|
132 |
+
else:
|
133 |
+
print("Failed to add user to group. Error:", response)
|
134 |
+
|
135 |
+
|
136 |
+
## Get user pool id
|
137 |
+
|
138 |
+
def get_user_pool_id(user_pool_name):
|
139 |
+
client = boto3.client('cognito-idp')
|
140 |
+
|
141 |
+
response = client.list_user_pools(MaxResults=60)
|
142 |
+
|
143 |
+
for user_pool in response['UserPools']:
|
144 |
+
if user_pool['Name'] == user_pool_name:
|
145 |
+
return user_pool['Id']
|
146 |
+
|
147 |
+
# If the User Pool with the given name is not found
|
148 |
+
raise ValueError("User Pool '{}' not found.".format(user_pool_name))
|
149 |
+
|
150 |
+
|
151 |
+
# -------------------------------------------------------
|
152 |
+
# Decode access token to JWT to get user's cognito groups
|
153 |
+
# -------------------------------------------------------
|
154 |
+
# Ref - https://gist.github.com/GuillaumeDerval/b300af6d4f906f38a051351afab3b95c
|
155 |
+
def pad_base64(data):
|
156 |
+
"""
|
157 |
+
Makes sure base64 data is padded.
|
158 |
+
Args:
|
159 |
+
data: base64 token string.
|
160 |
+
Returns:
|
161 |
+
data: padded token string.
|
162 |
+
"""
|
163 |
+
missing_padding = len(data) % 4
|
164 |
+
if missing_padding != 0:
|
165 |
+
data += "=" * (4 - missing_padding)
|
166 |
+
return data
|
167 |
+
def get_user_cognito_groups(id_token):
|
168 |
+
"""
|
169 |
+
Decode id token to get user cognito groups.
|
170 |
+
Args:
|
171 |
+
id_token: id token of a successfully authenticated user.
|
172 |
+
Returns:
|
173 |
+
user_cognito_groups: a list of all the cognito groups the user belongs to.
|
174 |
+
"""
|
175 |
+
if id_token != "":
|
176 |
+
header, payload, signature = id_token.split(".")
|
177 |
+
printable_payload = base64.urlsafe_b64decode(pad_base64(payload))
|
178 |
+
payload_dict = json.loads(printable_payload)
|
179 |
+
user_cognito_groups = list(dict(payload_dict)["cognito:groups"])
|
180 |
+
else:
|
181 |
+
user_cognito_groups = []
|
182 |
+
return user_cognito_groups
|
183 |
+
# -----------------------------
|
184 |
+
# Set Streamlit state variables
|
185 |
+
# -----------------------------
|
186 |
+
def set_st_state_vars():
|
187 |
+
"""
|
188 |
+
Sets the streamlit state variables after user authentication.
|
189 |
+
Returns:
|
190 |
+
Nothing.
|
191 |
+
"""
|
192 |
+
initialise_st_state_vars()
|
193 |
+
auth_code = get_auth_code()
|
194 |
+
access_token, id_token = get_user_tokens(auth_code)
|
195 |
+
user_info = get_user_info(access_token)
|
196 |
+
user_cognito_groups = get_user_cognito_groups(id_token)
|
197 |
+
if access_token != "":
|
198 |
+
st.session_state["auth_code"] = auth_code
|
199 |
+
st.session_state["authenticated"] = True
|
200 |
+
st.session_state["user_info"] = user_info
|
201 |
+
st.session_state["user_cognito_groups"] = user_cognito_groups
|
202 |
+
# -----------------------------
|
203 |
+
# Login/ Logout HTML components
|
204 |
+
# -----------------------------
|
205 |
+
login_link = f"{COGNITO_DOMAIN}/login?client_id={CLIENT_ID}&response_type=code&scope=email+openid&redirect_uri={APP_URI}"
|
206 |
+
logout_link = f"{COGNITO_DOMAIN}/logout?client_id={CLIENT_ID}&logout_uri={APP_URI}"
|
207 |
+
html_css_login = """
|
208 |
+
<style>
|
209 |
+
.button-login {
|
210 |
+
background-color: skyblue;
|
211 |
+
color: white !important;
|
212 |
+
padding: 1em 1.5em;
|
213 |
+
text-decoration: none;
|
214 |
+
text-transform: uppercase;
|
215 |
+
}
|
216 |
+
.button-login:hover {
|
217 |
+
background-color: #555;
|
218 |
+
text-decoration: none;
|
219 |
+
}
|
220 |
+
.button-login:active {
|
221 |
+
background-color: black;
|
222 |
+
}
|
223 |
+
</style>
|
224 |
+
"""
|
225 |
+
html_button_login = (
|
226 |
+
html_css_login
|
227 |
+
+ f"<a href='{login_link}' class='button-login' target='_self'>Se connecter</a>"
|
228 |
+
)
|
229 |
+
html_button_logout = (
|
230 |
+
html_css_login
|
231 |
+
+ f"<a href='{logout_link}' class='button-login' target='_self'>Se déconnecter</a>"
|
232 |
+
)
|
233 |
+
def button_login():
|
234 |
+
"""
|
235 |
+
Returns:
|
236 |
+
Html of the login button.
|
237 |
+
"""
|
238 |
+
return st.sidebar.markdown(f"{html_button_login}", unsafe_allow_html=True)
|
239 |
+
def button_logout():
|
240 |
+
"""
|
241 |
+
Returns:
|
242 |
+
Html of the logout button.
|
243 |
+
"""
|
244 |
+
return st.sidebar.markdown(f"{html_button_logout}", unsafe_allow_html=True)
|
components/logo.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# You can always call this function where ever you want
|
5 |
+
|
6 |
+
def add_logo(logo_path, width, height):
|
7 |
+
"""Read and return a resized logo"""
|
8 |
+
logo = Image.open(logo_path)
|
9 |
+
modified_logo = logo.resize((width, height))
|
10 |
+
return modified_logo
|
logo-digitalix.png
ADDED
![]() |
logo_digitalixsa.png
ADDED
![]() |
pages/Limite_Usage.py
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Importation des bibliothèques
|
2 |
+
import json
|
3 |
+
import components.fonctions_transcription as TRS
|
4 |
+
import streamlit as st
|
5 |
+
import components.logo as logo
|
6 |
+
import components.identification_aws as authenticate
|
7 |
+
import datetime
|
8 |
+
from datetime import datetime as date
|
9 |
+
import math
|
10 |
+
|
11 |
+
|
12 |
+
# Chargement du fichier des utilisateurs
|
13 |
+
with open("users_info.json", 'r') as file:
|
14 |
+
dict_user = json.load(file)
|
15 |
+
|
16 |
+
# Logo de la page
|
17 |
+
my_logo = logo.add_logo(logo_path="logo_digitalixsa.png", width=100, height=100)
|
18 |
+
st.image(my_logo)
|
19 |
+
|
20 |
+
# Titre de la page
|
21 |
+
st.title("Limite d'utilisation de la transcription")
|
22 |
+
|
23 |
+
# Calcul annee-mois de trascription
|
24 |
+
maintenant = datetime.datetime.now()
|
25 |
+
Year = maintenant.year
|
26 |
+
Month = maintenant.month
|
27 |
+
Year_Month = str(Year) + '_' + str(Month).zfill(2)
|
28 |
+
|
29 |
+
# Check authentication
|
30 |
+
authenticate.set_st_state_vars()
|
31 |
+
# Add login/logout buttons
|
32 |
+
if st.session_state["authenticated"]:
|
33 |
+
authenticate.button_logout()
|
34 |
+
# informations de l'utilisateur
|
35 |
+
user_group = 'utilisateurs_sidwaya'
|
36 |
+
user_info = st.session_state["user_info"]
|
37 |
+
username = user_info['username']
|
38 |
+
user_group = st.session_state["user_cognito_groups"][0]
|
39 |
+
# information de l'utilisateur
|
40 |
+
user_pool_name = 'transcription_streamlit'
|
41 |
+
# auth_code = st.session_state["auth_code"]
|
42 |
+
# add user to users_dict and group free
|
43 |
+
if username not in dict_user.keys():
|
44 |
+
dict_user[username] = {"email": user_info['email'],
|
45 |
+
"durees_audio_sec":[0],
|
46 |
+
"date_inscription":str(maintenant),
|
47 |
+
"dates_transcription":[str(maintenant)],
|
48 |
+
"abonnement":1}
|
49 |
+
#group_name = 'utilisateurs_gratuits'
|
50 |
+
# get user pool id
|
51 |
+
#user_pool_id = authenticate.get_user_pool_id(user_pool_name)
|
52 |
+
#print("User Pool ID:", user_pool_id)
|
53 |
+
#authenticate.add_user_to_group(user_pool_id, username, group_name)
|
54 |
+
|
55 |
+
##### Affichage utilisation de l'utilisateur #####
|
56 |
+
|
57 |
+
figure , consommation = TRS.graphique_utilisation(dict_user, username, Year_Month)
|
58 |
+
|
59 |
+
### Utilisateur SIDWAYA
|
60 |
+
if user_group == "utilisateurs_sidwaya":
|
61 |
+
date_inscription = dict_user[user_info['username']]['date_inscription']
|
62 |
+
format = "%Y-%m-%d %H:%M:%S.%f"
|
63 |
+
datetime_obj = date.strptime(date_inscription, format)
|
64 |
+
# Calculate the difference between the two dates
|
65 |
+
difference = maintenant - datetime_obj
|
66 |
+
|
67 |
+
# Display the Plotly figure in Streamlit app
|
68 |
+
st.plotly_chart(figure)
|
69 |
+
# Affichage consommation
|
70 |
+
st.text("Consommation du mois : "+ str(round(consommation/3600,2))+ "/ 20H")
|
71 |
+
st.text("Duree abonnement : "+ str(math.floor(difference.days/30) +1) +"/ 12 mois")
|
72 |
+
|
73 |
+
if user_group == "utilisateurs_vip":
|
74 |
+
# Display the Plotly figure in Streamlit app
|
75 |
+
st.plotly_chart(figure)
|
76 |
+
# Affichage consommation
|
77 |
+
st.text("Consommation du mois : "+ str(round(consommation/3600,2))+ "/ 20H")
|
78 |
+
|
79 |
+
if user_group == "utilisateurs_gratuits":
|
80 |
+
# Display the Plotly figure in Streamlit app
|
81 |
+
st.plotly_chart(figure)
|
82 |
+
# Affichage consommation
|
83 |
+
st.text("Consommation du mois : "+ str(round(consommation/3600,2))+ "/ 20H")
|
84 |
+
else:
|
85 |
+
authenticate.button_login()
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
|
90 |
+
|
pages/Transcription.py
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# pip install streamlit
|
2 |
+
import streamlit as st
|
3 |
+
import whisper
|
4 |
+
import components.logo as logo
|
5 |
+
import components.identification_aws as authenticate
|
6 |
+
# from audio_recorder_streamlit import audio_recorder
|
7 |
+
import soundfile as sf
|
8 |
+
import json
|
9 |
+
import datetime
|
10 |
+
from datetime import datetime as date
|
11 |
+
from datetime import timedelta as td
|
12 |
+
import pages.Limite_Usage as graphi
|
13 |
+
import components.fonctions_transcription as TRS
|
14 |
+
import boto3
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
#Region Paris
|
20 |
+
###region="eu-west-3"
|
21 |
+
|
22 |
+
# # Initialize Cognito client
|
23 |
+
# cognito_client = boto3.client('cognito-idp', region_name=region)
|
24 |
+
|
25 |
+
# Chargement du fichier des utilisateurs
|
26 |
+
with open("users_info.json", 'r') as file:
|
27 |
+
dict_user = json.load(file)
|
28 |
+
|
29 |
+
# Logo de la page
|
30 |
+
my_logo = logo.add_logo(logo_path="logo_digitalixsa.png", width=100, height=100)
|
31 |
+
st.image(my_logo)
|
32 |
+
|
33 |
+
# Titre de la page
|
34 |
+
st.title("TRANSCRIPTION AUDIO AUTOMATIQUE DIGITALIX")
|
35 |
+
|
36 |
+
|
37 |
+
# Calcul annee-mois de trascription
|
38 |
+
maintenant = datetime.datetime.now()
|
39 |
+
Year = maintenant.year
|
40 |
+
Month = maintenant.month
|
41 |
+
Year_Month = str(Year) + '_' + str(Month).zfill(2)
|
42 |
+
#text_transcript = ""
|
43 |
+
|
44 |
+
# Check authentication
|
45 |
+
authenticate.set_st_state_vars()
|
46 |
+
# Add login/logout buttons
|
47 |
+
if st.session_state["authenticated"]:
|
48 |
+
authenticate.button_logout()
|
49 |
+
# informations de l'utilisateur
|
50 |
+
user_group = 'utilisateurs_sidwaya'
|
51 |
+
user_info = st.session_state["user_info"]
|
52 |
+
username = user_info['username']
|
53 |
+
user_group = st.session_state["user_cognito_groups"][0]
|
54 |
+
# information de l'utilisateur
|
55 |
+
user_pool_name = 'transcription_streamlit'
|
56 |
+
# auth_code = st.session_state["auth_code"]
|
57 |
+
|
58 |
+
# add user to users_dict and group free
|
59 |
+
if username not in dict_user.keys():
|
60 |
+
dict_user[username] = {"email": user_info['email'],
|
61 |
+
"durees_audio_sec":[0],
|
62 |
+
"date_inscription":str(maintenant),
|
63 |
+
"dates_transcription":[str(maintenant)],
|
64 |
+
"abonnement":1}
|
65 |
+
#group_name = 'utilisateurs_gratuits'
|
66 |
+
# get user pool id
|
67 |
+
#user_pool_id = authenticate.get_user_pool_id(user_pool_name)
|
68 |
+
#print("User Pool ID:", user_pool_id)
|
69 |
+
#authenticate.add_user_to_group(user_pool_id, username, group_name)
|
70 |
+
#Charger l'audio avec streamlit
|
71 |
+
|
72 |
+
audio_file = st.file_uploader("Charger l'audio", type=["wav", "mp3", "m4a"])
|
73 |
+
#audio_name = audio_file.name
|
74 |
+
# Chargement du modèle
|
75 |
+
model = whisper.load_model("medium")
|
76 |
+
st.text("Chargement du modèle terminé")
|
77 |
+
|
78 |
+
|
79 |
+
#Definition quota utilisation
|
80 |
+
quota_20H = 1000
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
if st.sidebar.button("Transcrire l'audio"):
|
86 |
+
# Pour des groupes d'utilisateurs
|
87 |
+
if (user_group == "utilisateurs_sidwaya"):
|
88 |
+
text_transcript = TRS.transcript(dict_user,username,user_group, audio_file,maintenant,Year_Month,quota_20H,model)
|
89 |
+
################ Utilisateurs vip ############################
|
90 |
+
###################################################################
|
91 |
+
# Pour des groupes d'utilisateurs vip
|
92 |
+
if ((user_group == "utilisateurs_vip") or (user_group == "utilisateurs_vip")) :
|
93 |
+
text_transcript = TRS.transcript(dict_user,username,user_group, audio_file,maintenant,Year_Month,quota_20H,model)
|
94 |
+
|
95 |
+
else:
|
96 |
+
authenticate.button_login()
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
# if (st.session_state["authenticated"]):
|
101 |
+
# user_info = st.session_state["user_info"]
|
102 |
+
# username = user_info['username']
|
103 |
+
|
104 |
+
# # # add user to users_dict and group free
|
105 |
+
# # if username not in dict_user.keys() :
|
106 |
+
# # group_name = 'utilisateurs_gratuits'
|
107 |
+
# # # get user pool id
|
108 |
+
# # user_pool_id = authenticate.get_user_pool_id(user_pool_name)
|
109 |
+
# # #print("User Pool ID:", user_pool_id)
|
110 |
+
# # authenticate.add_user_to_group(user_pool_id, username, group_name)
|
111 |
+
|
112 |
+
# # Add the user to the group
|
113 |
+
# group_name = 'utilisateurs_gratuits'
|
114 |
+
# # get user pool id
|
115 |
+
# user_pool_id = authenticate.get_user_pool_id(user_pool_name)
|
116 |
+
# response = cognito_client.admin_add_user_to_group(
|
117 |
+
# UserPoolId=user_pool_id,
|
118 |
+
# Username=username,
|
119 |
+
# GroupName=group_name
|
120 |
+
# )
|
121 |
+
|
122 |
+
# # Check if the operation was successful
|
123 |
+
# if response['ResponseMetadata']['HTTPStatusCode'] == 200:
|
124 |
+
# print('User added to the group successfully.')
|
125 |
+
# else:
|
126 |
+
# print('Failed to add the user to the group.')
|
127 |
+
|
128 |
+
|
129 |
+
|
130 |
+
|
pages/__pycache__/Limite_Usage.cpython-39.pyc
ADDED
Binary file (1.92 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
openai-whisper
|
2 |
+
ffmpeg-python
|
3 |
+
streamlit
|
4 |
+
python-dotenv
|
5 |
+
audio_recorder_streamlit
|
6 |
+
soundfile
|
7 |
+
plotly.express
|
8 |
+
nbformat>=4.2.0
|
9 |
+
boto3
|
test_date.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import datetime
|
2 |
+
# import pandas as pd
|
3 |
+
|
4 |
+
# # Obtenir la date et l'heure actuelles
|
5 |
+
# maintenant = datetime.datetime.now()
|
6 |
+
|
7 |
+
# # Formater la date et l'heure dans le format souhaité
|
8 |
+
# date_formattee = maintenant.strftime("%Y-%m-%d-%H-%M-%S")
|
9 |
+
|
10 |
+
# # Afficher la date formatée
|
11 |
+
# #print(date_formattee.month())
|
12 |
+
# print(maintenant)
|
13 |
+
# print(datetime.datetime.min.date())
|
14 |
+
|
15 |
+
|
16 |
+
##### Affichage utilisation de l'utilisateur #####
|
17 |
+
# import json
|
18 |
+
|
19 |
+
# # Chargement du fichier des utilisateurs
|
20 |
+
# with open("users_info.json", 'r') as file:
|
21 |
+
# dict_user = json.load(file)
|
22 |
+
|
23 |
+
# # Convert JSON to DataFrame
|
24 |
+
# df_user = pd.json_normalize(dict_user)
|
25 |
+
|
26 |
+
# print(df_user)
|
27 |
+
|
28 |
+
# username_test = "18202e69-afba-430b-a7f2-cf33c0a173b5"
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
test_json.ipynb
ADDED
@@ -0,0 +1,1222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd\n",
|
10 |
+
"import json\n",
|
11 |
+
"import plotly.express as px"
|
12 |
+
]
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"cell_type": "code",
|
16 |
+
"execution_count": 2,
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"text/html": [
|
22 |
+
"<div>\n",
|
23 |
+
"<style scoped>\n",
|
24 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
25 |
+
" vertical-align: middle;\n",
|
26 |
+
" }\n",
|
27 |
+
"\n",
|
28 |
+
" .dataframe tbody tr th {\n",
|
29 |
+
" vertical-align: top;\n",
|
30 |
+
" }\n",
|
31 |
+
"\n",
|
32 |
+
" .dataframe thead th {\n",
|
33 |
+
" text-align: right;\n",
|
34 |
+
" }\n",
|
35 |
+
"</style>\n",
|
36 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
37 |
+
" <thead>\n",
|
38 |
+
" <tr style=\"text-align: right;\">\n",
|
39 |
+
" <th></th>\n",
|
40 |
+
" <th>usernames</th>\n",
|
41 |
+
" <th>email</th>\n",
|
42 |
+
" <th>durees_audio_sec</th>\n",
|
43 |
+
" <th>date_inscription</th>\n",
|
44 |
+
" <th>dates_transcription</th>\n",
|
45 |
+
" <th>Year</th>\n",
|
46 |
+
" <th>Month</th>\n",
|
47 |
+
" <th>Year_Month</th>\n",
|
48 |
+
" </tr>\n",
|
49 |
+
" </thead>\n",
|
50 |
+
" <tbody>\n",
|
51 |
+
" <tr>\n",
|
52 |
+
" <th>0</th>\n",
|
53 |
+
" <td>18202e69-afba-430b-a7f2-cf33c0a173b5</td>\n",
|
54 |
+
" <td>[email protected]</td>\n",
|
55 |
+
" <td>56.753311</td>\n",
|
56 |
+
" <td>2023-06-14 13:59:03.140847</td>\n",
|
57 |
+
" <td>2023-06-14 13:59:03.140847</td>\n",
|
58 |
+
" <td>2023</td>\n",
|
59 |
+
" <td>6</td>\n",
|
60 |
+
" <td>2023_06</td>\n",
|
61 |
+
" </tr>\n",
|
62 |
+
" <tr>\n",
|
63 |
+
" <th>1</th>\n",
|
64 |
+
" <td>18202e69-afba-430b-a7f2-cf33c0a173b5</td>\n",
|
65 |
+
" <td>[email protected]</td>\n",
|
66 |
+
" <td>56.753311</td>\n",
|
67 |
+
" <td>2023-06-14 13:59:03.140847</td>\n",
|
68 |
+
" <td>2023-06-14 14:01:42.171527</td>\n",
|
69 |
+
" <td>2023</td>\n",
|
70 |
+
" <td>6</td>\n",
|
71 |
+
" <td>2023_06</td>\n",
|
72 |
+
" </tr>\n",
|
73 |
+
" <tr>\n",
|
74 |
+
" <th>2</th>\n",
|
75 |
+
" <td>18202e69-afba-430b-a7f2-cf33c0a173b5</td>\n",
|
76 |
+
" <td>[email protected]</td>\n",
|
77 |
+
" <td>56.753311</td>\n",
|
78 |
+
" <td>2023-06-14 13:59:03.140847</td>\n",
|
79 |
+
" <td>2023-06-14 14:03:44.971361</td>\n",
|
80 |
+
" <td>2023</td>\n",
|
81 |
+
" <td>6</td>\n",
|
82 |
+
" <td>2023_06</td>\n",
|
83 |
+
" </tr>\n",
|
84 |
+
" <tr>\n",
|
85 |
+
" <th>3</th>\n",
|
86 |
+
" <td>18202e69-afba-430b-a7f2-cf33c0a173b5</td>\n",
|
87 |
+
" <td>[email protected]</td>\n",
|
88 |
+
" <td>232.408542</td>\n",
|
89 |
+
" <td>2023-06-14 13:59:03.140847</td>\n",
|
90 |
+
" <td>2023-06-15 00:10:08.233341</td>\n",
|
91 |
+
" <td>2023</td>\n",
|
92 |
+
" <td>6</td>\n",
|
93 |
+
" <td>2023_06</td>\n",
|
94 |
+
" </tr>\n",
|
95 |
+
" <tr>\n",
|
96 |
+
" <th>4</th>\n",
|
97 |
+
" <td>401507b3-9030-4690-969b-524b37ba5bc9</td>\n",
|
98 |
+
" <td>[email protected]</td>\n",
|
99 |
+
" <td>56.753311</td>\n",
|
100 |
+
" <td>2023-06-14 14:05:49.398837</td>\n",
|
101 |
+
" <td>2023-06-14 14:05:49.398837</td>\n",
|
102 |
+
" <td>2023</td>\n",
|
103 |
+
" <td>6</td>\n",
|
104 |
+
" <td>2023_06</td>\n",
|
105 |
+
" </tr>\n",
|
106 |
+
" </tbody>\n",
|
107 |
+
"</table>\n",
|
108 |
+
"</div>"
|
109 |
+
],
|
110 |
+
"text/plain": [
|
111 |
+
" usernames email \n",
|
112 |
+
"0 18202e69-afba-430b-a7f2-cf33c0a173b5 [email protected] \\\n",
|
113 |
+
"1 18202e69-afba-430b-a7f2-cf33c0a173b5 [email protected] \n",
|
114 |
+
"2 18202e69-afba-430b-a7f2-cf33c0a173b5 [email protected] \n",
|
115 |
+
"3 18202e69-afba-430b-a7f2-cf33c0a173b5 [email protected] \n",
|
116 |
+
"4 401507b3-9030-4690-969b-524b37ba5bc9 [email protected] \n",
|
117 |
+
"\n",
|
118 |
+
" durees_audio_sec date_inscription dates_transcription \n",
|
119 |
+
"0 56.753311 2023-06-14 13:59:03.140847 2023-06-14 13:59:03.140847 \\\n",
|
120 |
+
"1 56.753311 2023-06-14 13:59:03.140847 2023-06-14 14:01:42.171527 \n",
|
121 |
+
"2 56.753311 2023-06-14 13:59:03.140847 2023-06-14 14:03:44.971361 \n",
|
122 |
+
"3 232.408542 2023-06-14 13:59:03.140847 2023-06-15 00:10:08.233341 \n",
|
123 |
+
"4 56.753311 2023-06-14 14:05:49.398837 2023-06-14 14:05:49.398837 \n",
|
124 |
+
"\n",
|
125 |
+
" Year Month Year_Month \n",
|
126 |
+
"0 2023 6 2023_06 \n",
|
127 |
+
"1 2023 6 2023_06 \n",
|
128 |
+
"2 2023 6 2023_06 \n",
|
129 |
+
"3 2023 6 2023_06 \n",
|
130 |
+
"4 2023 6 2023_06 "
|
131 |
+
]
|
132 |
+
},
|
133 |
+
"execution_count": 2,
|
134 |
+
"metadata": {},
|
135 |
+
"output_type": "execute_result"
|
136 |
+
}
|
137 |
+
],
|
138 |
+
"source": [
|
139 |
+
"##### Affichage utilisation de l'utilisateur #####\n",
|
140 |
+
"# Chargement du fichier des utilisateurs\n",
|
141 |
+
"with open(\"users_info.json\", 'r') as file:\n",
|
142 |
+
" dict_user = json.load(file)\n",
|
143 |
+
"\n",
|
144 |
+
"# Transformation en dataframe\n",
|
145 |
+
"df_user = pd.DataFrame(dict_user).T.reset_index()\n",
|
146 |
+
"df_user.rename(columns={\"index\":\"usernames\"},inplace = True)\n",
|
147 |
+
"\n",
|
148 |
+
"# Separation des lignes de listes en plusieurs lignes pour les colonees duree_audio_sec et dates_transcription\n",
|
149 |
+
"df_duree = df_user.drop(['dates_transcription'],axis=1) \n",
|
150 |
+
"df_duree = df_duree.explode('durees_audio_sec')\n",
|
151 |
+
"df_duree = df_duree.reset_index(drop=True)\n",
|
152 |
+
"\n",
|
153 |
+
"df_transcription = df_user.drop(['durees_audio_sec'],axis=1)\n",
|
154 |
+
"df_transcription = df_transcription.explode('dates_transcription')\n",
|
155 |
+
"df_transcription = df_transcription.reset_index(drop=True)\n",
|
156 |
+
"\n",
|
157 |
+
"# Regroupement des dataframes\n",
|
158 |
+
"df_user = df_duree.copy()\n",
|
159 |
+
"df_user[\"dates_transcription\"] = df_transcription[\"dates_transcription\"]\n",
|
160 |
+
"\n",
|
161 |
+
"df_user['date_inscription'] = pd.to_datetime(df_user['date_inscription'],format = \"%Y-%m-%d %H:%M:%S.%f\")\n",
|
162 |
+
"df_user['dates_transcription'] = pd.to_datetime(df_user['dates_transcription'],format = \"%Y-%m-%d %H:%M:%S.%f\")\n",
|
163 |
+
"\n",
|
164 |
+
"# Calcul annee-mois de trascription\n",
|
165 |
+
"df_user['Year'] = df_user['dates_transcription'].dt.year\n",
|
166 |
+
"df_user['Month'] = df_user['dates_transcription'].dt.month\n",
|
167 |
+
"df_user['Year_Month'] = df_user['Year'].astype(str) + '_' + df_user['Month'].astype(str).str.zfill(2)\n",
|
168 |
+
"df_user\n"
|
169 |
+
]
|
170 |
+
},
|
171 |
+
{
|
172 |
+
"cell_type": "code",
|
173 |
+
"execution_count": 3,
|
174 |
+
"metadata": {},
|
175 |
+
"outputs": [
|
176 |
+
{
|
177 |
+
"data": {
|
178 |
+
"application/vnd.plotly.v1+json": {
|
179 |
+
"config": {
|
180 |
+
"plotlyServerURL": "https://plot.ly"
|
181 |
+
},
|
182 |
+
"data": [
|
183 |
+
{
|
184 |
+
"hovertemplate": "dates_transcription=%{x}<br>durees_audio_sec=%{y}<extra></extra>",
|
185 |
+
"legendgroup": "",
|
186 |
+
"line": {
|
187 |
+
"color": "#636efa",
|
188 |
+
"dash": "solid"
|
189 |
+
},
|
190 |
+
"marker": {
|
191 |
+
"symbol": "circle"
|
192 |
+
},
|
193 |
+
"mode": "lines",
|
194 |
+
"name": "",
|
195 |
+
"orientation": "v",
|
196 |
+
"showlegend": false,
|
197 |
+
"type": "scatter",
|
198 |
+
"x": [
|
199 |
+
"2023-06-14T13:59:03.140847",
|
200 |
+
"2023-06-14T14:01:42.171527",
|
201 |
+
"2023-06-14T14:03:44.971361",
|
202 |
+
"2023-06-15T00:10:08.233341"
|
203 |
+
],
|
204 |
+
"xaxis": "x",
|
205 |
+
"y": [
|
206 |
+
56.75331065759637,
|
207 |
+
56.75331065759637,
|
208 |
+
56.75331065759637,
|
209 |
+
232.40854166666668
|
210 |
+
],
|
211 |
+
"yaxis": "y"
|
212 |
+
}
|
213 |
+
],
|
214 |
+
"layout": {
|
215 |
+
"annotations": [
|
216 |
+
{
|
217 |
+
"font": {
|
218 |
+
"color": "red"
|
219 |
+
},
|
220 |
+
"showarrow": false,
|
221 |
+
"text": "SEUIL DE 20H = 72000 secondes",
|
222 |
+
"x": "2023-06-15T00:10:08.233341",
|
223 |
+
"xshift": -40,
|
224 |
+
"y": 72000,
|
225 |
+
"yshift": 20
|
226 |
+
}
|
227 |
+
],
|
228 |
+
"legend": {
|
229 |
+
"tracegroupgap": 0
|
230 |
+
},
|
231 |
+
"margin": {
|
232 |
+
"t": 60
|
233 |
+
},
|
234 |
+
"shapes": [
|
235 |
+
{
|
236 |
+
"line": {
|
237 |
+
"color": "red",
|
238 |
+
"dash": "dash",
|
239 |
+
"width": 2
|
240 |
+
},
|
241 |
+
"type": "line",
|
242 |
+
"x0": "2023-06-14T13:59:03.140847",
|
243 |
+
"x1": "2023-06-15T00:10:08.233341",
|
244 |
+
"y0": 72000,
|
245 |
+
"y1": 72000
|
246 |
+
}
|
247 |
+
],
|
248 |
+
"template": {
|
249 |
+
"data": {
|
250 |
+
"bar": [
|
251 |
+
{
|
252 |
+
"error_x": {
|
253 |
+
"color": "#2a3f5f"
|
254 |
+
},
|
255 |
+
"error_y": {
|
256 |
+
"color": "#2a3f5f"
|
257 |
+
},
|
258 |
+
"marker": {
|
259 |
+
"line": {
|
260 |
+
"color": "#E5ECF6",
|
261 |
+
"width": 0.5
|
262 |
+
},
|
263 |
+
"pattern": {
|
264 |
+
"fillmode": "overlay",
|
265 |
+
"size": 10,
|
266 |
+
"solidity": 0.2
|
267 |
+
}
|
268 |
+
},
|
269 |
+
"type": "bar"
|
270 |
+
}
|
271 |
+
],
|
272 |
+
"barpolar": [
|
273 |
+
{
|
274 |
+
"marker": {
|
275 |
+
"line": {
|
276 |
+
"color": "#E5ECF6",
|
277 |
+
"width": 0.5
|
278 |
+
},
|
279 |
+
"pattern": {
|
280 |
+
"fillmode": "overlay",
|
281 |
+
"size": 10,
|
282 |
+
"solidity": 0.2
|
283 |
+
}
|
284 |
+
},
|
285 |
+
"type": "barpolar"
|
286 |
+
}
|
287 |
+
],
|
288 |
+
"carpet": [
|
289 |
+
{
|
290 |
+
"aaxis": {
|
291 |
+
"endlinecolor": "#2a3f5f",
|
292 |
+
"gridcolor": "white",
|
293 |
+
"linecolor": "white",
|
294 |
+
"minorgridcolor": "white",
|
295 |
+
"startlinecolor": "#2a3f5f"
|
296 |
+
},
|
297 |
+
"baxis": {
|
298 |
+
"endlinecolor": "#2a3f5f",
|
299 |
+
"gridcolor": "white",
|
300 |
+
"linecolor": "white",
|
301 |
+
"minorgridcolor": "white",
|
302 |
+
"startlinecolor": "#2a3f5f"
|
303 |
+
},
|
304 |
+
"type": "carpet"
|
305 |
+
}
|
306 |
+
],
|
307 |
+
"choropleth": [
|
308 |
+
{
|
309 |
+
"colorbar": {
|
310 |
+
"outlinewidth": 0,
|
311 |
+
"ticks": ""
|
312 |
+
},
|
313 |
+
"type": "choropleth"
|
314 |
+
}
|
315 |
+
],
|
316 |
+
"contour": [
|
317 |
+
{
|
318 |
+
"colorbar": {
|
319 |
+
"outlinewidth": 0,
|
320 |
+
"ticks": ""
|
321 |
+
},
|
322 |
+
"colorscale": [
|
323 |
+
[
|
324 |
+
0,
|
325 |
+
"#0d0887"
|
326 |
+
],
|
327 |
+
[
|
328 |
+
0.1111111111111111,
|
329 |
+
"#46039f"
|
330 |
+
],
|
331 |
+
[
|
332 |
+
0.2222222222222222,
|
333 |
+
"#7201a8"
|
334 |
+
],
|
335 |
+
[
|
336 |
+
0.3333333333333333,
|
337 |
+
"#9c179e"
|
338 |
+
],
|
339 |
+
[
|
340 |
+
0.4444444444444444,
|
341 |
+
"#bd3786"
|
342 |
+
],
|
343 |
+
[
|
344 |
+
0.5555555555555556,
|
345 |
+
"#d8576b"
|
346 |
+
],
|
347 |
+
[
|
348 |
+
0.6666666666666666,
|
349 |
+
"#ed7953"
|
350 |
+
],
|
351 |
+
[
|
352 |
+
0.7777777777777778,
|
353 |
+
"#fb9f3a"
|
354 |
+
],
|
355 |
+
[
|
356 |
+
0.8888888888888888,
|
357 |
+
"#fdca26"
|
358 |
+
],
|
359 |
+
[
|
360 |
+
1,
|
361 |
+
"#f0f921"
|
362 |
+
]
|
363 |
+
],
|
364 |
+
"type": "contour"
|
365 |
+
}
|
366 |
+
],
|
367 |
+
"contourcarpet": [
|
368 |
+
{
|
369 |
+
"colorbar": {
|
370 |
+
"outlinewidth": 0,
|
371 |
+
"ticks": ""
|
372 |
+
},
|
373 |
+
"type": "contourcarpet"
|
374 |
+
}
|
375 |
+
],
|
376 |
+
"heatmap": [
|
377 |
+
{
|
378 |
+
"colorbar": {
|
379 |
+
"outlinewidth": 0,
|
380 |
+
"ticks": ""
|
381 |
+
},
|
382 |
+
"colorscale": [
|
383 |
+
[
|
384 |
+
0,
|
385 |
+
"#0d0887"
|
386 |
+
],
|
387 |
+
[
|
388 |
+
0.1111111111111111,
|
389 |
+
"#46039f"
|
390 |
+
],
|
391 |
+
[
|
392 |
+
0.2222222222222222,
|
393 |
+
"#7201a8"
|
394 |
+
],
|
395 |
+
[
|
396 |
+
0.3333333333333333,
|
397 |
+
"#9c179e"
|
398 |
+
],
|
399 |
+
[
|
400 |
+
0.4444444444444444,
|
401 |
+
"#bd3786"
|
402 |
+
],
|
403 |
+
[
|
404 |
+
0.5555555555555556,
|
405 |
+
"#d8576b"
|
406 |
+
],
|
407 |
+
[
|
408 |
+
0.6666666666666666,
|
409 |
+
"#ed7953"
|
410 |
+
],
|
411 |
+
[
|
412 |
+
0.7777777777777778,
|
413 |
+
"#fb9f3a"
|
414 |
+
],
|
415 |
+
[
|
416 |
+
0.8888888888888888,
|
417 |
+
"#fdca26"
|
418 |
+
],
|
419 |
+
[
|
420 |
+
1,
|
421 |
+
"#f0f921"
|
422 |
+
]
|
423 |
+
],
|
424 |
+
"type": "heatmap"
|
425 |
+
}
|
426 |
+
],
|
427 |
+
"heatmapgl": [
|
428 |
+
{
|
429 |
+
"colorbar": {
|
430 |
+
"outlinewidth": 0,
|
431 |
+
"ticks": ""
|
432 |
+
},
|
433 |
+
"colorscale": [
|
434 |
+
[
|
435 |
+
0,
|
436 |
+
"#0d0887"
|
437 |
+
],
|
438 |
+
[
|
439 |
+
0.1111111111111111,
|
440 |
+
"#46039f"
|
441 |
+
],
|
442 |
+
[
|
443 |
+
0.2222222222222222,
|
444 |
+
"#7201a8"
|
445 |
+
],
|
446 |
+
[
|
447 |
+
0.3333333333333333,
|
448 |
+
"#9c179e"
|
449 |
+
],
|
450 |
+
[
|
451 |
+
0.4444444444444444,
|
452 |
+
"#bd3786"
|
453 |
+
],
|
454 |
+
[
|
455 |
+
0.5555555555555556,
|
456 |
+
"#d8576b"
|
457 |
+
],
|
458 |
+
[
|
459 |
+
0.6666666666666666,
|
460 |
+
"#ed7953"
|
461 |
+
],
|
462 |
+
[
|
463 |
+
0.7777777777777778,
|
464 |
+
"#fb9f3a"
|
465 |
+
],
|
466 |
+
[
|
467 |
+
0.8888888888888888,
|
468 |
+
"#fdca26"
|
469 |
+
],
|
470 |
+
[
|
471 |
+
1,
|
472 |
+
"#f0f921"
|
473 |
+
]
|
474 |
+
],
|
475 |
+
"type": "heatmapgl"
|
476 |
+
}
|
477 |
+
],
|
478 |
+
"histogram": [
|
479 |
+
{
|
480 |
+
"marker": {
|
481 |
+
"pattern": {
|
482 |
+
"fillmode": "overlay",
|
483 |
+
"size": 10,
|
484 |
+
"solidity": 0.2
|
485 |
+
}
|
486 |
+
},
|
487 |
+
"type": "histogram"
|
488 |
+
}
|
489 |
+
],
|
490 |
+
"histogram2d": [
|
491 |
+
{
|
492 |
+
"colorbar": {
|
493 |
+
"outlinewidth": 0,
|
494 |
+
"ticks": ""
|
495 |
+
},
|
496 |
+
"colorscale": [
|
497 |
+
[
|
498 |
+
0,
|
499 |
+
"#0d0887"
|
500 |
+
],
|
501 |
+
[
|
502 |
+
0.1111111111111111,
|
503 |
+
"#46039f"
|
504 |
+
],
|
505 |
+
[
|
506 |
+
0.2222222222222222,
|
507 |
+
"#7201a8"
|
508 |
+
],
|
509 |
+
[
|
510 |
+
0.3333333333333333,
|
511 |
+
"#9c179e"
|
512 |
+
],
|
513 |
+
[
|
514 |
+
0.4444444444444444,
|
515 |
+
"#bd3786"
|
516 |
+
],
|
517 |
+
[
|
518 |
+
0.5555555555555556,
|
519 |
+
"#d8576b"
|
520 |
+
],
|
521 |
+
[
|
522 |
+
0.6666666666666666,
|
523 |
+
"#ed7953"
|
524 |
+
],
|
525 |
+
[
|
526 |
+
0.7777777777777778,
|
527 |
+
"#fb9f3a"
|
528 |
+
],
|
529 |
+
[
|
530 |
+
0.8888888888888888,
|
531 |
+
"#fdca26"
|
532 |
+
],
|
533 |
+
[
|
534 |
+
1,
|
535 |
+
"#f0f921"
|
536 |
+
]
|
537 |
+
],
|
538 |
+
"type": "histogram2d"
|
539 |
+
}
|
540 |
+
],
|
541 |
+
"histogram2dcontour": [
|
542 |
+
{
|
543 |
+
"colorbar": {
|
544 |
+
"outlinewidth": 0,
|
545 |
+
"ticks": ""
|
546 |
+
},
|
547 |
+
"colorscale": [
|
548 |
+
[
|
549 |
+
0,
|
550 |
+
"#0d0887"
|
551 |
+
],
|
552 |
+
[
|
553 |
+
0.1111111111111111,
|
554 |
+
"#46039f"
|
555 |
+
],
|
556 |
+
[
|
557 |
+
0.2222222222222222,
|
558 |
+
"#7201a8"
|
559 |
+
],
|
560 |
+
[
|
561 |
+
0.3333333333333333,
|
562 |
+
"#9c179e"
|
563 |
+
],
|
564 |
+
[
|
565 |
+
0.4444444444444444,
|
566 |
+
"#bd3786"
|
567 |
+
],
|
568 |
+
[
|
569 |
+
0.5555555555555556,
|
570 |
+
"#d8576b"
|
571 |
+
],
|
572 |
+
[
|
573 |
+
0.6666666666666666,
|
574 |
+
"#ed7953"
|
575 |
+
],
|
576 |
+
[
|
577 |
+
0.7777777777777778,
|
578 |
+
"#fb9f3a"
|
579 |
+
],
|
580 |
+
[
|
581 |
+
0.8888888888888888,
|
582 |
+
"#fdca26"
|
583 |
+
],
|
584 |
+
[
|
585 |
+
1,
|
586 |
+
"#f0f921"
|
587 |
+
]
|
588 |
+
],
|
589 |
+
"type": "histogram2dcontour"
|
590 |
+
}
|
591 |
+
],
|
592 |
+
"mesh3d": [
|
593 |
+
{
|
594 |
+
"colorbar": {
|
595 |
+
"outlinewidth": 0,
|
596 |
+
"ticks": ""
|
597 |
+
},
|
598 |
+
"type": "mesh3d"
|
599 |
+
}
|
600 |
+
],
|
601 |
+
"parcoords": [
|
602 |
+
{
|
603 |
+
"line": {
|
604 |
+
"colorbar": {
|
605 |
+
"outlinewidth": 0,
|
606 |
+
"ticks": ""
|
607 |
+
}
|
608 |
+
},
|
609 |
+
"type": "parcoords"
|
610 |
+
}
|
611 |
+
],
|
612 |
+
"pie": [
|
613 |
+
{
|
614 |
+
"automargin": true,
|
615 |
+
"type": "pie"
|
616 |
+
}
|
617 |
+
],
|
618 |
+
"scatter": [
|
619 |
+
{
|
620 |
+
"fillpattern": {
|
621 |
+
"fillmode": "overlay",
|
622 |
+
"size": 10,
|
623 |
+
"solidity": 0.2
|
624 |
+
},
|
625 |
+
"type": "scatter"
|
626 |
+
}
|
627 |
+
],
|
628 |
+
"scatter3d": [
|
629 |
+
{
|
630 |
+
"line": {
|
631 |
+
"colorbar": {
|
632 |
+
"outlinewidth": 0,
|
633 |
+
"ticks": ""
|
634 |
+
}
|
635 |
+
},
|
636 |
+
"marker": {
|
637 |
+
"colorbar": {
|
638 |
+
"outlinewidth": 0,
|
639 |
+
"ticks": ""
|
640 |
+
}
|
641 |
+
},
|
642 |
+
"type": "scatter3d"
|
643 |
+
}
|
644 |
+
],
|
645 |
+
"scattercarpet": [
|
646 |
+
{
|
647 |
+
"marker": {
|
648 |
+
"colorbar": {
|
649 |
+
"outlinewidth": 0,
|
650 |
+
"ticks": ""
|
651 |
+
}
|
652 |
+
},
|
653 |
+
"type": "scattercarpet"
|
654 |
+
}
|
655 |
+
],
|
656 |
+
"scattergeo": [
|
657 |
+
{
|
658 |
+
"marker": {
|
659 |
+
"colorbar": {
|
660 |
+
"outlinewidth": 0,
|
661 |
+
"ticks": ""
|
662 |
+
}
|
663 |
+
},
|
664 |
+
"type": "scattergeo"
|
665 |
+
}
|
666 |
+
],
|
667 |
+
"scattergl": [
|
668 |
+
{
|
669 |
+
"marker": {
|
670 |
+
"colorbar": {
|
671 |
+
"outlinewidth": 0,
|
672 |
+
"ticks": ""
|
673 |
+
}
|
674 |
+
},
|
675 |
+
"type": "scattergl"
|
676 |
+
}
|
677 |
+
],
|
678 |
+
"scattermapbox": [
|
679 |
+
{
|
680 |
+
"marker": {
|
681 |
+
"colorbar": {
|
682 |
+
"outlinewidth": 0,
|
683 |
+
"ticks": ""
|
684 |
+
}
|
685 |
+
},
|
686 |
+
"type": "scattermapbox"
|
687 |
+
}
|
688 |
+
],
|
689 |
+
"scatterpolar": [
|
690 |
+
{
|
691 |
+
"marker": {
|
692 |
+
"colorbar": {
|
693 |
+
"outlinewidth": 0,
|
694 |
+
"ticks": ""
|
695 |
+
}
|
696 |
+
},
|
697 |
+
"type": "scatterpolar"
|
698 |
+
}
|
699 |
+
],
|
700 |
+
"scatterpolargl": [
|
701 |
+
{
|
702 |
+
"marker": {
|
703 |
+
"colorbar": {
|
704 |
+
"outlinewidth": 0,
|
705 |
+
"ticks": ""
|
706 |
+
}
|
707 |
+
},
|
708 |
+
"type": "scatterpolargl"
|
709 |
+
}
|
710 |
+
],
|
711 |
+
"scatterternary": [
|
712 |
+
{
|
713 |
+
"marker": {
|
714 |
+
"colorbar": {
|
715 |
+
"outlinewidth": 0,
|
716 |
+
"ticks": ""
|
717 |
+
}
|
718 |
+
},
|
719 |
+
"type": "scatterternary"
|
720 |
+
}
|
721 |
+
],
|
722 |
+
"surface": [
|
723 |
+
{
|
724 |
+
"colorbar": {
|
725 |
+
"outlinewidth": 0,
|
726 |
+
"ticks": ""
|
727 |
+
},
|
728 |
+
"colorscale": [
|
729 |
+
[
|
730 |
+
0,
|
731 |
+
"#0d0887"
|
732 |
+
],
|
733 |
+
[
|
734 |
+
0.1111111111111111,
|
735 |
+
"#46039f"
|
736 |
+
],
|
737 |
+
[
|
738 |
+
0.2222222222222222,
|
739 |
+
"#7201a8"
|
740 |
+
],
|
741 |
+
[
|
742 |
+
0.3333333333333333,
|
743 |
+
"#9c179e"
|
744 |
+
],
|
745 |
+
[
|
746 |
+
0.4444444444444444,
|
747 |
+
"#bd3786"
|
748 |
+
],
|
749 |
+
[
|
750 |
+
0.5555555555555556,
|
751 |
+
"#d8576b"
|
752 |
+
],
|
753 |
+
[
|
754 |
+
0.6666666666666666,
|
755 |
+
"#ed7953"
|
756 |
+
],
|
757 |
+
[
|
758 |
+
0.7777777777777778,
|
759 |
+
"#fb9f3a"
|
760 |
+
],
|
761 |
+
[
|
762 |
+
0.8888888888888888,
|
763 |
+
"#fdca26"
|
764 |
+
],
|
765 |
+
[
|
766 |
+
1,
|
767 |
+
"#f0f921"
|
768 |
+
]
|
769 |
+
],
|
770 |
+
"type": "surface"
|
771 |
+
}
|
772 |
+
],
|
773 |
+
"table": [
|
774 |
+
{
|
775 |
+
"cells": {
|
776 |
+
"fill": {
|
777 |
+
"color": "#EBF0F8"
|
778 |
+
},
|
779 |
+
"line": {
|
780 |
+
"color": "white"
|
781 |
+
}
|
782 |
+
},
|
783 |
+
"header": {
|
784 |
+
"fill": {
|
785 |
+
"color": "#C8D4E3"
|
786 |
+
},
|
787 |
+
"line": {
|
788 |
+
"color": "white"
|
789 |
+
}
|
790 |
+
},
|
791 |
+
"type": "table"
|
792 |
+
}
|
793 |
+
]
|
794 |
+
},
|
795 |
+
"layout": {
|
796 |
+
"annotationdefaults": {
|
797 |
+
"arrowcolor": "#2a3f5f",
|
798 |
+
"arrowhead": 0,
|
799 |
+
"arrowwidth": 1
|
800 |
+
},
|
801 |
+
"autotypenumbers": "strict",
|
802 |
+
"coloraxis": {
|
803 |
+
"colorbar": {
|
804 |
+
"outlinewidth": 0,
|
805 |
+
"ticks": ""
|
806 |
+
}
|
807 |
+
},
|
808 |
+
"colorscale": {
|
809 |
+
"diverging": [
|
810 |
+
[
|
811 |
+
0,
|
812 |
+
"#8e0152"
|
813 |
+
],
|
814 |
+
[
|
815 |
+
0.1,
|
816 |
+
"#c51b7d"
|
817 |
+
],
|
818 |
+
[
|
819 |
+
0.2,
|
820 |
+
"#de77ae"
|
821 |
+
],
|
822 |
+
[
|
823 |
+
0.3,
|
824 |
+
"#f1b6da"
|
825 |
+
],
|
826 |
+
[
|
827 |
+
0.4,
|
828 |
+
"#fde0ef"
|
829 |
+
],
|
830 |
+
[
|
831 |
+
0.5,
|
832 |
+
"#f7f7f7"
|
833 |
+
],
|
834 |
+
[
|
835 |
+
0.6,
|
836 |
+
"#e6f5d0"
|
837 |
+
],
|
838 |
+
[
|
839 |
+
0.7,
|
840 |
+
"#b8e186"
|
841 |
+
],
|
842 |
+
[
|
843 |
+
0.8,
|
844 |
+
"#7fbc41"
|
845 |
+
],
|
846 |
+
[
|
847 |
+
0.9,
|
848 |
+
"#4d9221"
|
849 |
+
],
|
850 |
+
[
|
851 |
+
1,
|
852 |
+
"#276419"
|
853 |
+
]
|
854 |
+
],
|
855 |
+
"sequential": [
|
856 |
+
[
|
857 |
+
0,
|
858 |
+
"#0d0887"
|
859 |
+
],
|
860 |
+
[
|
861 |
+
0.1111111111111111,
|
862 |
+
"#46039f"
|
863 |
+
],
|
864 |
+
[
|
865 |
+
0.2222222222222222,
|
866 |
+
"#7201a8"
|
867 |
+
],
|
868 |
+
[
|
869 |
+
0.3333333333333333,
|
870 |
+
"#9c179e"
|
871 |
+
],
|
872 |
+
[
|
873 |
+
0.4444444444444444,
|
874 |
+
"#bd3786"
|
875 |
+
],
|
876 |
+
[
|
877 |
+
0.5555555555555556,
|
878 |
+
"#d8576b"
|
879 |
+
],
|
880 |
+
[
|
881 |
+
0.6666666666666666,
|
882 |
+
"#ed7953"
|
883 |
+
],
|
884 |
+
[
|
885 |
+
0.7777777777777778,
|
886 |
+
"#fb9f3a"
|
887 |
+
],
|
888 |
+
[
|
889 |
+
0.8888888888888888,
|
890 |
+
"#fdca26"
|
891 |
+
],
|
892 |
+
[
|
893 |
+
1,
|
894 |
+
"#f0f921"
|
895 |
+
]
|
896 |
+
],
|
897 |
+
"sequentialminus": [
|
898 |
+
[
|
899 |
+
0,
|
900 |
+
"#0d0887"
|
901 |
+
],
|
902 |
+
[
|
903 |
+
0.1111111111111111,
|
904 |
+
"#46039f"
|
905 |
+
],
|
906 |
+
[
|
907 |
+
0.2222222222222222,
|
908 |
+
"#7201a8"
|
909 |
+
],
|
910 |
+
[
|
911 |
+
0.3333333333333333,
|
912 |
+
"#9c179e"
|
913 |
+
],
|
914 |
+
[
|
915 |
+
0.4444444444444444,
|
916 |
+
"#bd3786"
|
917 |
+
],
|
918 |
+
[
|
919 |
+
0.5555555555555556,
|
920 |
+
"#d8576b"
|
921 |
+
],
|
922 |
+
[
|
923 |
+
0.6666666666666666,
|
924 |
+
"#ed7953"
|
925 |
+
],
|
926 |
+
[
|
927 |
+
0.7777777777777778,
|
928 |
+
"#fb9f3a"
|
929 |
+
],
|
930 |
+
[
|
931 |
+
0.8888888888888888,
|
932 |
+
"#fdca26"
|
933 |
+
],
|
934 |
+
[
|
935 |
+
1,
|
936 |
+
"#f0f921"
|
937 |
+
]
|
938 |
+
]
|
939 |
+
},
|
940 |
+
"colorway": [
|
941 |
+
"#636efa",
|
942 |
+
"#EF553B",
|
943 |
+
"#00cc96",
|
944 |
+
"#ab63fa",
|
945 |
+
"#FFA15A",
|
946 |
+
"#19d3f3",
|
947 |
+
"#FF6692",
|
948 |
+
"#B6E880",
|
949 |
+
"#FF97FF",
|
950 |
+
"#FECB52"
|
951 |
+
],
|
952 |
+
"font": {
|
953 |
+
"color": "#2a3f5f"
|
954 |
+
},
|
955 |
+
"geo": {
|
956 |
+
"bgcolor": "white",
|
957 |
+
"lakecolor": "white",
|
958 |
+
"landcolor": "#E5ECF6",
|
959 |
+
"showlakes": true,
|
960 |
+
"showland": true,
|
961 |
+
"subunitcolor": "white"
|
962 |
+
},
|
963 |
+
"hoverlabel": {
|
964 |
+
"align": "left"
|
965 |
+
},
|
966 |
+
"hovermode": "closest",
|
967 |
+
"mapbox": {
|
968 |
+
"style": "light"
|
969 |
+
},
|
970 |
+
"paper_bgcolor": "white",
|
971 |
+
"plot_bgcolor": "#E5ECF6",
|
972 |
+
"polar": {
|
973 |
+
"angularaxis": {
|
974 |
+
"gridcolor": "white",
|
975 |
+
"linecolor": "white",
|
976 |
+
"ticks": ""
|
977 |
+
},
|
978 |
+
"bgcolor": "#E5ECF6",
|
979 |
+
"radialaxis": {
|
980 |
+
"gridcolor": "white",
|
981 |
+
"linecolor": "white",
|
982 |
+
"ticks": ""
|
983 |
+
}
|
984 |
+
},
|
985 |
+
"scene": {
|
986 |
+
"xaxis": {
|
987 |
+
"backgroundcolor": "#E5ECF6",
|
988 |
+
"gridcolor": "white",
|
989 |
+
"gridwidth": 2,
|
990 |
+
"linecolor": "white",
|
991 |
+
"showbackground": true,
|
992 |
+
"ticks": "",
|
993 |
+
"zerolinecolor": "white"
|
994 |
+
},
|
995 |
+
"yaxis": {
|
996 |
+
"backgroundcolor": "#E5ECF6",
|
997 |
+
"gridcolor": "white",
|
998 |
+
"gridwidth": 2,
|
999 |
+
"linecolor": "white",
|
1000 |
+
"showbackground": true,
|
1001 |
+
"ticks": "",
|
1002 |
+
"zerolinecolor": "white"
|
1003 |
+
},
|
1004 |
+
"zaxis": {
|
1005 |
+
"backgroundcolor": "#E5ECF6",
|
1006 |
+
"gridcolor": "white",
|
1007 |
+
"gridwidth": 2,
|
1008 |
+
"linecolor": "white",
|
1009 |
+
"showbackground": true,
|
1010 |
+
"ticks": "",
|
1011 |
+
"zerolinecolor": "white"
|
1012 |
+
}
|
1013 |
+
},
|
1014 |
+
"shapedefaults": {
|
1015 |
+
"line": {
|
1016 |
+
"color": "#2a3f5f"
|
1017 |
+
}
|
1018 |
+
},
|
1019 |
+
"ternary": {
|
1020 |
+
"aaxis": {
|
1021 |
+
"gridcolor": "white",
|
1022 |
+
"linecolor": "white",
|
1023 |
+
"ticks": ""
|
1024 |
+
},
|
1025 |
+
"baxis": {
|
1026 |
+
"gridcolor": "white",
|
1027 |
+
"linecolor": "white",
|
1028 |
+
"ticks": ""
|
1029 |
+
},
|
1030 |
+
"bgcolor": "#E5ECF6",
|
1031 |
+
"caxis": {
|
1032 |
+
"gridcolor": "white",
|
1033 |
+
"linecolor": "white",
|
1034 |
+
"ticks": ""
|
1035 |
+
}
|
1036 |
+
},
|
1037 |
+
"title": {
|
1038 |
+
"x": 0.05
|
1039 |
+
},
|
1040 |
+
"xaxis": {
|
1041 |
+
"automargin": true,
|
1042 |
+
"gridcolor": "white",
|
1043 |
+
"linecolor": "white",
|
1044 |
+
"ticks": "",
|
1045 |
+
"title": {
|
1046 |
+
"standoff": 15
|
1047 |
+
},
|
1048 |
+
"zerolinecolor": "white",
|
1049 |
+
"zerolinewidth": 2
|
1050 |
+
},
|
1051 |
+
"yaxis": {
|
1052 |
+
"automargin": true,
|
1053 |
+
"gridcolor": "white",
|
1054 |
+
"linecolor": "white",
|
1055 |
+
"ticks": "",
|
1056 |
+
"title": {
|
1057 |
+
"standoff": 15
|
1058 |
+
},
|
1059 |
+
"zerolinecolor": "white",
|
1060 |
+
"zerolinewidth": 2
|
1061 |
+
}
|
1062 |
+
}
|
1063 |
+
},
|
1064 |
+
"xaxis": {
|
1065 |
+
"anchor": "y",
|
1066 |
+
"domain": [
|
1067 |
+
0,
|
1068 |
+
1
|
1069 |
+
],
|
1070 |
+
"title": {
|
1071 |
+
"text": "dates_transcription"
|
1072 |
+
}
|
1073 |
+
},
|
1074 |
+
"yaxis": {
|
1075 |
+
"anchor": "x",
|
1076 |
+
"domain": [
|
1077 |
+
0,
|
1078 |
+
1
|
1079 |
+
],
|
1080 |
+
"title": {
|
1081 |
+
"text": "durees_audio_sec"
|
1082 |
+
}
|
1083 |
+
}
|
1084 |
+
}
|
1085 |
+
}
|
1086 |
+
},
|
1087 |
+
"metadata": {},
|
1088 |
+
"output_type": "display_data"
|
1089 |
+
}
|
1090 |
+
],
|
1091 |
+
"source": [
|
1092 |
+
"# Tracer X en fonction de Y en utilisant Plotly\n",
|
1093 |
+
"#df_user[\"durees_audio_sec\"] = df_user[\"durees_audio_sec\"]/3600\n",
|
1094 |
+
"a =df_user[(df_user[\"usernames\"] == \"18202e69-afba-430b-a7f2-cf33c0a173b5\") & (df_user[\"Year_Month\"] == \"2023_06\")]\n",
|
1095 |
+
"fig = px.line(a, x='dates_transcription', y='durees_audio_sec')\n",
|
1096 |
+
"\n",
|
1097 |
+
"# Ajouter la limite de temps\n",
|
1098 |
+
"fig.add_shape(type=\"line\",\n",
|
1099 |
+
" x0=fig['data'][0]['x'][0],\n",
|
1100 |
+
" x1=fig['data'][0]['x'][-1],\n",
|
1101 |
+
" y0=72000,\n",
|
1102 |
+
" y1=72000,\n",
|
1103 |
+
" line=dict(color='red', width=2, dash='dash'))\n",
|
1104 |
+
"\n",
|
1105 |
+
"fig.add_annotation(x=fig['data'][0]['x'][-1],\n",
|
1106 |
+
" y=72000,\n",
|
1107 |
+
" text=\"SEUIL DE 20H = 72000 secondes\",\n",
|
1108 |
+
" showarrow=False,\n",
|
1109 |
+
" font=dict(color=\"red\"),\n",
|
1110 |
+
" xshift=-40, # Shift the label to the left\n",
|
1111 |
+
" yshift=20) # Shift the label downwards\n",
|
1112 |
+
"# Afficher la figure interactive\n",
|
1113 |
+
"fig.show()"
|
1114 |
+
]
|
1115 |
+
},
|
1116 |
+
{
|
1117 |
+
"cell_type": "code",
|
1118 |
+
"execution_count": 5,
|
1119 |
+
"metadata": {},
|
1120 |
+
"outputs": [
|
1121 |
+
{
|
1122 |
+
"data": {
|
1123 |
+
"text/plain": [
|
1124 |
+
"402.6684736394558"
|
1125 |
+
]
|
1126 |
+
},
|
1127 |
+
"execution_count": 5,
|
1128 |
+
"metadata": {},
|
1129 |
+
"output_type": "execute_result"
|
1130 |
+
}
|
1131 |
+
],
|
1132 |
+
"source": [
|
1133 |
+
"a[\"durees_audio_sec\"].sum()"
|
1134 |
+
]
|
1135 |
+
},
|
1136 |
+
{
|
1137 |
+
"cell_type": "code",
|
1138 |
+
"execution_count": 8,
|
1139 |
+
"metadata": {},
|
1140 |
+
"outputs": [
|
1141 |
+
{
|
1142 |
+
"data": {
|
1143 |
+
"text/plain": [
|
1144 |
+
"72000"
|
1145 |
+
]
|
1146 |
+
},
|
1147 |
+
"execution_count": 8,
|
1148 |
+
"metadata": {},
|
1149 |
+
"output_type": "execute_result"
|
1150 |
+
}
|
1151 |
+
],
|
1152 |
+
"source": [
|
1153 |
+
"3600 *20"
|
1154 |
+
]
|
1155 |
+
},
|
1156 |
+
{
|
1157 |
+
"cell_type": "code",
|
1158 |
+
"execution_count": 6,
|
1159 |
+
"metadata": {},
|
1160 |
+
"outputs": [
|
1161 |
+
{
|
1162 |
+
"name": "stdout",
|
1163 |
+
"output_type": "stream",
|
1164 |
+
"text": [
|
1165 |
+
"2023-06-14 13:59:03.140847\n"
|
1166 |
+
]
|
1167 |
+
}
|
1168 |
+
],
|
1169 |
+
"source": [
|
1170 |
+
"from datetime import datetime\n",
|
1171 |
+
"\n",
|
1172 |
+
"date_string = \"2023-06-14 13:59:03.140847\"\n",
|
1173 |
+
"format = \"%Y-%m-%d %H:%M:%S.%f\"\n",
|
1174 |
+
"\n",
|
1175 |
+
"datetime_obj = datetime.strptime(date_string, format)\n",
|
1176 |
+
"print(datetime_obj)\n"
|
1177 |
+
]
|
1178 |
+
},
|
1179 |
+
{
|
1180 |
+
"cell_type": "code",
|
1181 |
+
"execution_count": 8,
|
1182 |
+
"metadata": {},
|
1183 |
+
"outputs": [
|
1184 |
+
{
|
1185 |
+
"data": {
|
1186 |
+
"text/plain": [
|
1187 |
+
"18"
|
1188 |
+
]
|
1189 |
+
},
|
1190 |
+
"execution_count": 8,
|
1191 |
+
"metadata": {},
|
1192 |
+
"output_type": "execute_result"
|
1193 |
+
}
|
1194 |
+
],
|
1195 |
+
"source": [
|
1196 |
+
"datetime_obj.month + 12"
|
1197 |
+
]
|
1198 |
+
}
|
1199 |
+
],
|
1200 |
+
"metadata": {
|
1201 |
+
"kernelspec": {
|
1202 |
+
"display_name": "whisper",
|
1203 |
+
"language": "python",
|
1204 |
+
"name": "python3"
|
1205 |
+
},
|
1206 |
+
"language_info": {
|
1207 |
+
"codemirror_mode": {
|
1208 |
+
"name": "ipython",
|
1209 |
+
"version": 3
|
1210 |
+
},
|
1211 |
+
"file_extension": ".py",
|
1212 |
+
"mimetype": "text/x-python",
|
1213 |
+
"name": "python",
|
1214 |
+
"nbconvert_exporter": "python",
|
1215 |
+
"pygments_lexer": "ipython3",
|
1216 |
+
"version": "3.9.16"
|
1217 |
+
},
|
1218 |
+
"orig_nbformat": 4
|
1219 |
+
},
|
1220 |
+
"nbformat": 4,
|
1221 |
+
"nbformat_minor": 2
|
1222 |
+
}
|
users_info.json
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"18202e69-afba-430b-a7f2-cf33c0a173b5": {
|
3 |
+
"email": "[email protected]",
|
4 |
+
"durees_audio_sec": [
|
5 |
+
56.75331065759637,
|
6 |
+
56.75331065759637,
|
7 |
+
56.75331065759637,
|
8 |
+
232.40854166666668,
|
9 |
+
56.75331065759637,
|
10 |
+
56.75331065759637
|
11 |
+
],
|
12 |
+
"date_inscription": "2023-06-14 13:59:03.140847",
|
13 |
+
"dates_transcription": [
|
14 |
+
"2023-06-14 13:59:03.140847",
|
15 |
+
"2023-06-14 14:01:42.171527",
|
16 |
+
"2023-06-14 14:03:44.971361",
|
17 |
+
"2023-06-15 00:10:08.233341",
|
18 |
+
"2023-06-15 01:01:04.821023",
|
19 |
+
"2023-06-15 01:03:01.867620"
|
20 |
+
],
|
21 |
+
"abonnement": 1
|
22 |
+
},
|
23 |
+
"401507b3-9030-4690-969b-524b37ba5bc9": {
|
24 |
+
"email": "[email protected]",
|
25 |
+
"durees_audio_sec": [
|
26 |
+
56.75331065759637
|
27 |
+
],
|
28 |
+
"date_inscription": "2023-06-14 14:05:49.398837",
|
29 |
+
"dates_transcription": [
|
30 |
+
"2023-06-14 14:05:49.398837"
|
31 |
+
],
|
32 |
+
"abonnement": 1
|
33 |
+
},
|
34 |
+
"10425ed8-fb31-4d5b-b419-e09e3eed17cc": {
|
35 |
+
"email": "[email protected]",
|
36 |
+
"durees_audio_sec": [
|
37 |
+
0,
|
38 |
+
56.75331065759637,
|
39 |
+
56.75331065759637,
|
40 |
+
56.75331065759637,
|
41 |
+
56.75331065759637
|
42 |
+
],
|
43 |
+
"date_inscription": "2023-06-16 14:36:11.076300",
|
44 |
+
"dates_transcription": [
|
45 |
+
"2023-06-16 14:36:11.076300",
|
46 |
+
"2023-06-16 14:36:11.076300",
|
47 |
+
"2023-06-16 15:22:43.918257",
|
48 |
+
"2023-06-24 19:05:36.730951",
|
49 |
+
"2023-06-25 15:02:43.520520"
|
50 |
+
],
|
51 |
+
"abonnement": 1
|
52 |
+
},
|
53 |
+
"39c7ad13-9e92-4e9a-af24-9ecb26e4f487": {
|
54 |
+
"email": "[email protected]",
|
55 |
+
"durees_audio_sec": [
|
56 |
+
0,
|
57 |
+
56.75331065759637
|
58 |
+
],
|
59 |
+
"date_inscription": "2023-06-25 15:14:38.401039",
|
60 |
+
"dates_transcription": [
|
61 |
+
"2023-06-25 15:14:38.401039",
|
62 |
+
"2023-06-25 15:14:38.401039"
|
63 |
+
],
|
64 |
+
"abonnement": 1
|
65 |
+
},
|
66 |
+
"25a3587c-3dcb-4605-a7df-76cbfcda555d": {
|
67 |
+
"email": "[email protected]",
|
68 |
+
"durees_audio_sec": [
|
69 |
+
0,
|
70 |
+
56.75331065759637
|
71 |
+
],
|
72 |
+
"date_inscription": "2023-06-25 15:32:54.315302",
|
73 |
+
"dates_transcription": [
|
74 |
+
"2023-06-25 15:32:54.315302",
|
75 |
+
"2023-06-25 15:32:54.315302"
|
76 |
+
],
|
77 |
+
"abonnement": 1
|
78 |
+
}
|
79 |
+
}
|