File tree 2 files changed +19
-5
lines changed
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 5
5
import apiai
6
6
import local_settings
7
7
from time import gmtime , strftime
8
-
8
+ import speech_recognition as sr
9
9
10
10
CLIENT_ACCESS_TOKEN = local_settings .CLIENT_ACCESS_TOKEN
11
11
12
+ def ascolta_microfono ():
13
+ r = sr .Recognizer ()
14
+ with sr .Microphone () as source :
15
+ audio = r .listen (source )
16
+ testo = r .recognize_google (audio ,language = 'it' )
17
+ print (testo )
18
+ return testo
19
+
12
20
def ascolta_tastiera ():
13
21
ascolto = input ('Enter your input:' )
14
22
return ascolto
@@ -40,7 +48,11 @@ def elabora(richiesta):
40
48
def parla (testo ):
41
49
os .system ("say " + testo )
42
50
43
-
44
- ascolto = ascolta_tastiera ()
45
- risponde = elabora (ascolto )
46
- parla (risponde )
51
+ ascolto = ''
52
+ while (ascolto != 'Addio' ):
53
+ ascolto = ascolta_microfono ()
54
+ if (ascolto != 'Addio' ) :
55
+ risponde = elabora (ascolto )
56
+ else :
57
+ risponde = 'alla prossima'
58
+ parla (risponde )
Original file line number Diff line number Diff line change 1
1
requests
2
+ pyaudio
3
+ SpeechRecognition
You can’t perform that action at this time.
0 commit comments