Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mac compatability. #9

Closed
wants to merge 4 commits into from
Closed

Conversation

johnrtipton
Copy link

DRAFT:
Add Mac compatibility, I need to do some cleanup still, this is a rough implementation.

@johnrtipton johnrtipton marked this pull request as draft May 1, 2024 15:48
self.libc.open_memstream.restype = ctypes.POINTER(ctypes.c_char)
self.lib_espeak = self._load_library("libespeak-ng.so", "libespeak-ng.so.1")
#self.lib_espeak = self._load_library("libespeak-ng.so", "libespeak-ng.so.1")
self.lib_espeak = self._load_library("libespeak.dylib", "libespeak.1.dylib")
Copy link

@Traxmaxx Traxmaxx May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What worked for me on MacOS was

import platform
[...]
self.lib_espeak = ctypes.cdll.LoadLibrary("libespeak-ng.{}".format("so.1" if platform.uname()[0] != "Darwin" else "dylib"))

Still need to test on linux, will do later today
This change allowed me to actually get voice working on MacOS somewhat, but I now run into the following error:

Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 0000 for phoneme 'f?'
Invalid instruction 4801 for phoneme 'f?'
Invalid instruction 0007 for phoneme '�O�'
Invalid instruction 7878 for phoneme '�O�'
Invalid instruction 5a4b for phoneme '�O�'
Invalid instruction 0000 for phoneme '�O�'
Invalid instruction 0028 for phoneme '�O�'
Invalid instruction 0000 for phoneme '�O�'
Invalid instruction 0000 for phoneme '�O�'
Invalid instruction 0000 for phoneme '�O�'
Invalid instruction 0000 for phoneme '�O�'
Invalid instruction 0000 for phoneme '�O�'
Invalid instruction 00fa for phoneme '�O�'
Invalid instruction 000c for phoneme '�O�'
Invalid instruction 0003 for phoneme '�O�'

YMMV

@Traxmaxx
Copy link

Traxmaxx commented May 3, 2024

Installing espeak-ng through homebrew and doing the mentioned change above, espeak is not directly crashing and works for some time until I run into mentioned error. I'm still investigating what is happening there.
Any clues?

@@ -216,9 +218,11 @@ class Phonemizer:
espeakVOICE = "en-us"

def __init__(self):
self.libc = ctypes.cdll.LoadLibrary("libc.so.6")
# self.libc = ctypes.cdll.LoadLibrary("libc.so.6")
self.libc = ctypes.cdll.LoadLibrary("libc.dylib")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did self.libc = ctypes.cdll.LoadLibrary("libc.{}".format("so.6" if platform.uname()[0] != "Darwin" else "dylib"))
to support both

@Traxmaxx Traxmaxx mentioned this pull request May 3, 2024
@fonix232
Copy link

fonix232 commented May 3, 2024

I've been doing some refactor locally, which I think could go into this PR.

Instead of relying on manually compiled and installed libraries, my suggestion would be an init script that:

  1. Enters a Python venv
  2. Checks for libwhisper, if not found, pulls the git repo, builds it, and copies the appropriate files into a local path
  3. Checks for libespeak-ng, if not found, pulls the git repo, builds it, and copies the appropriate files into a local path
  4. Checks for llama.cpp, and you guessed it right, if not found, pulls the git repo, builds it, and copies the appropriate files into a local path
  5. Installs all Python dependencies
  6. Starts the main app

Optionally it could also prompt for installing the make/cmake/etc. build tools as needed, though with all the different distros, this might be a task a smidge too big.

I'd also go for masking ctypes.cdll.LoadLibrary with a custom method that takes care of the dylib or so checking (note that e.g. libwhisper still builds a .so file on macOS, so on Darwin platforms it's best to check first for dylib then for so and only if neither are found, throw the exception).

@fonix232
Copy link

fonix232 commented May 3, 2024

@dnhkng please see my above comment to expand on the discussion under #11

@dnhkng
Copy link
Owner

dnhkng commented May 11, 2024

We now use the espeak-ng binary, as it resolves the segfault issues, so I am closing this,

@dnhkng dnhkng closed this May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants