Package: rhvoice-wrapper
High-level interface for RHVoice libraryGenerating speech stream from text viaRHVoicelibrary without re-initializing engine.
This very fast and more convenient than call RHVoice-test.Supported audio formats:wav,mp3,opus,flacandpcm(raw RHVoice output).Installpip3 install rhvoice-wrapperThis package doesNOTprovide RHVoice itself. You must be build (or install) RHVoice, languages and voices manually. In Windows you must specify the paths for work.rhvoice-wrapper-binWarning!rhvoice-wrapper-binnot working inmacOS, install RHVoice manually.Instead of RHVoice you may installrhvoice-wrapper-bin. This is best way for Windows.
If therhvoice-wrapper-binis installed, its libraries and data will be used automatically.pip3 install rhvoice-wrapper[rhvoice]DocumentationFirst create TTS object:fromrhvoice_wrapperimportTTStts=TTS(threads=1)You may set options when creating or through variable environments (UPPER REGISTER). Options override variable environments. To set the default value useNone:threadsorTHREADED. If equal to1, created one thread object, if more running in multiprocessing mode and create a lot of processes. Default1.force_processorPROCESSES_MODE: IfTrueengines run in multiprocessing mode, ifFalsein threads mode.
DefaultFalseif threads == 1, elseTrue.Threads mode and threads > 1 causes a segmentation faults or may return corrupted datalib_pathorRHVOICELIBPATH: Path to RHVoice library. DefaultlibRHVoice.soin Linux,libRHVoice.dylibin macOS andRHVoice.dllin Windows.data_pathorRHVOICEDATAPATH: Path to folder, containing voices and languages folders. Default/usr/local/share/RHVoice.config_pathorRHVOICECONFIGPATH: Path to folder, contain RHVoice.conf in linux and RHVoice.ini in windows. Default/usr/local/etc/RHVoice.resourcesorRHVOICERESOURCES: A list of paths to language and voice data. It should be used when it is not possible to collect all the data in one place. Default[].lame_pathorLAMEPATH: Path tolame, optional. Lame must be present formp3support. Defaultlame.opus_pathorOPUSENCPATH: Path toopusenc, optional. File must be present foropussupport. Defaultopusenc.flac_pathorFLACPATH: Path toflac, optional. File must be present forflacsupport. Defaultflac.quietorQUIET: IfTruedon't info output. DefaultFalse.streamorRHVOICESTREAM: Processing and sending chunks soon as possible, otherwise processing and sending only full data including length:saywill return one big chunk, formats other thanwavandpcmwill be generated much slower. DefaultTrue.UsageStart synthesis generator and get audio data, chunk by chunk:defgenerator_audio(text,voice='anna',format_='wav',buff=4096,sets=None):withtts.say(text,voice,format_,buff,sets)asgen:forchunkingen:yieldchunkOr get all audio data in one big chunk:data=tts.get('Hello world!',format_='wav')print('data size: ',len(data),' bytes')subprocess.check_output(['aplay','-q'],input=data)Or just save to file:tts.to_file(filename='esperanto.ogg',text='Saluton mondo',voice='spomenka',format_='opus',sets=None)format_is output audio format. Must be present intts.formats.voiceis a voice of speaker. Must be present intts.voice_profiles.voice='Voice', sets=Noneequalvoice=None, sets={'voice_profile': 'Voice'},voicemore priority.setsmay set as dict containing synthesis parameters as inset_params.
This parameters only work for current phrase. DefaultNone.IfbuffequalNone or 0, for pcm and wav chunks return as is (probably little faster).
For others used default chunk size (4 KiB).Text as iterable objectIftextiterable object, all its fragments will processing successively.
This is a good method for processing incredibly large texts.
Remember, the generator cannot be transferred to another process. Example:def_text():withopen('wery_large_book.txt')asfp:text=fp.read(5000)whiletext:yieldtexttext=fp.read(5000)defgenerator_audio():withtts.say(_text())asgen:forchunkingen:yieldchunkOther methodsset_paramsChanges voice synthesizer settings:tts.set_params(**kwargs)Allow:voice_profile,absolute_rate,absolute_pitch,absolute_volume,relative_rate,relative_pitch,relative_volume,punctuation_mode,punctuation_list,capitals_mode,flags. See RHVoice documentation for details.ReturnTrueif change, elseFalse.get_paramsGet voice synthesizer settings:tts.get_params(param=None)If param isNonereturn all settings indict, else parameter value by name. If parameter not found returnNone.joinJoin thread or processes. Don't use object after join:tts.join()PropertiesTTS.formats: List of supported formats,pcmandwavalways present.TTS.thread_count: Number of synthesis threads.TTS.process: IfTrue, TTS running in multiprocessing mode.TTS.voices: List of supported voices.TTS.voice_profiles: List of supported voice profiles.TTS.voices_info: Dictionary of supported voices with voices information.TTS.api_version: Supported RHVoice library version.TTS.lib_version: RHVoice library version. If not inrhvoice_wrapper.rhvoice_proxy.SUPPORT, may incorrect work.TTS.cmd: Dictionary of external calls, as it is.ExamplesExamplesExample usageRequirementsOS: Linux, WindowsRHVoice library 0.7.2 or above, languages and voicesPython 3.5 +