-
Notifications
You must be signed in to change notification settings - Fork 1
/
Transcript.py
38 lines (36 loc) · 1.02 KB
/
Transcript.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
import os
def determineTranscript():
f = open('WatsonSTTResult.txt', 'r')
transcript = ''
confidence = ''
num = 0
while (True):
text = f.readline()
if '"confidence": ' in text:
confidence = text[29:(len(text) - 3)]
num = float(confidence)
text = f.readline()
if (num >= 0.7):
transcript += " " + text[30:(len(text) - 3)]
if text == '':
break
if (transcript == ''):
os.system('aplay louder.wav')
transcript = "false"
return transcript
def determineEmotion():
f = open('WatsonAnalyzerResult.txt', 'r')
emotion = ''
confidence = ''
num = 0
while (True):
text = f.readline()
if '"score": ' in text:
confidence = text[21:(len(text) - 3)]
num = float(confidence)
text = f.readline()
if (num >= 0.75):
emotion += " " + text[24:(len(text) - 2)]
if text == '':
break
return emotion