예제 #1
0
파일: google.py 프로젝트: km-p/backends
 def getWavStream(self,text):
     wav_path = os.path.join(util.getTmpfs(),'speech.wav')
     mp3_path = os.path.join(util.getTmpfs(),'speech.mp3')
     self.runCommand(text,mp3_path)
     self.process = subprocess.Popen(['mpg123','-w',wav_path,mp3_path],stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)
     while self.process.poll() == None and self.active: util.sleep(10)
     os.remove(mp3_path)
     return open(wav_path,'rb')
예제 #2
0
    def play(self, path):
        args = self.playArgs(path)
        self._wavProcess = subprocess.Popen(args,
                                            stdout=(open(os.path.devnull,
                                                         'w')),
                                            stderr=subprocess.STDOUT)

        while self._wavProcess.poll() == None and self.active:
            util.sleep(10)
예제 #3
0
파일: __init__.py 프로젝트: km-p/backends
 def play(self,path):
     if not os.path.exists(path):
         util.LOG('WindowsAudioPlayer.play() - Missing wav file')
         return
     self.audio = self._player.load(path)
     self.audio.play()
     self.event.clear()
     self.event.wait(self.audio.milliseconds() / 1000.0)
     if self.event.isSet(): self.audio.stop()
     while self.audio.isplaying(): util.sleep(10)
     self.audio = None
예제 #4
0
	def play(self,path):
		if not os.path.exists(path):
			util.LOG('WindowsAudioPlayer.play() - Missing wav file')
			return
		self.audio = self._player.load(path)
		self.audio.play()
		self.event.clear()
		self.event.wait(self.audio.milliseconds() / 1000.0)
		if self.event.isSet(): self.audio.stop()
		while self.audio.isplaying(): util.sleep(10)
		self.audio = None
예제 #5
0
파일: google.py 프로젝트: km-p/backends
 def getWavStream(self, text):
     wav_path = os.path.join(util.getTmpfs(), 'speech.wav')
     mp3_path = os.path.join(util.getTmpfs(), 'speech.mp3')
     self.runCommand(text, mp3_path)
     self.process = subprocess.Popen(['mpg123', '-w', wav_path, mp3_path],
                                     stdout=(open(os.path.devnull, 'w')),
                                     stderr=subprocess.STDOUT)
     while self.process.poll() == None and self.active:
         util.sleep(10)
     os.remove(mp3_path)
     return open(wav_path, 'rb')
예제 #6
0
파일: sapi.py 프로젝트: km-p/backends
 def __init__(self):
     self.SpVoice = None
     self.comtypesClient = None
     self.valid = False
     self._voiceName = None
     self.interrupt = False
     try:
         self.reset()
     except:
         util.ERROR('SAPI: Initialization failed: retrying...')
         util.sleep(1000) #May not be necessary, but here it is
         try:
             self.reset()
         except:
             util.ERROR('SAPI: Initialization failed: Giving up.')
             return
     self.valid = True
     self.COMError = importHelper('_ctypes').COMError
     self.setStreamFlags()
예제 #7
0
파일: sapi.py 프로젝트: km-p/backends
        return None

    def checkSAPI(func):
        def checker(self,*args,**kwargs):
            if not self.valid:
                util.LOG('SAPI: Broken - ignoring {0}'.format(func.__name__))
                return None
            try:
                return func(self,*args,**kwargs)
            except self.COMError,e:
                self.logSAPIError(e,func.__name__)
            except:
                util.ERROR('SAPI: {0} error'.format(func.__name__))
            self.valid = False
            util.LOG('SAPI: Resetting...')
            util.sleep(1000)
            try:
                self.reset()
                self.valid = True
                util.LOG('SAPI: Resetting succeded.')
                return func(self,*args,**kwargs)
            except self.COMError,e:
                self.valid = False
                self.logSAPIError(e,func.__name__)
            except:
                self.valid = False
                util.ERROR('SAPI: {0} error'.format(func.__name__))

        return checker

    #Wrapped SAPI methods
예제 #8
0
파일: osxsay.py 프로젝트: km-p/backends
 def threadedSay(self, text):
     if not text:
         return
     self.process = subprocess.Popen(["say", text.encode("utf-8")])
     while self.process.poll() == None and self.active:
         util.sleep(10)
예제 #9
0
        self._wavProcess = subprocess.Popen(self._pipeArgs,
                                            stdin=subprocess.PIPE,
                                            stdout=(open(os.path.devnull,
                                                         'w')),
                                            stderr=subprocess.STDOUT)
        try:
            shutil.copyfileobj(source, self._wavProcess.stdin)
        except IOError, e:
            if e.errno != errno.EPIPE:
                util.ERROR('Error piping audio', hide_tb=True)
        except:
            util.ERROR('Error piping audio', hide_tb=True)
        source.close()
        self._wavProcess.stdin.close()
        while self._wavProcess.poll() == None and self.active:
            util.sleep(10)

    def setSpeed(self, speed):
        self.speed = speed

    def setVolume(self, volume):
        self.volume = volume

    def play(self, path):
        args = self.playArgs(path)
        self._wavProcess = subprocess.Popen(args,
                                            stdout=(open(os.path.devnull,
                                                         'w')),
                                            stderr=subprocess.STDOUT)

        while self._wavProcess.poll() == None and self.active:
예제 #10
0
파일: __init__.py 프로젝트: km-p/backends
    def play(self,path):
        args = self.playArgs(path)
        self._wavProcess = subprocess.Popen(args,stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)

        while self._wavProcess.poll() == None and self.active: util.sleep(10)
예제 #11
0
파일: termux.py 프로젝트: ruuk/backends
    def runCommandAndSpeak(self, text):
        args = ['termux-tts-speak', text]

        process = subprocess.Popen(args)
        while process.poll() == None and self.active:
            util.sleep(10)
예제 #12
0
파일: __init__.py 프로젝트: km-p/backends
        util.LOG_DEBUG ("SubprocessAudioPlayer.pipe: after adding _soundOutputArgs pipeArgs={}".format (pipeArgs))

        #self._wavProcess = subprocess.Popen(self._pipeArgs,stdin=subprocess.PIPE,stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)
        self._wavProcess = subprocess.Popen(pipeArgs,stdin=subprocess.PIPE,stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)
        ##########

        try:
            shutil.copyfileobj(source,self._wavProcess.stdin)
        except IOError,e:
            if e.errno != errno.EPIPE:
                util.ERROR('Error piping audio',hide_tb=True)
        except:
            util.ERROR('Error piping audio',hide_tb=True)
        source.close()
        self._wavProcess.stdin.close()
        while self._wavProcess.poll() == None and self.active: util.sleep(10)

    def setSpeed(self,speed):
        self.speed = speed

    def setVolume(self,volume):
        self.volume = volume

    def play(self,path):
        args = self.playArgs(path)
        self._wavProcess = subprocess.Popen(args,stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)

        while self._wavProcess.poll() == None and self.active: util.sleep(10)

    def isPlaying(self):
        return self._wavProcess and self._wavProcess.poll() == None
예제 #13
0
		
	def canPipe(self):
		return bool(self._pipeArgs)
		
	def pipe(self,source):
		self._wavProcess = subprocess.Popen(self._pipeArgs,stdin=subprocess.PIPE,stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)
		try:
			shutil.copyfileobj(source,self._wavProcess.stdin)
		except IOError,e:
			if e.errno != errno.EPIPE:
				util.ERROR('Error piping audio',hide_tb=True)
		except:
			util.ERROR('Error piping audio',hide_tb=True)
		source.close()
		self._wavProcess.stdin.close()
		while self._wavProcess.poll() == None and self.active: util.sleep(10)
		
	def setSpeed(self,speed):
		self.speed = speed
		
	def setVolume(self,volume):
		self.volume = volume
		
	def play(self,path):
		args = self.playArgs(path)
		self._wavProcess = subprocess.Popen(args,stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)
		
		while self._wavProcess.poll() == None and self.active: util.sleep(10)
		
	def isPlaying(self):
		return self._wavProcess and self._wavProcess.poll() == None
예제 #14
0
파일: base.py 프로젝트: km-p/backends
    def insertPause(self,ms=500):
        """Insert a pause of ms milliseconds

        May be overridden by sublcasses. Default implementation sleeps for ms.
        """
        util.sleep(ms)
예제 #15
0
 def threadedSay(self, text):
     if not text: return
     self.process = subprocess.Popen(['say', text.encode('utf-8')])
     while self.process.poll() == None and self.active:
         util.sleep(10)
예제 #16
0
 def runCommandAndSpeak(self,text):
     args = ['recite',text]
     self.process = subprocess.Popen(args)
     while self.process.poll() == None and self.active: util.sleep(10)
예제 #17
0
 def threadedSay(self, text):
     if not text: return
     self.synth.startSpeakingString_(self.cocoapy.get_NSString(text))
     while self.synth.isSpeaking():
         util.sleep(10)
예제 #18
0
    def insertPause(self, ms=500):
        """Insert a pause of ms milliseconds

        May be overridden by sublcasses. Default implementation sleeps for ms.
        """
        util.sleep(ms)
예제 #19
0
파일: osxsay.py 프로젝트: km-p/backends
 def threadedSay(self, text):
     if not text:
         return
     self.synth.startSpeakingString_(self.cocoapy.get_NSString(text))
     while self.synth.isSpeaking():
         util.sleep(10)
예제 #20
0
파일: flite.py 프로젝트: km-p/backends
 def runCommandAndSpeak(self,text):
     self.process = subprocess.Popen(['flite', '-voice', self.voice, '-t', text.encode('utf-8')])
     while self.process.poll() == None and self.active: util.sleep(10)
예제 #21
0
 def runCommandAndSpeak(self, text):
     self.process = subprocess.Popen(
         ['flite', '-voice', self.voice, '-t',
          text.encode('utf-8')])
     while self.process.poll() == None and self.active:
         util.sleep(10)