def processStringInternal(self, s, symbolLevel, language): index = 0 for match in self.regexp.finditer(s): if speech.isBlank(speech.processText(language,match.group(0), symbolLevel)): # Current punctuation level indicates that punctuation mark matched will not be pronounced, therefore skipping it. continue yield s[index:match.start(0)] yield self.speechCommand index = match.end(0) yield s[index:]
def postProcessSynchronousCommands(speechSequence, symbolLevel): language=speech.getCurrentLanguage() speechSequence = [element for element in speechSequence if not isinstance(element, str) or not speech.isBlank(speech.processText(language,element,symbolLevel)) ] newSequence = [] for (isSynchronous, values) in itertools.groupby(speechSequence, key=lambda x: isinstance(x, PpSynchronousCommand)): if isSynchronous: chain = PpChainCommand(list(values)) duration = chain.getDuration() newSequence.append(chain) newSequence.append(speech.commands.BreakCommand(duration)) else: newSequence.extend(values) newSequence = eloquenceFix(newSequence, language, symbolLevel) return newSequence
def eloquenceFix(speechSequence, language, symbolLevel): """ With some versions of eloquence driver, when the entire utterance has been replaced with audio icons, and therefore there is nothing else to speak, the driver for some reason issues the callback command after the break command, not before. To work around this, we detect this case and remove break command completely. """ nonEmpty = [element for element in speechSequence if isinstance(element, str) and not speech.isBlank(speech.processText(language,element,symbolLevel)) ] if len(nonEmpty) > 0: return speechSequence indicesToRemove = [] for i in range(1, len(speechSequence)): if ( isinstance(speechSequence[i], speech.commands.BreakCommand) and isinstance(speechSequence[i-1], PpChainCommand) ): indicesToRemove.append(i) return [speechSequence[i] for i in range(len(speechSequence)) if i not in indicesToRemove]
def test(self, s, symbolLevel): wav = "H:\\drp\\work\\emacspeak\\sounds\\classic\\alarm.wav" wavLength = self.getWavLengthMillis(wav) language = speech.getCurrentLanguage() tone = 500 while "!" in s: index = s.index("!") prefix = s[:index] prefix = prefix.lstrip() pPrefix = speech.processText(language, prefix, symbolLevel) if speech.isBlank(pPrefix): pass else: yield prefix #yield speech.commands.WaveFileCommand(wav) #yield speech.commands.BeepCommand(tone, 100) #yield PpBeepCommand(tone, 100) yield PpWaveFileCommand(wav) tone += 50 #yield speech.commands.BreakCommand(100) s = s[index + 1:] if len(s) > 0: yield s