-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeak.py
47 lines (44 loc) · 1.09 KB
/
speak.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
import pyttsx3
from threading import Thread
from dotenv import dotenv_values,load_dotenv
import time
local = 'fr'
if(load_dotenv()):
env = dotenv_values('.env')
local = env['LOCAL']
# configuration pyttsx3
engine=pyttsx3.init()
# VOLUME
volume=engine.getProperty('volume')
# print(volume)
engine.setProperty('volume',1.0)
# VITESSE
vitesse=engine.getProperty('rate')
# print(vitesse)
engine.setProperty('rate',180)
# VOIX
if(local=='fr'):
voice=0
elif(local=='en'):
voice=1
voix=engine.getProperty('voices')
engine.setProperty('voice',voix[voice].id)
# Fonction parler
def parler(text):
engine.say(text)
engine.runAndWait()
engine.stop()
print('initialisation ...')
time.sleep(2)
print('initialisation terminée ...')
while True:
fichier=open("static/data/objets.txt","r")
detection=fichier.read()
if (detection!=''):
if(detection=='rien'):
parler('je ne detecte aucune objets')
else:
parler('je vois environ {}'.format(detection))
fichier=open("static/data/objets.txt","w")
fichier.write('')
fichier.close