예제 #1
0
    def speak(self, statement):
        import time

        if self.platform == 'darwin':
            # Use Mac's built-in say command to speak the response
            cmd = ['say', str(statement.text)]

            subprocess.call(
                cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
            )

            return statement.text

        from espeak import espeak
        from espeak import core as espeak_core

        done_synth = [False]

        def synth_callback(event, pos, length):
            if event == espeak_core.event_MSG_TERMINATED:
                done_synth[0] = True

        espeak.set_SynthCallback(synth_callback)
        call_result = espeak.synth(statement)

        # Wait for the speech to stop
        while call_result and not done_synth[0]:
            time.sleep(0.05)

        return call_result
예제 #2
0
    def speak(self, statement):
        import time

        if self.platform == 'darwin':
            # Use Mac's built-in say command to speak the response
            cmd = ['say', str(statement.text)]

            subprocess.call(cmd,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)

            return statement.text

        from espeak import espeak
        from espeak import core as espeak_core

        done_synth = [False]

        def synth_callback(event, pos, length):
            if event == espeak_core.event_MSG_TERMINATED:
                done_synth[0] = True

        espeak.set_SynthCallback(synth_callback)
        call_result = espeak.synth(statement)

        # Wait for the speech to stop
        while call_result and not done_synth[0]:
            time.sleep(0.05)

        return call_result
예제 #3
0
파일: tts1.py 프로젝트: TheBatUNT/thebat
def say(*args):
  done_synth = [False]
  def synth_callback(event, pos, length):
    if event == espeak_core.event_MSG_TERMINATED:
      done_synth[0] = True
  espeak.set_SynthCallback(synth_callback)
  call_result = espeak.synth(*args)
  while call_result and not done_synth[0]:
    time.sleep(0.05)
  return call_result
예제 #4
0
def speak(*args):
	#https://answers.launchpad.net/python-espeak/+question/244655
    done_synth = [False]
    def cb(event, pos, length):
        if event == espeak_core.event_MSG_TERMINATED:
            done_synth[0] = True
    espeak.set_SynthCallback(cb)
    r = espeak.synth(*args)
    while r and not done_synth[0]:
        time.sleep(0.05)
    return r
예제 #5
0
 def __init__(self):
     self.set_sounds()
     if PY_LIB_GOOD:
         self.player = Gst.ElementFactory.make("playbin", "player")
         self.player.set_property("uri", "file://" + self.error)
         # Enable message bus to check for errors in the pipeline
         bus = self.player.get_bus()
         bus.add_signal_watch()
         bus.connect("message", self.on_message)
     try:
         espeak.set_SynthCallback(self.speak_finished)
     except Exception as e:
         pass
예제 #6
0
파일: speech.py 프로젝트: EbaCorp/vega
    def say(*args):
        done_synth = [False]

        def cb(event, pos, length):
            if event == espeak_core.event_MSG_TERMINATED:
                done_synth[0] = True

        espeak.set_SynthCallback(cb)
        r = espeak.synth(*args)

        while r and not done_synth[0]:
            time.sleep(0.05)
        return r
예제 #7
0
def wait4espeak(r):
    #
    # A Function that puts the programm to sleep while espeak is busy
    #
    # :param r: the synthesized text
    #
    done_synth = [False]

    def cb(event, pos, length):
        if event == espeak.core.event_MSG_TERMINATED:
            done_synth[0] = True

    espeak.set_SynthCallback(cb)
    while r and not done_synth[0]:
        time.sleep(0.10)
예제 #8
0
파일: m5k.py 프로젝트: lvm/m5k
def _espeak_synth(args):
    """
    https://answers.launchpad.net/python-espeak/+question/244655
    """
    if not USE_ESPEAK:
        return
    done_synth = [False]
    def cb(event, pos, length):
        if event == espeak_core.event_MSG_TERMINATED:
            done_synth[0] = True
    espeak.set_SynthCallback(cb)
    r = espeak.synth(args)
    while r and not done_synth[0]:
        time.sleep(0.05)
    return r
예제 #9
0
    def _speak(self, text, acss, callback=None):
        if isinstance(text, ACSS):
            text = ''
        text = self.__addVerbalizedPunctuation(text)
        if orca_state.activeScript:
            text = orca_state.activeScript.\
                utilities.adjustForPronunciation(text)

        # We need to make several replacements.
        text = text.translate({
            0x1: None, # used for embedded commands
            0x5B: u" [", # [: [[ indicates phonemes
        })

        self._apply_acss(acss)
        espeak.set_SynthCallback(callback)
        espeak.synth(text)
예제 #10
0
def synth(*args):
        global ButtonPressed
        done_synth=[False]
        def cb(event,pos,length):
          if event==espeak_core.event_MSG_TERMINATED:
                  done_synth[0]=True
        espeak.set_SynthCallback(cb)
        r = espeak.synth(*args)
        while r and not done_synth[0]:
                time.sleep(0.05)
                if ButtonPressed is not 0:
                        #ButtonPressed=0
                        done_synth[0]=True
                        print "Espeak canceled. Button ", ButtonPressed
                        espeak.cancel()
                        return r
        return r
예제 #11
0
    def _speak(self, text, acss, callback=None):
        if isinstance(text, ACSS):
            text = ''
        text = self.__addVerbalizedPunctuation(text)
        if orca_state.activeScript:
            text = orca_state.activeScript.\
                utilities.adjustForPronunciation(text)

        # We need to make several replacements.
        text = text.translate({
            0x1: None,  # used for embedded commands
            0x5B: u" [",  # [: [[ indicates phonemes
        })

        self._apply_acss(acss)
        espeak.set_SynthCallback(callback)
        espeak.synth(text)
예제 #12
0
    def get_espeak_call_result(self, text):
        import time
        from espeak import espeak
        from espeak import core as espeak_core

        done_synth = [False]

        def synth_callback(event, pos, length):
            if event == espeak_core.event_MSG_TERMINATED:
                done_synth[0] = True

        espeak.set_SynthCallback(synth_callback)
        call_result = espeak.synth(text)

        # Wait for the speech to stop
        while call_result and not done_synth[0]:
            time.sleep(0.05)

        return call_result
예제 #13
0
파일: speech.py 프로젝트: ududsha/Salvius
    def reply(self, text):
        import time
        from espeak import espeak
        from espeak import core as espeak_core

        # Get the robot's response to the input text
        response = self.connection.respond(text)

        done_synth = [False]

        def synth_callback(event, pos, length):
            if event == espeak_core.event_MSG_TERMINATED:
                done_synth[0] = True

        espeak.set_SynthCallback(synth_callback)
        call_result = espeak.synth(response['text'])

        # Wait for the speech to stop
        while call_result and not done_synth[0]:
            time.sleep(0.05)

        return call_result
예제 #14
0
파일: speech.py 프로젝트: emijrp/Salvius
    def reply(self, text):
        import time
        from espeak import espeak
        from espeak import core as espeak_core

        # Get the robot's response to the input text
        response = self.connection.respond(text)

        done_synth = [False]

        def synth_callback(event, pos, length):
            if event == espeak_core.event_MSG_TERMINATED:
                done_synth[0] = True

        espeak.set_SynthCallback(synth_callback)
        call_result = espeak.synth(response.text)

        # Wait for the speech to stop
        while call_result and not done_synth[0]:
            time.sleep(0.05)

        return call_result
예제 #15
0
    display_active = False
    print("PySerial not found. VFD output disabled.", file=sys.stderr)
    
try:
    from espeak import espeak
    from espeak import core as espeak_core
    # done_synth signals when the speech synthesizer has finished
    global old_count
    old_count = 0    
    global done_synth
    done_synth = True
    def espeak_callback(event, pos, length):
        if event == espeak_core.event_MSG_TERMINATED:
            global done_synth
            done_synth = True
    espeak.set_SynthCallback(espeak_callback)
    voice_active = True
except:
    voice_active = False
    print("Espeak not found. Voice output deactivated", file=sys.stderr)

default_cascade = "/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml"

# Control commands for Toshiba LIUST-51 Vacuum Fluorescent Display
vfd_clear = '\x1B\x5B\x32\x4A'
vfd_del = '\x1B\x5B\x30\x4B'
vfd_lf = '\x0A'
vfd_cr = '\x0D'
vfd_line1 = '\x1B\x5B\x01\x3B\x01\x48'
vfd_line2 = '\x1B\x5B\x02\x3B\x01\x48'
예제 #16
0
파일: lios.py 프로젝트: Nalin-x-Linux/Lios
	def __init__(self,filename=None):
		self.guibuilder = gtk.Builder()
		self.guibuilder.add_from_file("/usr/share/lios/Gui/main.glade")
		self.window = self.guibuilder.get_object("window")
		self.textbuffer = self.guibuilder.get_object("textbuffer")
		self.textview = self.guibuilder.get_object("textview")
		self.image_frame = self.guibuilder.get_object("frame")
		self.progressbar = self.guibuilder.get_object("progressbar")
		self.random_label = self.guibuilder.get_object("random_label")
		self.random_spinbutton = self.guibuilder.get_object("random_spinbutton")
		self.random_entry = self.guibuilder.get_object("random_entry")
		self.random_label.hide()
		self.random_spinbutton.hide()
		self.random_entry.hide()
		self.textview.grab_focus()
		self.guibuilder.connect_signals(self)
		

		self.progressbar.set_pulse_step(.01)
		self.pulse = True
		
		#self.image = self.guibuilder.get_object("image")
		
		self.scrolledwindow_image = self.guibuilder.get_object("scrolledwindow_image")
		self.vruler = self.guibuilder.get_object("vruler")
		self.hruler = self.guibuilder.get_object("hruler")
		self.scrolledwindow_image.connect_object("motion_notify_event", self.motion_notify, self.hruler)
		self.scrolledwindow_image.connect_object("motion_notify_event", self.motion_notify, self.vruler)
		
		

		
		self.voice_list=[]
		for item in espeak.list_voices():
			self.voice_list.append(item.name)

		for item in "scan_to_ui","ocr_pdf","ocr_folder","ocr_image","scan_and_ocr","scan_and_ocr_repeatedly","cam_scan","optimise_brightness","ocr_ui_image":
			self.guibuilder.get_object(item).connect("activate",self.run_process,item)
			
			
		ocr_ui_image_button = self.guibuilder.get_object("ocr_ui_image_button")
		ocr_ui_image_button.connect("clicked",self.run_process,"ocr_ui_image")

		ocr_selected_image_region_button = self.guibuilder.get_object("ocr_selected_image_region_button")
		ocr_selected_image_region_button.connect("clicked",self.run_process,"ocr_selected_image_region")
		
		
		scan_to_ui_button = self.guibuilder.get_object("scan_to_ui_button")		 
		scan_to_ui_button.connect("clicked",self.run_process,"scan_to_ui")
		
		
		#Preferences
		General_Preferences = self.guibuilder.get_object("General_Preferences")
		General_Preferences.connect("activate",self.preferences,0)
		Preferences_Recognition = self.guibuilder.get_object("Preferences_Recognition")
		Preferences_Recognition.connect("activate",self.preferences,1)
		Preferences_Scanning = self.guibuilder.get_object("Preferences_Scanning")
		Preferences_Scanning.connect("activate",self.preferences,2)
		Preferences_CamaraWebcam = self.guibuilder.get_object("Preferences_CamaraWebcam")
		Preferences_CamaraWebcam.connect("activate",self.preferences,3)
		
		#Getting Preferences Values
		self.read_preferences()
		
		#Init Keep Runner
		self.keep_running = False

		# Intiating thred in PyGtk
		gtk.threads_init()
		
		#Espeak And event
		espeak.set_parameter(espeak.Parameter.Rate,self.voice_message_rate)
		espeak.set_parameter(espeak.Parameter.Pitch,self.voice_message_pitch)
		espeak.set_parameter(espeak.Parameter.Volume,self.voice_message_volume)
		espeak.set_voice(self.voice_list[self.voice_message_voice])
		espeak.set_SynthCallback(self.espeak_event)


		#Gnome-Canvas
		self.first_run = True
		self.canvas = gnomecanvas.Canvas(aa=True)
		self.dragging = False
		self.scrolledwindow_image.add(self.canvas)
		self.canvas.connect("event", self.canvas_event)
		self.set_image(self,data=None)
		self.canvas.show()
		self.window.maximize()		

		#Reading Dictionarys		
		self.key_value = {"eng" : "en","afr" : "af","am" : "am","ara" : "ar","ara" : "ar","bul" : "bg","ben" : "bn","br" : "br","cat" : "ca","ces" : "cs","cy" : "cy","dan" : "da","ger" : "de","ger" : "de","ell" : "el","eo" : "eo","spa" : "es","est" : "et","eu" : "eu","fa" : "fa","fin" : "fi","fo" : "fo","fra" : "fr","ga" : "ga","gl" : "gl","gu" : "gu","heb" : "he","hin" : "hi","hrv" : "hr","hsb" : "hsb","hun" : "hu","hy" : "hy","id" : "id","is" : "is","ita" : "it","kk" : "kk","kn" : "kn","ku" : "ku","lit" : "lt","lav" : "lv","mal" : "ml ","mr" : "mr ","dut" : "nl","no" : "no","nr" : "nr","ns" : "ns ","or" : "or ","pa" : "pa ","pol" : "pl ","por" : "pt","por" : "pt","por" : "pt","ron" : "ro","rus" : "ru ","slk" : "sk","slv" : "sl","ss" : "ss","st" : "st","swe" : "sv","tam" : "ta","tel" : "te","tl" : "tl","tn" : "tn","ts" : "ts","ukr" : "uk","uz" : "uz","xh" : "xh","zu" : "zu" }
		self.dict = enchant.Dict("%s" % self.key_value[self.language])
		
		#Font 
		pangoFont = pango.FontDescription(self.font)
		self.textview.modify_font(pangoFont)

		if (filename):
			 self.textbuffer.set_text(open(filename,"r").read())
			 self.save_file_name = filename
		else:
			#Opening Recent Document
			try:
				recent_open = open("%srecent"%directory,'r')
			except IOError:
				pass
			else:
				recent_text = recent_open.read()
				self.textbuffer.set_text(recent_text)
		
		#Color
		self.highlight_tag = self.textbuffer.create_tag('Reading')
		self.textview.modify_text(gtk.STATE_NORMAL, gtk.gdk.Color(self.font_color))
		self.textview.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color(self.background_color))
		self.highlight_tag.set_property('foreground',gtk.gdk.Color(self.highlight_color))
		self.highlight_tag.set_property('background',gtk.gdk.Color(self.background_highlight_color))		
		self.highlight_tag.set_property('font',self.highlight_font)
		
		#Welcome
		self.notify("Welcome To Linux-Intelligent-O.C.R-Solution",True,None,True)
		gobject.timeout_add(20, self.pulse_progressbar)

		#Placing cursor
		self.textbuffer.place_cursor(self.textbuffer.get_start_iter())
		
		self.window.show()
		gtk.main()
예제 #17
0
def callb(event, pos, length):
    global speaking
    print(event)
    # Events can be,
    # WORD, SENTENCE, MARK, PLAY, END, MSG_TERMINATED or PHONEME
    if event == espeak_core.event_MSG_TERMINATED:
        print("End of")
        speaking = False

    if event == espeak_core.event_WORD:
        print("Open Mouth, Close Mouth")
        open_mouth()
        sleep(0.1)
        close_mouth()


espeak.set_SynthCallback(callb)

while True:
    espeak.synth(get_lyric())
    speaking = True
    while speaking:
        sleep(1)
        print(".")
    if on_a_pi:
        GPIO.wait_for_edge(switch_pin, GPIO.FALLING)
    else:
        print("Not on a pi so faking a wait")
        sleep(3)
예제 #18
0
        GPIO.output(head_pin, False)

def callb(event, pos, length):
    global speaking
    print(event)
    # Events can be,
    # WORD, SENTENCE, MARK, PLAY, END, MSG_TERMINATED or PHONEME
    if event == espeak_core.event_MSG_TERMINATED:
        print("End of")
        speaking = False

    if event == espeak_core.event_WORD:
        print("Open Mouth, Close Mouth")
        open_mouth()
        sleep(0.1)
        close_mouth()

espeak.set_SynthCallback(callb)

while True:
    espeak.synth(get_lyric())
    speaking=True
    while speaking:
        sleep(1)
        print(".")
    if on_a_pi:
        GPIO.wait_for_edge(switch_pin, GPIO.FALLING)
    else:
        print("Not on a pi so faking a wait")
        sleep(3)