-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·49 lines (41 loc) · 1.22 KB
/
main.py
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
#!/usr/bin/env python3
from os import remove
from header import welcome, settings
from speech_to_text import speech_to_text
from ollama import chat
say_hello = {
"en": "Welcomes all students for the ceremony.",
"fr": "Souhaite la bienvenue pour la cérémonie."
}
def main():
try:
model, language, students = settings()
except TypeError:
return
messages = []
messages.append({"role": "asssistant", "content": say_hello[language]})
message = chat(messages)
messages.append(message)
print("\nHYPPCHOIPUS: {}".format(message["content"]))
while students > 0:
user_input = speech_to_text(model, language)
if not user_input:
exit()
print()
messages.append({"role": "user", "content": user_input})
message = chat(messages)
print("\nHYPPCHOIPUS: {}".format(message["content"]))
messages.append(message)
students -= 1
if __name__ == "__main__":
try:
welcome()
main()
except (KeyboardInterrupt, EOFError):
print("\nProgram terminated by user")
finally:
print("Cleaning up...")
try:
remove("audio.wav")
except FileNotFoundError:
pass