Skip to content

Commit

Permalink
nanotts executable (#6)
Browse files Browse the repository at this point in the history
* nanotts executable

support https://github.com/gmn/nanotts as a backend, this seems to be the latest iteration on picotts

* Update __init__.py

* Update __init__.py
  • Loading branch information
JarbasAl authored Aug 26, 2022
1 parent e884c9c commit 3f1ce8e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ovos_tts_plugin_pico/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ def __init__(self, *args, **kwargs):
validator=PicoTTSValidator(self))
if not self.voice:
self.voice = get_voice_from_lang(self.lang)

# TODO support speed and pitch for nanotts
self.nanotts = find_executable("nanotts")
self.pico2wave = find_executable("pico2wave")
self.picotts = find_executable("pico-tts")
if not self.pico2wave and not self.picotts:
if not self.nanotts and not self.pico2wave and not self.picotts:
raise RuntimeError("pico2wave/pico-tts executable not found")

def get_nanotts(self, sentence, wav_file, voice):
subprocess.call(
[self.nanotts, '-v', voice, "-o", wav_file, sentence])
return wav_file

def get_pico2wave(self, sentence, wav_file, voice):
subprocess.call(
[self.pico2wave, '-l', voice, "-w", wav_file, sentence])
Expand All @@ -55,7 +63,9 @@ def get_tts(self, sentence, wav_file, lang=None):
voice = get_voice_from_lang(lang) or self.voice
else:
voice = self.voice
if self.pico2wave:
if self.nanotts:
wav_file = self.get_nanotts(sentence, wav_file, voice)
elif self.pico2wave:
wav_file = self.get_pico2wave(sentence, wav_file, voice)
else:
wav_file = self.get_picotts(sentence, wav_file, voice)
Expand Down Expand Up @@ -85,7 +95,8 @@ def validate_lang(self):

def validate_connection(self):
if not find_executable("pico2wave") and \
not find_executable("pico-tts"):
not find_executable("pico-tts") and \
not find_executable("nanotts"):
raise Exception(
'PicoTTS is not installed. Run: '
'\nsudo apt-get install libttspico0\n'
Expand Down

0 comments on commit 3f1ce8e

Please sign in to comment.