question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mic isn't recording audio

See original GitHub issue

This is the code (I’ve taken it from the docs)

import soundcard as sc
import numpy

# get a list of all speakers:
speakers = sc.all_speakers()
# get the current default speaker on your system:
default_speaker = sc.default_speaker()
# get a list of all microphones:
mics = sc.all_microphones()
# get the current default microphone on your system:
default_mic = sc.default_microphone()

data = default_mic.record(samplerate=48000, numframes=48000)
default_speaker.play(data/numpy.max(data), samplerate=48000)

when I run the code the sound does not play. At first I thought this was a problem with the speaker object but then I tried playing a saved wav file separately using the speaker object and it worked but when I try to play the mic input there is no sound output, also there is this warning

/Users/faizrahim/PycharmProjects/voice-lag-simul/writejson.py:15: RuntimeWarning: invalid value encountered in true_divide
  default_speaker.play(data/numpy.max(data), samplerate=48000)

The data variable when printed returns an array with nothing other than 0.0

[[0.]
 [0.]
 [0.]
 ...
 [0.]
 [0.]
 [0.]]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
alfonsocv12commented, May 21, 2022

Yes the real problem is the most common places where people run their scripts on macos is from vscode (that has a well documented bug since macos Mojave) and iterm that also doesn’t ask for permission.

I try to fix this at script level so that soundcard ask for it regardless of the top application in the meantime I add the workaround to the readme.

0reactions
alfonsocv12commented, Jul 28, 2022

I’m ok with closing this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microphone not picking up voice [Solved] - Driver Easy
Troubleshoot mic problems · Method 1: Update your audio driver. A missing or outdated audio driver may stop mic from picking up voice....
Read more >
How to Fix Windows 10 Voice Recorder Not Working
1. Update Windows Driver · 2. Make Sure Microphone is Enable · 3. Adjust Microphone Levels · 4. Select the Correct Recording Device...
Read more >
What To Do If Your Mic is Not Working on Windows 10 - A Guide
You can go to Control Panel > Hardware and Sound > Sound where you can find the headset listed in the recording devices...
Read more >
No Sound When Screen Recording on Windows 10
How to fix the Windows voice recorder not working? · 1. Enable microphone/recording device · 2. Update your drivers · 3. Grant audio...
Read more >
How to Fix It When a Windows 10 Microphone is Not Working
Run the Windows 10 troubleshooter. · Look for a Mute button. · Check your connections. · Check individual app settings. · Change your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found