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

Speech Mode not working: ModuleNotFoundError: No module named 'AppKit' #2810

Closed
andrewbaisden opened this issue Apr 21, 2023 · 4 comments
Closed
Labels

Comments

@andrewbaisden
Copy link

I have an M1 MacBook Pro and I get this error when I try to use Speech Mode:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/andrewbaisden/Desktop/autogpt-app/Auto-GPT/autogpt/speech/say.py", line 33, in speak
    success = VOICE_ENGINE.say(text, voice_index)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrewbaisden/Desktop/autogpt-app/Auto-GPT/autogpt/speech/base.py", line 33, in say
    return self._speech(text, voice_index)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andrewbaisden/Desktop/autogpt-app/Auto-GPT/autogpt/speech/gtts.py", line 20, in _speech
    playsound("speech.mp3", True)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/playsound.py", line 55, in _playsoundOSX
    from AppKit     import NSSound
ModuleNotFoundError: No module named 'AppKit'

I tried installing these packages and still had the same error.

pip install pyobjc
pip install AppKit

I also get this error when trying to update the playsound package to 1.3.0. Only 1.2.2 will install all other versions fail https://pypi.org/project/playsound/#history

Collecting playsound==1.3.0
  Using cached playsound-1.3.0.tar.gz (7.7 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/z6/fx2tpl_x3mvgnbqqtfc3rzvh0000gn/T/pip-build-env-rxi4q83a/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/z6/fx2tpl_x3mvgnbqqtfc3rzvh0000gn/T/pip-build-env-rxi4q83a/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/z6/fx2tpl_x3mvgnbqqtfc3rzvh0000gn/T/pip-build-env-rxi4q83a/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 488, in run_setup
          self).run_setup(setup_script=setup_script)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/z6/fx2tpl_x3mvgnbqqtfc3rzvh0000gn/T/pip-build-env-rxi4q83a/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 6, in <module>
        File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1262, in getsource
          lines, lnum = getsourcelines(object)
                        ^^^^^^^^^^^^^^^^^^^^^^
        File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1244, in getsourcelines
          lines, lnum = findsource(object)
                        ^^^^^^^^^^^^^^^^^^
        File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1081, in findsource
          raise OSError('could not get source code')
      OSError: could not get source code
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

These issues are related:

OSError: Unable to load sound #856

In speak mode: ModuleNotFoundError: No module named 'gi' #1697

--speak mode not working #483

The Speech Mode worked in this previous build but not the latest one I have only been able to get the text mode to work.

@andrewbaisden
Copy link
Author

andrewbaisden commented Apr 21, 2023

I solved it and found a working solution.

If pyobjc is already installed and you still can't see the AppKit module, there might be an issue with your Python environment or installation. In this case, consider creating a new virtual environment or reinstalling Python to ensure a clean setup.

I have Python 3.11 downloaded and installed from https://www.python.org/. Using the command which python3 will show you where it's installed on your computer.

To create a new virtual environment, run:

/Library/Frameworks/Python.framework/Versions/3.11/bin/python3 -m venv my_new_env
source my_new_env/bin/activate
pip install pyobjc

Then install the packages in the new virtual environment:

pip install -r requirements.txt

Then run it in Speech Mode:

python3 -m autogpt --speak

To get custom ELEVENLABS voices ass these to the .env file and make sure you put the IDs in the right place.

### ELEVENLABS
## ELEVENLABS_API_KEY - Eleven Labs API key (Example: my-elevenlabs-api-key)
## ELEVENLABS_VOICE_1_ID - Eleven Labs voice 1 ID (Example: my-voice-id-1)
## ELEVENLABS_VOICE_2_ID - Eleven Labs voice 2 ID (Example: my-voice-id-2)
ELEVENLABS_API_KEY=YOUR API KEY
ELEVENLABS_VOICE_1_ID=21m00Tcm4TlvDq8ikWAM
ELEVENLABS_VOICE_2_ID=AZnzlk1XvdvUeBnXmlld

@wirunw
Copy link

wirunw commented May 29, 2023

It work, Thank you very much @andrewbaisden

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2023

This issue has automatically been marked as stale because it has not had any activity in the last 50 days. You can unstale it by commenting or removing the label. Otherwise, this issue will be closed in 10 days.

@github-actions github-actions bot added the Stale label Sep 6, 2023
@github-actions
Copy link
Contributor

This issue was closed automatically because it has been stale for 10 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants