-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvoice-record.py
102 lines (61 loc) · 1.72 KB
/
voice-record.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
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
import sys
import os
import record
import readline
import subprocess
os.system('clear')
print "Welcome to the WordRecord"
def process_word():
os.system('clear')
fin = open( 'file', "r" )
data_list = fin.readlines()
fin.close()
print "\n"
print "\n"
word = data_list[:1][0].replace('\n','')
print word
print "\n"
print "\n"
record.record_audio(word)
print "\n"
print "\n"
confirm = raw_input("Do you confirm the recording? Y/N : ")
confirm = confirm.lower()
if confirm == 'y':
completed=open("completed_words","a")
completed.writelines(data_list)
completed.close()
del data_list[:1]
fout = open("file", "w")
fout.writelines(data_list)
fout.close()
subprocess.call(["oggenc", '-Q', word + '.wav'])
play_confirm = raw_input("\nDo you hear the recorded word: " + word + " ? Y/N : ")
play_confirm = play_confirm.lower()
if play_confirm == 'y':
print ("\nPlaying the recorded word: " + word)
os.system("ogg123 " + word + ".ogg")
elif play_confirm == 'n':
print "\nHope the word is recorded well."
#play_confirm = "n"
if confirm == 'n':
process_word()
def process_next_word():
print "\n"
print "\n"
next_word = raw_input( "Are you ready for next word? Y/N : ")
next_word = next_word.lower()
if next_word == 'y':
process_word()
process_next_word()
elif next_word == 'n':
print "Thank You"
else:
print "Please Enter Y or N"
answer = raw_input("Are you ready? Y/N : ")
if answer.lower() == 'y':
process_word()
process_next_word()
elif answer.lower() == 'n':
print "Thanks"
sys.exit()