Browse Source

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

Jezra 9 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,7 +76,12 @@ class Blather:
76 76
 			self.history = []
77 77
 
78 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 85
 		self.recognizer.connect('finished',self.recognizer_finished)
81 86
 
82 87
 		print "Using Options: ", self.options

+ 2
- 0
Recognizer.py View File

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

Loading…
Cancel
Save