-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
118 lines (107 loc) · 3.59 KB
/
test.py
File metadata and controls
118 lines (107 loc) · 3.59 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import tts
import stt
import readDoc
import writeD
import json
import os
import time
from VoiceIt import *
def reading():
tts.textToSpeech("Speak the File Name after the beep").say()
time.sleep(0.5)
os.system("echo '\a'")
time.sleep(0.2)
stt.SpeechToText('~/Desktop/major/sound/filename.wav').record(3)
os.system("echo '\a'")
file_name = stt.SpeechToText('~/Desktop/major/sound/filename.wav').speech_to_text().replace(" ", "")
file_name = file_name+".docx"
print(file_name)
if len(readDoc.readFile(file_name).find_all("~/Desktop/major/documents"))<=0:
print("No such file found")
tts.textToSpeech("No File Found").say()
else:
doc_data = readDoc.readFile("~/Desktop/major/documents/"+file_name).read()
print(doc_data)
tts.textToSpeech(doc_data).say()
def writing():
#writeDoc object
wr = writeD.writeDoc()
#taking the title
tts.textToSpeech("Speak the title of the document").say()
time.sleep(0.5)
os.system("echo '\a'")
time.sleep(0.2)
stt.SpeechToText('~/Desktop/major/sound/docTitle.wav').record(5)
os.system("echo '\a'")
doc_title = stt.SpeechToText('~/Desktop/major/sound/docTitle.wav').speech_to_text()
paragraph = []
#taking the first paragraph
while True:
tts.textToSpeech("Speak the Paragraph").say()
time.sleep(0.5)
os.system("echo '\a'")
time.sleep(0.2)
stt.SpeechToText('~/Desktop/major/sound/docPara.wav').record(15)
os.system("echo '\a'")
file_para = stt.SpeechToText('~/Desktop/major/sound/docPara.wav').speech_to_text()
paragraph.append(file_para)
tts.textToSpeech("Do you want add more content").say()
time.sleep(0.2)
os.system("echo '\a'")
time.sleep(0.2)
stt.SpeechToText('~/Desktop/major/sound/res.wav').record(3)
os.system("echo '\a'")
res=stt.SpeechToText('~/Desktop/major/sound/res.wav').speech_to_text()
if res=="no":
break
time.sleep(0.2)
tts.textToSpeech("What would you like to name the file").say()
time.sleep(0.5)
os.system("echo '\a'")
time.sleep(0.2)
stt.SpeechToText('~/Desktop/major/sound/docName.wav').record(4)
os.system("echo '\a'")
file_Name = stt.SpeechToText('~/Desktop/major/sound/docName.wav').speech_to_text().replace(" ", "")
file_Name=file_Name+".docx"
wr.addHeading(doc_title)
for p in paragraph:
print(p)
wr.addParagraph(p)
wr.saveDoc("~/Desktop/major/documents/"+file_Name)
tts.textToSpeech("Document saved sucessfully").say()
def browse():
return "Something 1"
from calci import calculator
def calc():
c=calculator()
c.evaluate()
#calci.calculator.evaluate();
def plmusic():
return "playing music"
switcher = {
"read file":reading,
"write file":writing,
"browse internet":browse,
"calculate":calc,
"play music":plmusic
}
def perform_command(argument):
func = switcher.get(argument, "Invalid Command")
if(func != "Invalid Command"):
return func()
else:
tts.textToSpeech("Invalid Command").say()
#print(perform_command("read document"))
while True:
key_press = raw_input()
if key_press == "":
print("You pressed enter")
os.system("echo '\a'")
time.sleep(0.2)
stt.SpeechToText('./sound/command.wav').record(3)
cmd = stt.SpeechToText('./sound/command.wav').speech_to_text()
print(cmd)
perform_command(cmd)
else:
print("Something went Wront Try Again")
tts.textToSpeech("Something went Wrong. Try Again").say()