sdfd
parent
e2073f02cd
commit
0fe5c2a58e
|
@ -1,11 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="25/12/2024 - 22h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="sdf">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/attached_file_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/attached_file_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tools_cherif/mysy_openai_file.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/mysy_openai_file.py" afterDir="false" />
|
||||
</list>
|
||||
|
@ -78,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00373" summary="17/08/2024 - 20h55">
|
||||
<created>1723920962711</created>
|
||||
<option name="number" value="00373" />
|
||||
<option name="presentableId" value="LOCAL-00373" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1723920962711</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00374" summary="18/08/2024 - 16h55">
|
||||
<created>1724077502402</created>
|
||||
<option name="number" value="00374" />
|
||||
|
@ -421,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1735161926243</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="422" />
|
||||
<task id="LOCAL-00422" summary="sdf">
|
||||
<created>1735475357282</created>
|
||||
<option name="number" value="00422" />
|
||||
<option name="presentableId" value="LOCAL-00422" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1735475357282</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="423" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -463,7 +462,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="18/09/2024 - 21h" />
|
||||
<MESSAGE value="19/09/2024 - 20h" />
|
||||
<MESSAGE value="23/09/2024 - 17h" />
|
||||
<MESSAGE value="25/09/2024 - 15h" />
|
||||
|
@ -488,6 +486,7 @@
|
|||
<MESSAGE value="24/12/2024 - 22h" />
|
||||
<MESSAGE value="25/12/2024 - 14h" />
|
||||
<MESSAGE value="25/12/2024 - 22h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="25/12/2024 - 22h30" />
|
||||
<MESSAGE value="sdf" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="sdf" />
|
||||
</component>
|
||||
</project>
|
|
@ -830,4 +830,15 @@ mysy_voice_instruction_collection_action = {
|
|||
Cette variable defini ou les messages vocaux utilisés par le système
|
||||
sont stocké
|
||||
"""
|
||||
SYSTEM_VOICE_MESSAGES_LOCATION = "./admin_voices_messages/"
|
||||
SYSTEM_VOICE_MESSAGES_LOCATION = "./admin_voices_messages/"
|
||||
|
||||
|
||||
"""
|
||||
Confirmation d'un ordre de vocal
|
||||
"""
|
||||
VOICE_INSTRUCTION_CONFIRMATION = ["confirme", "confimer", "conformation"]
|
||||
|
||||
"""
|
||||
Annulation d'un ordre de vocal
|
||||
"""
|
||||
VOICE_INSTRUCTION_ANNULATION = ["annuler", "annulle", "refus", "refuser"]
|
2093
Log/log_file.log
2093
Log/log_file.log
File diff suppressed because it is too large
Load Diff
20
main.py
20
main.py
|
@ -11473,6 +11473,7 @@ def mysy_openai_get_voice_file():
|
|||
|
||||
new_payload = {}
|
||||
new_payload['voice_file'] = "temp_direct/test_audio_pr_IA.mp3"
|
||||
new_payload['token'] = payload['token']
|
||||
status, retval, collection_instruction_id = mysy_openai_file.mysy_openai_voice_to_text(new_payload)
|
||||
|
||||
"""
|
||||
|
@ -11512,15 +11513,21 @@ def mysy_openai_confirme_voice_instruction_api():
|
|||
f.filename = "confirmation_test_audio_pr_IA.mp3"
|
||||
f.save(os.path.join(str("./temp_direct/confirmation_test_audio_pr_IA.mp3")))
|
||||
|
||||
repeat_instruction = "0"
|
||||
|
||||
new_payload = {}
|
||||
new_payload['voice_file'] = "temp_direct/confirmation_test_audio_pr_IA.mp3"
|
||||
new_payload['token'] = payload['token']
|
||||
new_payload['instruction_id'] = payload['instruction_id']
|
||||
status, retval = mysy_openai_file.mysy_openai_confirme_voice_instruction(new_payload)
|
||||
status, retval, repeat = mysy_openai_file.mysy_openai_confirme_voice_instruction(new_payload)
|
||||
if(status is False ):
|
||||
return
|
||||
|
||||
# SI on a bien compris l'instruction, on demande à repeter, ceci sans annuler l'instruction en cours
|
||||
repeat_instruction = repeat
|
||||
collection_instruction_id = str(payload['instruction_id'])
|
||||
audio_file_name = retval
|
||||
|
||||
local_instruction_id = ""
|
||||
|
||||
|
||||
print(" ### audio_file_name = ", retval)
|
||||
|
@ -11538,10 +11545,13 @@ def mysy_openai_confirme_voice_instruction_api():
|
|||
|
||||
print(" ### new_diction = ", new_diction)
|
||||
|
||||
status, message = mysy_openai_file.mysy_openai_get_voice_file(new_diction)
|
||||
return jsonify(status=status, message=message, collection_instruction_id="")
|
||||
if(repeat_instruction == "1"):
|
||||
local_instruction_id = str(payload['instruction_id'])
|
||||
|
||||
return jsonify(status=False, message="Impossible de traiter le fichier audio", collection_instruction_id = False)
|
||||
status, message = mysy_openai_file.mysy_openai_get_voice_file(new_diction)
|
||||
return jsonify(status=status, message=message, collection_instruction_id= str(local_instruction_id), repeat_instruction = str(repeat_instruction))
|
||||
|
||||
return jsonify(status=False, message="Impossible de traiter le fichier audio", collection_instruction_id = str(local_instruction_id), repeat_instruction = str(repeat_instruction))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
import ast
|
||||
import base64
|
||||
|
||||
import pymongo
|
||||
import zeep
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
from pymongo import ReturnDocument
|
||||
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
from flask import send_file
|
||||
import csv
|
||||
import pandas as pd
|
||||
from pymongo import ReturnDocument
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
|
||||
from validate_email import validate_email
|
||||
import jinja2
|
||||
import Ela_Spacy as ela_Spacy
|
||||
|
||||
import class_mgt as class_mgt
|
||||
|
||||
|
@ -168,10 +157,14 @@ def mysy_openai_instruction_collection_confirmation_texte(diction):
|
|||
|
||||
|
||||
"""
|
||||
Cette fonction prend un fichier audio et le converti en fichier texte
|
||||
Cette fonction prend un fichier audio et le converti en fichier texte.
|
||||
cette fonctio prend comme argument :
|
||||
- voice_text
|
||||
- token
|
||||
"""
|
||||
def mysy_openai_voice_to_text(diction):
|
||||
try:
|
||||
|
||||
file_name = "temp_direct/mysy_test_voice_mp3.mp3"
|
||||
if( "voice_file" in diction.keys() and diction['voice_file'] ):
|
||||
file_name = diction['voice_file']
|
||||
|
@ -191,7 +184,12 @@ def mysy_openai_voice_to_text(diction):
|
|||
|
||||
print(requestion_response)
|
||||
|
||||
status, retval, collection_instruction_id = mysy_openai_voice_to_text_traitement_1(requestion_response)
|
||||
new_diction = {}
|
||||
new_diction['voice_text'] = str(requestion_response)
|
||||
new_diction['token'] = str(diction['token'])
|
||||
|
||||
|
||||
status, retval, collection_instruction_id = mysy_openai_voice_to_text_traitement_1(new_diction)
|
||||
|
||||
return True, requestion_response, collection_instruction_id
|
||||
|
||||
|
@ -334,8 +332,14 @@ Cette fonction prend une phrase et fait un decoupage comme suit :
|
|||
"""
|
||||
|
||||
tab_order_mysy = ['ok, missi', 'ok missi', 'ok; missi','ok, missy', 'ok mysy']
|
||||
def mysy_openai_voice_to_text_traitement_1(voice_text):
|
||||
def mysy_openai_voice_to_text_traitement_1(diction):
|
||||
try:
|
||||
voice_text = diction['voice_text']
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data({'token': diction['token']})
|
||||
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
print(" ### Texte initial = ", str(voice_text).strip().lower())
|
||||
voice_text_work = str(voice_text).strip().lower()
|
||||
|
||||
|
@ -346,7 +350,7 @@ def mysy_openai_voice_to_text_traitement_1(voice_text):
|
|||
|
||||
new_diction = {}
|
||||
new_diction['text'] = str(voice_text_work)
|
||||
new_diction['partner_owner_recid'] = "partner_owner_recid"
|
||||
new_diction['partner_owner_recid'] = str(my_partner['recid'])
|
||||
new_diction['related_object'] = "myclass"
|
||||
new_diction['related_collection_recid'] = "dqsqddd0ed"
|
||||
|
||||
|
@ -606,7 +610,12 @@ def mysy_openai_assistant(diction):
|
|||
|
||||
|
||||
"""
|
||||
Cette fonction prend l'_id d'une instruction en cours et effectue le traitement
|
||||
Cette fonction prend l'_id d'une instruction, un fichier audi.
|
||||
|
||||
Si l'audit confirme l'instruction, alors l'instruction est traitée.
|
||||
si l'audit annule l'instruction, alors on annule l'instruction.
|
||||
|
||||
|
||||
"""
|
||||
def mysy_openai_confirme_voice_instruction(diction):
|
||||
try:
|
||||
|
@ -635,6 +644,12 @@ def mysy_openai_confirme_voice_instruction(diction):
|
|||
#return False, " Impossible de récupérer les informations"
|
||||
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
voice_erreur_text = "Erreur technique 4 : Instruction invalide "
|
||||
return False, voice_erreur_text, False
|
||||
|
||||
|
||||
file_name = ""
|
||||
if( "voice_file" in diction.keys() and diction['voice_file'] ):
|
||||
file_name = diction['voice_file']
|
||||
|
@ -642,7 +657,86 @@ def mysy_openai_confirme_voice_instruction(diction):
|
|||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Aucune instruction à traiter. Processus annulé. ")
|
||||
voice_erreur_text = "Erreur technique 3 : Instruction invalide "
|
||||
return False, " Aucune instruction à traiter. Processus annulé. "
|
||||
return False, " Aucune instruction à traiter. Processus annulé. ", False
|
||||
|
||||
"""
|
||||
Verifier si l'instruction a été confirmée par le fichier audio
|
||||
"""
|
||||
audio_file = open(file_name, "rb")
|
||||
transcription = client.audio.transcriptions.create(
|
||||
model="whisper-1",
|
||||
file=audio_file,
|
||||
# response_format = "text"
|
||||
)
|
||||
|
||||
requestion_response = transcription.text
|
||||
print(" ### mysy_openai_confirme_voice_instruction message de confirmtion = ", requestion_response)
|
||||
|
||||
status, tab_tokens = ela_Spacy.Ela_Tokenize(requestion_response)
|
||||
if (status is False):
|
||||
voice_erreur_text = " Je n'ai pas compris votre message."
|
||||
repeat = "1"
|
||||
return True, voice_erreur_text, repeat
|
||||
|
||||
local_status, tab_retval = ela_Spacy.Ela_remove_stop_words(tab_tokens)
|
||||
print(" ### mysy_openai_confirme_voice_instruction tab_retval= ", tab_retval)
|
||||
|
||||
confirmation_annulation_action = ""
|
||||
confirmation_annulation_action_value = ""
|
||||
# Verifier d'abord si c'est une annulation
|
||||
for voice_message_token in tab_retval:
|
||||
for confirmation_mot in MYSY_GV.VOICE_INSTRUCTION_ANNULATION :
|
||||
cmp_levenshtein = int(mycommon.levenshtein(voice_message_token, str(confirmation_mot)))
|
||||
if( cmp_levenshtein < 2 ):
|
||||
print(" ### Le message orale est 11 : ", str(confirmation_mot))
|
||||
confirmation_annulation_action = str(confirmation_mot)
|
||||
confirmation_annulation_action_value = "0"
|
||||
continue
|
||||
|
||||
# Puis verifier si c'est un message de confirmation pour exécuter l'instruction
|
||||
for voice_message_token in tab_retval:
|
||||
for confirmation_mot in MYSY_GV.VOICE_INSTRUCTION_CONFIRMATION:
|
||||
cmp_levenshtein = int(mycommon.levenshtein(voice_message_token, str(confirmation_mot)))
|
||||
if (cmp_levenshtein < 2):
|
||||
print(" ### Le message orale est 22 : ", str(confirmation_mot))
|
||||
confirmation_annulation_action = str(confirmation_mot)
|
||||
confirmation_annulation_action_value = "1"
|
||||
continue
|
||||
|
||||
print(" ### ACTION A REALISER EST : ", confirmation_annulation_action)
|
||||
|
||||
if( confirmation_annulation_action_value == "0" ):
|
||||
# Il faut annuler l'instruction
|
||||
after_intruction_text = " L'instruction a été annulée"
|
||||
new_data = {}
|
||||
new_data['valide'] = '0'
|
||||
new_data['locked'] = '0'
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
|
||||
result = MYSY_GV.dbname['voice_instruction'].find_one_and_update(
|
||||
{'_id': ObjectId(str(diction['instruction_id'])),
|
||||
'valide': '1', 'locked': '0'},
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
local_status, outpufile_name = mysy_openai_text_to_voice({'text': str(after_intruction_text)})
|
||||
print(" le fichier audio de confirmation est : ", outpufile_name)
|
||||
return True, outpufile_name, "0"
|
||||
|
||||
|
||||
|
||||
|
||||
elif( confirmation_annulation_action_value == ""):
|
||||
# Impossible de comprendre le message
|
||||
after_intruction_text = " Je n'ai pas compris l'instruction. merci de répéter "
|
||||
local_status, outpufile_name = mysy_openai_text_to_voice({'text': str(after_intruction_text)})
|
||||
print(" le fichier audio de confirmation est : ", outpufile_name)
|
||||
repeat = "1"
|
||||
return True, outpufile_name, repeat
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
@ -658,7 +752,7 @@ def mysy_openai_confirme_voice_instruction(diction):
|
|||
|
||||
|
||||
if( voice_erreur_text and len(str(voice_erreur_text)) > 5):
|
||||
return False, voice_erreur_text
|
||||
return False, voice_erreur_text, "0"
|
||||
|
||||
|
||||
audio_file = open(file_name, "rb")
|
||||
|
@ -694,14 +788,14 @@ def mysy_openai_confirme_voice_instruction(diction):
|
|||
print(" le fichier audio de confirmation est : ", outpufile_name)
|
||||
|
||||
|
||||
return True, outpufile_name
|
||||
return True, outpufile_name, "0"
|
||||
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de traiter : mysy_openai_voice_to_text"
|
||||
return False, " Impossible de traiter : mysy_openai_voice_to_text", "0"
|
||||
|
||||
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue