-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJarvis.py
More file actions
87 lines (68 loc) · 2.45 KB
/
Jarvis.py
File metadata and controls
87 lines (68 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import pyttsx3
import speech_recognition as sr
from playsound import playsound
import threading
import time
r = sr.Recognizer()
def SpeakText(command) :
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[2].id)
engine.setProperty('rate', 150)
engine.say(command)
engine.runAndWait()
#Récuperation de la voix :
def record_text():
while(1):
try:
with sr.Microphone() as source2 :
r.adjust_for_ambient_noise(source2, duration=0.2)
print("I'm listening")
audio2 = r.listen(source2)
MyText = r.recognize_google(audio2)
return MyText
except sr.RequestError as e :
print("Could not request results; {0}".format(e))
except sr.UnknownValueError:
print("unknown error occured")
def fake_loading(message, duration):
progress_symbols = "⭐️"
progress_bar_length = 10
print(message + " [", end="")
for _ in range(progress_bar_length):
print(progress_symbols, end="", flush=True)
time.sleep(duration / progress_bar_length)
print("] Done")
def playintro(sound):
playsound(sound)
def send_ollama():
print("coucou")
def main():
speak_thread = threading.Thread(target=playintro, args=("Boot.mp3",))
loading_thread = threading.Thread(target=fake_loading, args=("BOOT of ARC REACTOR Process", 15))
# Démarre les threads
speak_thread.start()
loading_thread.start()
# Attends que les threads se terminent avant de continuer
speak_thread.join()
loading_thread.join()
SpeakText("Jarvis is now initialized and ready to assist you.")
while(1):
response = record_text()
if "goodbye" in response :
# Crée deux threads pour exécuter les deux fonctions en parallèle
speak_thread = threading.Thread(target=SpeakText, args=("Goodbye my lord",))
loading_thread = threading.Thread(target=fake_loading, args=("Unloading the ARC REACTOR Process", 2))
# Démarre les threads
speak_thread.start()
loading_thread.start()
# Attends que les threads se terminent avant de continuer
speak_thread.join()
loading_thread.join()
playsound('Repulsor.mp3')
exit()
else :
print(response)
SpeakText(response)
if __name__ == "__main__":
main()