示例#1
0
def iteration(stt, keyphrase):
    wav, threshold = audio.keyRecording(
        THRESHOLD_TIME=1, THRESHOLD_MULTIPLIER=1.8, LISTEN_TIME=10,
        verbose=True, wav=True
    )
    if not wav:
        return None
    hyp = stt.transcribe(wav)
    if hyp:
        print stt.get_prob()
        if keyphrase == hyp:
            return threshold or 1
    return None
示例#2
0
文件: mic.py 项目: yannickulrich/IRIS
    def semiActiveListen(self, listen_time, use_local=None):
        self.stop_itunes()
        if use_local is None:
            use_local = self.use_local
        if self.prompt:
            self.userinput = raw_input("YOU: ")
        else:
            frames, self.threshold = audio.keyRecording(
                LISTEN_TIME=listen_time, verbose=True
            )

            if not frames:
                self.undo_itunes()
                return ''
            self.wav, energies = audio.record(
                verbose=True, threshold=self.threshold,
                initialFrames=frames, emptyFrames=20
            )
            if use_local:
                self.userinput = self.localSTT.transcribe(self.wav)
            else:
                self.userinput = self.cloudSTT.transcribe(self.wav)
        self.undo_itunes()
        return self.userinput