4

I'm trying to use pyaudio to record some speech but I can't seem to figure out how to record anything on a Mac running Mojave. I think that you have to allow access to the microphone on a mac but I'm not sure how.

babyDev
  • 415
  • 5
  • 8
  • What have you already tried, and what errors if any are you encountering? – TheLazyScripter Sep 15 '19 at 02:17
  • Post the current code you have for accessing the mic. – Gino Mempin Sep 15 '19 at 02:21
  • Nothing happens. It's just a bank recording – babyDev Sep 15 '19 at 02:43
  • [Please see my answer to this post](https://stackoverflow.com/questions/58433344/recording-or-playing-audio-with-python-not-working-on-mac-no-errors-no-sound/58469236#58469236) – kemaru Oct 20 '19 at 01:03
  • [Please see my answer to this post](https://stackoverflow.com/questions/58433344/recording-or-playing-audio-with-python-not-working-on-mac-no-errors-no-sound/58469236#58469236) – kemaru Oct 20 '19 at 01:05

2 Answers2

5

Met same problem on Mac Mojave. Solved by running the python script with 'Terminal', it will ask the access for microphone.

enter image description here

Yongke
  • 318
  • 3
  • 5
0

For those who use PyCharm as their IDE, you follow these steps:

  1. Run your microphone-using python script in Terminal (as @Yongke suggested)
  2. Once prompted, allow Terminal to access Microphone
  3. Close running PyCharm instances
  4. Open PyCharm from terminal
cd /Applications/PyCharm\ CE.app/Contents/MacOS/
./pycharm
  1. Now your recording app should work

Further explaination
Every App running on recent macOS versions needs explicit permissions to use the microphone. PyCharm doesn't request these permissions upon usage, i.e. when you run your script trying to record, and you cannot manually add a program to Mac's Microphone white-listed apps. This means you cannot access the microphone via PyCharm unless you run it within a white-listed app such as Terminal.

Sahar
  • 436
  • 1
  • 4
  • 15
  • 1
    PyCharm recent update fixes this issue by asking for permissions, which means you can avoid my workaround by downloading it https://www.jetbrains.com/pycharm/download/#section=mac – Sahar Feb 15 '21 at 15:42