-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeech_trial.py
55 lines (38 loc) · 1.1 KB
/
speech_trial.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
50
51
52
53
54
55
import analyze as az
#import speech_trial as stt
from gtts import gTTS
import speech_recognition as sr
import os
import re
import webbrowser
import smtplib
import requests
'''import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()'''
def myCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Ready...')
r.pause_threshold = 1
r.adjust_for_ambient_noise(source, duration=1)
audio = r.listen(source)
try:
command = r.recognize_google(audio).lower()
print('You said: ' + command + '\n')
except sr.UnknownValueError:
print('Your last command couldn\'t be heard')
command = myCommand()
return command
def get_text():
text = myCommand()
SUBSCRIPTION_KEY_ENV_NAME = "e0a4ec68847644849409dce0a433d785"
# text = stt.rec()
#text = 'can someone pass the dissection sissors?'
print(text)
keys = az.key_phrases(SUBSCRIPTION_KEY_ENV_NAME,text)
ent = az.entity_extraction(SUBSCRIPTION_KEY_ENV_NAME,text)
print(keys)
return [keys,ent]
get_text()