jasonppy / VoiceCraft

Zero-Shot Speech Editing and Text-to-Speech in the Wild
Other
7.67k stars 749 forks source link

RuntimeError: espeak not installed on your system #33

Closed valentinweyer closed 8 months ago

valentinweyer commented 8 months ago

Environment

Issue Description I am attempting to run the inference_tts.ipynb notebook on an Apple Silicon Mac. As part of adapting the code for Apple Silicon, I replaced CUDA references with MPS (or CPU where MPS isn't an option). However, I encountered a runtime error related to espeak not being recognized by the system despite being installed.

Steps taken

  1. Installed espeak via Homebrew using brew install espeak.
  2. Confirmed espeak installation with espeak --version, which outputs 'eSpeak NG text-to-speech: 1.51.1'
  3. Ran the inference_tts.ipynb notebook after making necessary modifications for MPS compatibility.
  4. Encountered the RuntimeError: espeak not installed on your system upon executing Cell 4.

Behavior Despite espeak being installed (confirmed via command line), a RuntimeError is thrown indicating that espeak is not installed on the system.

Troubleshooting Steps Taken

Full output with error

RuntimeError                              Traceback (most recent call last)
Cell In[4], line 31
     27 model.eval()
     29 phn2num = ckpt['phn2num']
---> 31 text_tokenizer = TextTokenizer(backend="espeak")
     32 audio_tokenizer = AudioTokenizer(signature=encodec_fn) # will also put the neural codec model on gpu
     34 # run the model to get the output

File ~/VoiceCraft_things/VoiceCraft-master/data/tokenizer.py:48, in TextTokenizer.__init__(self, language, backend, separator, preserve_punctuation, punctuation_marks, with_stress, tie, language_switch, words_mismatch)
     36 def __init__(
     37     self,
     38     language="en-us",
   (...)
     46     words_mismatch: WordMismatch = "ignore",
     47 ) -> None:
---> 48     phonemizer = EspeakBackend(
     49         language,
     50         punctuation_marks=punctuation_marks,
     51         preserve_punctuation=preserve_punctuation,
     52         with_stress=with_stress,
     53         tie=tie,
     54         language_switch=language_switch,
     55         words_mismatch=words_mismatch,
     56     )
...
     81 self._logger.info(
     82     'initializing backend %s-%s',
     83     'espeak', '.'.join(str(v) for v in self.version()))

RuntimeError: espeak not installed on your system

I would also really like to do it without e.g. Docker, because I want to try to use MPS for the Apple Silicon GPU.

Would appreciate any guidance on resolving this issue so that espeak is correctly recognized by the system and the notebook can run as intended.

sangfrois commented 8 months ago

https://github.com/bootphon/phonemizer/issues/44

valentinweyer commented 8 months ago

Adding this solved it:

from phonemizer.backend.espeak.wrapper import EspeakWrapper
_ESPEAK_LIBRARY = '/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.1.1.48.dylib'.  #use the Path to the library.
EspeakWrapper.set_library(_ESPEAK_LIBRARY)

Thanks.

rajpython commented 4 months ago

on macOS Sonoma 14.2.1 M1 pro

I am attempting to use phonemizer with espeak. I set the library path as above after installing phonemizer and espeak etc. I have tried all tricks but keep getting the following error despite following the thread

RuntimeError Traceback (most recent call last) Cell In[1], line 9 6 import phonemizer 8 text = "Hello, how are you?" ----> 9 phonemes = phonemizer.phonemize(text, language='en-us', backend='espeak', strip=True) 10 print(phonemes)

File ~/opt/anaconda3/envs/phenv/lib/python3.9/site-packages/phonemizer/phonemize.py:206, in phonemize(text, language, backend, separator, strip, prepend_text, preserve_empty_lines, preserve_punctuation, punctuation_marks, with_stress, tie, language_switch, words_mismatch, njobs, logger) 204 # initialize the phonemization backend 205 if backend == 'espeak': --> 206 phonemizer = BACKENDS[backend]( 207 language, 208 punctuation_marks=punctuation_marks, 209 preserve_punctuation=preserve_punctuation, 210 with_stress=with_stress, 211 tie=tie, 212 language_switch=language_switch, 213 words_mismatch=words_mismatch, 214 logger=logger) 215 elif backend == 'espeak-mbrola': 216 phonemizer = BACKENDS[backend]( 217 language, 218 logger=logger)

File ~/opt/anaconda3/envs/phenv/lib/python3.9/site-packages/phonemizer/backend/espeak/espeak.py:45, in EspeakBackend.init(self, language, punctuation_marks, preserve_punctuation, with_stress, tie, language_switch, words_mismatch, logger) 37 def init(self, language: str, 38 punctuation_marks: Optional[Union[str, Pattern]] = None, 39 preserve_punctuation: bool = False, (...) 43 words_mismatch: WordMismatch = 'ignore', 44 logger: Optional[Logger] = None): ---> 45 super().init( 46 language, punctuation_marks=punctuation_marks, 47 preserve_punctuation=preserve_punctuation, logger=logger) 49 self._espeak.set_voice(language) 50 self._with_stress = with_stress

File ~/opt/anaconda3/envs/phenv/lib/python3.9/site-packages/phonemizer/backend/espeak/base.py:39, in BaseEspeakBackend.init(self, language, punctuation_marks, preserve_punctuation, logger) 35 def init(self, language: str, 36 punctuation_marks: Optional[Union[str, Pattern]] = None, 37 preserve_punctuation: bool = False, 38 logger: Optional[Logger] = None): ---> 39 super().init( 40 language, 41 punctuation_marks=punctuation_marks, 42 preserve_punctuation=preserve_punctuation, 43 logger=logger) 45 self._espeak = EspeakWrapper() 46 self.logger.debug('loaded %s', self._espeak.library_path)

File ~/opt/anaconda3/envs/phenv/lib/python3.9/site-packages/phonemizer/backend/base.py:77, in BaseBackend.init(self, language, punctuation_marks, preserve_punctuation, logger) 75 # ensure the backend is installed on the system 76 if not self.is_available(): ---> 77 raise RuntimeError( # pragma: nocover 78 '{} not installed on your system'.format(self.name())) 80 self._logger = logger 81 self._logger.info( 82 'initializing backend %s-%s', 83 self.name(), '.'.join(str(v) for v in self.version()))

RuntimeError: espeak not installed on your system

amirvenus commented 3 months ago

Adding this solved it:

from phonemizer.backend.espeak.wrapper import EspeakWrapper
_ESPEAK_LIBRARY = '/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.1.1.48.dylib'.  #use the Path to the library.
EspeakWrapper.set_library(_ESPEAK_LIBRARY)

Thanks.

What changes did you have to make? Could you please raise a PR?

Thanks!