def proc(s,t): data=AudioUtils.deinterleave(s,2) shorts=[AudioUtils.toShorts(k) for k in data] shorts[0]=list(shorts[0]) shorts[1]=list(shorts[1]) for i in range(len(shorts[0])): shorts[0][i]=math.sin(t/(math.pi*10000))*shorts[0][i] shorts[1][i]=math.cos(t/(math.pi*10000))*shorts[1][i] strings=[AudioUtils.toBytes(k) for k in shorts] return AudioUtils.interleave(strings,2)
def search_for_match(text): os.chdir( os.getcwd() + '/Trvial_Skill/Questions/') # todo: questions is answers <opposite!> filesInDir = os.listdir() for file in filesInDir: line_number = readQuestionChoices(file, text) if (line_number != -1): answer = readAnswerChoices(file, line_number) AudioUtils.reply(answer) return True return False
def run(self): while self.running: delay=max([c.qsize() for c in self.chans]) if delay>self.streamInfo['CHUNK']*2: chunk=[c.read(min(self.streamInfo['CHUNK']),c.qsize()) for c in self.chans] for i in range(len(chunk)): if len(chunk[i])<self.streamInfo['CHUNK']: chunk[i]+='\0'*(self.streamInfo['CHUNK']-len(chunk[i])) data=AudioUtils.interleave(chunk,self.streamInfo['CHANNELS']) self.stream.write(data)
def run(self): while self.running: chunk=self.stream.read(self.streamInfo['CHUNK']) data=AudioUtils.deinterleave(chunk,self.streamInfo['CHANNELS']) self.stream.close()