10/12/2024 - 22h

master
cherif 2024-12-10 22:10:19 +01:00
parent 1eb2cab8f7
commit 3cea719d32
5 changed files with 2834 additions and 12 deletions

View File

@ -1,10 +1,12 @@
<?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="27/11/2024 : 12h30">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="08/12/2024 - 12h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -75,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00367" summary="08/08/2024 - 20h32s">
<created>1723210885739</created>
<option name="number" value="00367" />
<option name="presentableId" value="LOCAL-00367" />
<option name="project" value="LOCAL" />
<updated>1723210885743</updated>
</task>
<task id="LOCAL-00368" summary="10/08/2024 - 20h32s">
<created>1723319219142</created>
<option name="number" value="00368" />
@ -418,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1732706635907</updated>
</task>
<option name="localTasksCounter" value="416" />
<task id="LOCAL-00416" summary="08/12/2024 - 12h">
<created>1733655942461</created>
<option name="number" value="00416" />
<option name="presentableId" value="LOCAL-00416" />
<option name="project" value="LOCAL" />
<updated>1733655942463</updated>
</task>
<option name="localTasksCounter" value="417" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -460,7 +462,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="qsh" />
<MESSAGE value="06/09/2024 - 22h" />
<MESSAGE value="08/09/2024 - 21h" />
<MESSAGE value="08/09/2024 - 21terth" />
@ -485,6 +486,7 @@
<MESSAGE value="qsd" />
<MESSAGE value="22/11/2024 - 18h" />
<MESSAGE value="27/11/2024 : 12h30" />
<option name="LAST_COMMIT_MESSAGE" value="27/11/2024 : 12h30" />
<MESSAGE value="08/12/2024 - 12h" />
<option name="LAST_COMMIT_MESSAGE" value="08/12/2024 - 12h" />
</component>
</project>

File diff suppressed because it is too large Load Diff

43
main.py
View File

@ -1,4 +1,5 @@
import atexit
import os
from flask import make_response, request, current_app, Flask, jsonify
from functools import update_wrapper
@ -11333,6 +11334,48 @@ def mysy_openai():
return jsonify(status=status, message=retval)
"""
API test mysy Open AI voice to text
"""
@app.route('/myclass/api/mysy_openai_voice_to_text/', methods=['POST','GET'])
@crossdomain(origin='*')
def mysy_openai_voice_to_text():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### mysy_openai_voice_to_text payload zzzz = ")
status, retval = mysy_openai_file.mysy_openai_voice_to_text(payload)
return jsonify(status=status, message=retval)
'''
API test recuperation fichier blob audio
'''
@app.route('/myclass/api/Get_Audio_File/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Audio_File():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### payload = ",payload)
print(request.files)
if request.method == 'POST':
# Create variable for uploaded file
f = request.files['file']
f.filename = "test_audio_pr_IA.mp3"
f.save(os.path.join(str("./temp_direct/test_audio_pr_IA.mp3")))
new_payload = {}
new_payload['voice_file'] = str(f.filename)
status, retval = mysy_openai_file.mysy_openai_voice_to_text(payload)
status= True
return jsonify(status=status)
@app.route('/myclass/api/mysy_openai_assistant/', methods=['POST','GET'])
@crossdomain(origin='*')
def mysy_openai_assistant():

View File

@ -240,7 +240,7 @@ def Upload_Save_IMG_PNG_File(file=None, Folder=None):
local_base_name = str(new_basename2).replace('(', '').replace(')', '').replace(' ', '')
new_file_name = str(local_base_name) + "_" + str(timestr) + "." + str(basename2[1])
file.filename = new_file_name
file.save(os.path.join(str(Folder), secure_filename(file.filename))) # t
file.save(os.path.join(str(Folder), secure_filename(file.filename)))
Global_file_name = str(Folder) + str(file.filename)

View File

@ -83,6 +83,37 @@ def mysy_openai(diction):
return False, " Impossible de traiter : mysy_openai"
"""
Test openai voice to text mysy
"""
def mysy_openai_voice_to_text(diction):
try:
print(" ### diction = ", diction)
file_name = "temp_direct/mysy_test_voice_mp3.mp3"
if( "voice_file" in diction.keys() and diction['voice_file'] ):
file_name = diction['voice_file']
print(" ### Traitement du fichier audio : ", file_name)
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(" ### AFFICHAGE GPT RESPONSE - mysy_openai_voice_to_text")
print(transcription.text)
return True,requestion_response
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"
def mysy_openai_assistant(diction):
try: