Browse Source

*slightly* improved the error handling.... slightly

Jezra 10 years ago
parent
commit
8433aac1ed
2 changed files with 8 additions and 1 deletions
  1. 6
    1
      Blather.py
  2. 2
    0
      Recognizer.py

+ 6
- 1
Blather.py View File

76
 			self.history = []
76
 			self.history = []
77
 
77
 
78
 		#create the recognizer
78
 		#create the recognizer
79
-		self.recognizer = Recognizer(lang_file, dic_file, self.options['microphone'] )
79
+		try:
80
+			self.recognizer = Recognizer(lang_file, dic_file, self.options['microphone'] )
81
+		except Exception, e:
82
+			#no recognizer? bummer
83
+			sys.exit()
84
+
80
 		self.recognizer.connect('finished',self.recognizer_finished)
85
 		self.recognizer.connect('finished',self.recognizer_finished)
81
 
86
 
82
 		print "Using Options: ", self.options
87
 		print "Using Options: ", self.options

+ 2
- 0
Recognizer.py View File

7
 import gst
7
 import gst
8
 import os.path
8
 import os.path
9
 import gobject
9
 import gobject
10
+import sys
10
 
11
 
11
 #define some global variables
12
 #define some global variables
12
 this_dir = os.path.dirname( os.path.abspath(__file__) )
13
 this_dir = os.path.dirname( os.path.abspath(__file__) )
31
 		except Exception, e:
32
 		except Exception, e:
32
 			print e.message
33
 			print e.message
33
 			print "You may need to install gstreamer0.10-pocketsphinx"
34
 			print "You may need to install gstreamer0.10-pocketsphinx"
35
+			raise e
34
 
36
 
35
 		#get the Auto Speech Recognition piece
37
 		#get the Auto Speech Recognition piece
36
 		asr=self.pipeline.get_by_name('asr')
38
 		asr=self.pipeline.get_by_name('asr')

Loading…
Cancel
Save