def speak(self, item, lang): client = speechd.SSIPClient('vox-launcher') client.set_priority(speechd.client.Priority.IMPORTANT) client.set_pause_context(0) client.set_language(lang) client.speak(item) client.close()
def _init(self): self._client = client = speechd.SSIPClient('Orca', component=self._id) if self._id != self.DEFAULT_SERVER_ID: client.set_output_module(self._id) self._current_voice_properties = {} mode = self._PUNCTUATION_MODE_MAP[settings.verbalizePunctuationStyle] client.set_punctuation(mode)
def __init__(self, *args, **kwargs): super(SpeechDispatcher, self).__init__(*args, **kwargs) try: import speechd self.spd = speechd.SSIPClient(application.name) except ImportError: raise OutputError atexit.register(self.on_exit_event)
def voices(): try: client = speechd.SSIPClient('readetextstest') voices = client.list_synthesis_voices() client.close() return voices except Exception, e: _logger.warning('speech dispatcher not started: %s' % e) return []
def main(): try: import speechd client = speechd.SSIPClient('ReadTextExtensionPythonScript') except (ImportError): print ('I did not find the speechd voice synthesis resources!') usage() sys.exit(2) try: opts, args = getopt.getopt(sys.argv[1:], "holvr", ["help", "output_module=","language=","voice=","rate="]) except (getopt.GetoptError): # print help information and exit: print ( "option was not recognized" ) usage() sys.exit(2) for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() elif o in ("-o", "--output_module"): client.set_output_module(a) elif o in ("-l", "--language"): # 2 letters lowercase - fr Français, de Deutsch... client.set_language(a[:2].lower()) elif o in ("-v", "--voice"): # MALE1, MALE2 ... client.set_voice(a.upper()) elif o in ("-r", "--rate"): client.set_rate( int(a) ) else: assert False, "unhandled option" try: f = codecs.open(sys.argv[-1],mode='r',encoding=sys.getfilesystemencoding()) except (IOError): print ('I was unable to open the file you specified!') usage() else: sTXT=f.read() f.close() sD=" ".encode( "utf-8" ) sE=' \''.encode( "utf-8" ) sTXT=sTXT.encode("utf-8") sTXT1=sTXT.replace(sE,sD) sD=" ".encode( "utf-8" ) sE='\''.encode( "utf-8" ) sTXT=sTXT1.replace(sE,sD) sD=" ".encode( "utf-8" ) sE=' "'.encode( "utf-8" ) sTXT1=sTXT.replace(sE,sD) sD=" ".encode( "utf-8" ) sE='"'.encode( "utf-8" ) sTXT=sTXT1.replace(sE,sD) sTXT=sTXT.decode("utf-8") sA=' " ' +sTXT+'"' sA=sA.encode( "utf-8" ) client.set_punctuation(speechd.PunctuationMode.SOME) client.speak(sA) client.close() sys.exit(0)
def say(words): try: client = speechd.SSIPClient('readetextstest') client.set_rate(int(speech.rate)) client.set_pitch(int(speech.pitch)) client.set_language(speech.voice[1]) client.speak(words) client.close() except Exception, e: _logger.warning('speech dispatcher not running: %s' % e)
def speak(text): engine = speechd.SSIPClient('rhvoice') engine.set_output_module('rhvoice') engine.set_language('ru') engine.set_synthesis_voice('Elena') # engine.set_rate(9) engine.set_punctuation(speechd.PunctuationMode.SOME) engine.speak(str(text)) engine.close()
def say_speechd(self, text, priority='important'): '''speak some text''' ''' http://cvs.freebsoft.org/doc/speechd/ssip.html see 4.3.1 for priorities''' import speechd self.speech = speechd.SSIPClient('MAVProxy%u' % os.getpid()) self.speech.set_output_module('festival') self.speech.set_language('en') self.speech.set_priority(priority) self.speech.set_punctuation(speechd.PunctuationMode.SOME) self.speech.speak(text) self.speech.close()
def initialize(self, environment): self.env = environment try: import speechd self._sd = speechd.SSIPClient('fenrir') self._punct = speechd.PunctuationMode() self._isInitialized = True except Exception as e: self.env['runtime']['debug'].writeDebugOut(str(e), debug.debugLevel.ERROR) self._initialized = False
def __init__(self, tts_queue, name, engine, voice, language, volume, rate, pitch): super(SpeechDispatcher, self).__init__(tts_queue) self.client = speechd.SSIPClient(name) self.client.set_output_module(engine) self.client.set_voice(voice) self.client.set_language(language) self.client.set_volume(volume) self.client.set_rate(rate) self.client.set_pitch(pitch) self.client.set_punctuation(speechd.PunctuationMode.SOME)
def __init__(self): global speechd try: import speechd except: print( "Cannot find Speech Dispatcher. Please install python-speechd or python3-speechd." ) else: try: self._client = speechd.SSIPClient("") except Exception as e: print(e)
def say(text, priority='important'): '''speak some text''' ''' http://cvs.freebsoft.org/doc/speechd/ssip.html see 4.3.1 for priorities''' mpstate.console.writeln(text) if mpstate.settings.speech: import speechd mpstate.status.speech = speechd.SSIPClient('MAVProxy%u' % os.getpid()) mpstate.status.speech.set_output_module('festival') mpstate.status.speech.set_language('en') mpstate.status.speech.set_priority(priority) mpstate.status.speech.set_punctuation(speechd.PunctuationMode.SOME) mpstate.status.speech.speak(text) mpstate.status.speech.close()
def initialize(self, environment): self._sd = None self.env = environment self._isInitialized = False self.language = '' self.voice = '' self.module = '' try: import speechd self._sd = speechd.SSIPClient('fenrir') self._punct = speechd.PunctuationMode() self._isInitialized = True except Exception as e: self.env['runtime']['debug'].writeDebugOut( 'speechDriver initialize:' + str(e), debug.debugLevel.ERROR)
def __init__(self): # UI initialization QtGui.QMainWindow.__init__(self) self.setupUi(self) # Speech Dispatcher initialziation client = self._client = speechd.SSIPClient('speak.py') output_modules = client.list_output_modules() if output_modules: self.output_module.addItems(output_modules) client.set_output_module(output_modules[0]) client.set_punctuation(speechd.PunctuationMode.SOME) self.language.emit(QtCore.SIGNAL('textChanged(int)'), self.language.text()) self.volume.emit(QtCore.SIGNAL('valueChanged(int)'), self.volume.value()) self.rate.emit(QtCore.SIGNAL('valueChanged(int)'), self.rate.value())
def main(): try: import speechd client = speechd.SSIPClient('ReadTextExtensionPythonScript') except ImportError: print('I did not find the speechd voice synthesis resources!') print(str(err)) usage() sys.exit(2) try: opts, args = getopt.getopt( sys.argv[1:], "holvr", ["help", "output_module=", "language=", "voice=", "rate="]) except getopt.GetoptError, err: # print help information and exit: print(str(err)) # will print something like "option -a not recognized" usage() sys.exit(2)
def run(self): "This is the code that is executed when the start() method is called" self.client = None try: self.client = speechd.SSIPClient('readetexts') self.client._conn.send_command('SET', speechd.Scope.SELF, 'SSML_MODE', "ON") if speech.voice: self.client.set_language(speech.voice[1]) self.client.set_rate(speech.rate) self.client.set_pitch(speech.pitch) self.client.speak( self.words, self.next_word_cb, (speechd.CallbackType.INDEX_MARK, speechd.CallbackType.END)) global done done = False while not done: time.sleep(0.1) self.cancel() self.client.close() except Exception, e: _logger.warning('speech-dispatcher client not created: %s' % e)
def main(): s1 = sys.argv[-1] i1 = 0 if os.path.isfile(s1): if sys.argv[-1] == sys.argv[0]: usage() sys.exit(0) try: import speechd import time client = speechd.SSIPClient(readtexttools.fsAppSignature()) except (ImportError): print("I did not find the speechd voice synthesis resources!") usage() sys.exit(2) try: opts, args = getopt.getopt( sys.argv[1:], "holvr", ["help", "output_module=", "language=", "voice=", "rate="]) except (getopt.GetoptError): # print help information and exit: print('option was not recognized') usage() sys.exit(2) for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() elif o in ("-o", "--output_module"): client.set_output_module(a) elif o in ("-l", "--language"): # 2 letters lowercase - fr Français, de Deutsch... client.set_language(a[:2].lower()) sLang = a elif o in ("-v", "--voice"): # MALE1, MALE2 ... client.set_voice(a.upper()) elif o in ("-r", "--rate"): client.set_rate(int(a)) i1 = a else: assert False, "unhandled option" try: f = codecs.open(s1, mode='r', encoding=sys.getfilesystemencoding()) except (IOError): client.close() print("I was unable to open the file you specified!") usage() else: sTXT = f.read() f.close() sA = ' " ' + sTXT + '"' sLock = readtexttools.getMyLock("lock") if os.path.isfile(sLock): client.close() readtexttools.myossystem("spd-say --cancel") readtexttools.UnlockMyLock() else: readtexttools.LockMyLock() sTime = guessTime(sA, i1, s1, sLang) client.set_punctuation(speechd.PunctuationMode.SOME) client.speak(sA) client.close() time.sleep(sTime) readtexttools.UnlockMyLock() sys.exit(0) else: print("I was unable to find the text file you specified!") usage()
import speechd from tkinter import * import pyperclip tts_d = speechd.SSIPClient('test') tts_d.set_output_module('rhvoice') tts_d.set_language('ru') tts_d.set_voice('female1') tts_d.set_rate(100) tts_d.set_punctuation(speechd.PunctuationMode.SOME) tts_d.speak('готов') def hello_Call_Back(): tts_d.speak(pyperclip.paste()) def pause1(): print("ps") tts_d.pause() def resume1(): print("cn") tts_d.resume() def stop1(): print("cn") tts_d.stop()
import speechd client = speechd.SSIPClient('test') client.set_output_module('festival') client.set_language('en') client.set_punctuation(speechd.PunctuationMode.SOME) client.speak("Hello World!") client.close()
def main(): """ main function """ logging.basicConfig(format='[%(filename)s:%(lineno)d] %(message)s', level=logging.WARN) spdclient = speechd.SSIPClient('test') spdclient.set_language('zh') spdclient.set_rate(20) state_queue = multiprocessing.Queue(1) name_queue = multiprocessing.Queue(1) data_queue = multiprocessing.Queue() plter = plotter.Plotter(4, 'queue') data_process = multiprocessing.Process( target=delayout, args=(state_queue, name_queue, data_queue)) draw_process = multiprocessing.Process( target=plter.plot, args=({'queue': data_queue}, )) data_process.start() draw_process.start() actions = actionlist(USERNAME) # logging.debug(actions) inkey = '' idx = None for idx, val in enumerate(actions): actstr = translate_by_dicts(val.split('_')[1], GESTURES_DICT, BUTTONS_DICT) pronounce_str = translate_by_dicts(actstr, PRONOUNCE_DICT) logging.debug(pronounce_str) spdclient.speak(pronounce_str)#pronounce(pronounce_str) print( '[!] 按 %s 之后, 请做以下动作: [\033[30;103m %s \033[0m]' % (STARTKEY, actstr)) print( '[-] 做完动作之后,按 %s 保存。按 %s 退出' % (ENDKEY, QUITKEY)) print('main: input --> ', end='') sys.stdout.flush() while True: inkey = getch() print(inkey) print('main: input --> ', end='') sys.stdout.flush() logging.info('main: ' + inkey) if inkey == QUITKEY: break elif inkey == STARTKEY: state_queue.put(inkey) elif inkey == ENDKEY: name_queue.put(val) state_queue.put(inkey) break if inkey == QUITKEY: # let QUITKEY break to the most outer loop break time.sleep(.1) # add a delay to make display in more natural order with open('%s.actionlist' % USERNAME, 'w') as file_actionlist: if inkey == QUITKEY: file_actionlist.write('\n'.join(actions[idx:])) spdclient.set_language('en') spdclient.set_rate(0) spdclient.speak('Game Over') spdclient.close() data_process.terminate() draw_process.terminate() print('退出')
log("letter " + data) client.char(clean(data)) elif cmd == "tts_sync_state": punct, capitalize, allcaps, splitcaps, rate = re.split("\s+", data) #tts_sync_state(punct, capitalize, allcaps, splitcaps, rate) # x is for exit. Not used by emacspeak, helpful for testing. elif cmd == "x": client.close() exit() # Log any unimplemented commands else: log("Unimplemented: " + line) # Main client = speechd.SSIPClient('espd') # client.set_output_module('festival') client.set_language('en') client.set_punctuation(speechd.PunctuationMode.SOME) client.set_priority(speechd.Priority.MESSAGE) client.speak("Emacspeak Speech Dispatcher!") queue = deque([]) # queue of things to speak # Main loop read_partial_cmd = 0 # flag to indicate if we have only read a partial command so far input = [sys.stdin] while 1: log("select") #inputready,outputready,exceptready = select.select(input,[],[]) #print "inputready: ", inputready
import speechd from . import defaults # Настройка синтезатора речи tts_d = speechd.SSIPClient('Vasisya') tts_d.set_output_module('rhvoice') tts_d.set_language('ru') try: voice = defaults.get_value("voice") speed = defaults.get_value("speed") pitch = defaults.get_value("pitch") except FileNotFoundError: voice = defaults.defaults["voice"] speed = defaults.defaults["speed"] pitch = defaults.defaults["pitch"] tts_d.set_synthesis_voice(voice) tts_d.set_rate(speed) tts_d.set_punctuation(speechd.PunctuationMode.SOME) tts_d.set_pitch(pitch) def speak(message, widget): '''Выводит сообщение пользователю и озвучивает его. :param message: сообщение, которое нужно вывести и озвучить (string). :param widget: виджет, в который нужно вывести сообщение (QWidget). ''' tts_d.speak(message) # Озвучка переданного сообщения с помощью синтеза речи widget.addItem(message) # Вывод переданного сообщения в графический интерфейс widget.scrollToBottom() # Прокрутка виджета с сообщениями до конца
def __init__(self): self._client = speechd.SSIPClient("")
def __init__(self): self.client = speechd.SSIPClient('AccessibleOutput2') self.client.set_output_module('espeak-ng') self.client.set_punctuation(speechd.PunctuationMode.NONE)
def __init__(self): self.Client = speechd.SSIPClient('cah-speech-client')