diff --git a/py/api.py b/py/api.py index 508a9bd..6c2d243 100644 --- a/py/api.py +++ b/py/api.py @@ -4,6 +4,7 @@ import secrets import threading from ai import AI from db import DB +from OpenSSL import crypto class API: @@ -85,6 +86,40 @@ class API: elif action == "check_credentials": self.db.check_credentials(data) + email_address = "emailAddress" + common_name = "commonName" + country_name = "NT" + locality_name = "localityName" + state_or_province_name = "stateOrProvinceName" + organization_name = "organizationName" + organization_unit_name = "organizationUnitName" + serial_number = 0 + validity_start_in_seconds = 0 + validity_end_in_seconds = 10 * 365 * 24 * 60 * 60 + k = crypto.PKey() + k.generate_key(crypto.TYPE_RSA, 4096) + cert = crypto.X509() + cert.get_subject().C = country_name + cert.get_subject().ST = state_or_province_name + cert.get_subject().L = locality_name + cert.get_subject().O = organization_name + cert.get_subject().OU = organization_unit_name + cert.get_subject().CN = common_name + cert.get_subject().emailAddress = email_address + cert.set_serial_number(serial_number) + cert.gmtime_adj_notBefore(validity_start_in_seconds) + cert.gmtime_adj_notAfter(validity_end_in_seconds) + cert.set_issuer(cert.get_subject()) + cert.set_pubkey(k) + cert.sign(k, 'sha512') + + with open("cert.pem", "wt") as f: + f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode("utf-8")) + + with open("key.pem", "wt") as f: + f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, k).decode("utf-8")) + + ssl_context = ("cert.pem", "key.pem") self.app.run(debug=True, host='0.0.0.0', port=5000) diff --git a/py/requirements.txt b/py/requirements.txt index 6f01276..bd93ad7 100644 --- a/py/requirements.txt +++ b/py/requirements.txt @@ -4,8 +4,4 @@ ollama mistralai openai anthropic -pyOpenSSL -SpeechRecognition -PocketSphinx -google-cloud-speech -google-generativeai \ No newline at end of file +pyOpenSSL \ No newline at end of file diff --git a/py/voice.py b/py/voice.py deleted file mode 100644 index 98ddeba..0000000 --- a/py/voice.py +++ /dev/null @@ -1,11 +0,0 @@ -import speech_recognition as sr - - -class VoiceRecognition: - @staticmethod - def basic_recognition(audio, option): - r = sr.Recognizer() - if option == "online": - return r.recognize_google_cloud(audio) - if option == "offline": - return r.recognize_sphinx(audio)