Speaker/Headphone Output Mixed with Mic Input Stream
See original GitHub issueIf I try to read the audio stream from microphone using sd.InputStream
when another audio is being played in the machine, it records input from both mic and speaker. Therefore, the recorded audio includes the noise of background audio along with mic input. However, I have assumed that it would record only the input from the mic which is required in my use case. Is there any workaround? My code is given below:
stream_in = sd.InputStream(
device=device_in,
samplerate=args.sample_rate,
channels=1)
stream_in.start()
frame, overflow = stream_in.read(length)
Here, I have passed the default pulse
input device (from the list below) as device_in
and sample_rate
is set to 16000.
$ python -m sounddevice
0 HDA Intel PCH: ALC3234 Alt Analog (hw:0,2), ALSA (2 in, 0 out)
1 HDA Intel PCH: HDMI 0 (hw:0,3), ALSA (0 in, 8 out)
2 HDA Intel PCH: HDMI 1 (hw:0,7), ALSA (0 in, 8 out)
3 HDA Intel PCH: HDMI 2 (hw:0,8), ALSA (0 in, 8 out)
4 HDA Intel PCH: HDMI 3 (hw:0,9), ALSA (0 in, 8 out)
5 HDA Intel PCH: HDMI 4 (hw:0,10), ALSA (0 in, 8 out)
6 hdmi, ALSA (0 in, 8 out)
7 pulse, ALSA (32 in, 32 out)
* 8 default, ALSA (32 in, 32 out)
Issue Analytics
- State:
- Created 2 years ago
- Comments:12
Top Results From Across the Web
Headphone Output/STEREO MIX To MIC Input For Recording
In this video you will learn how I take any audio /music output (L & R outputs ) going to my headphones /...
Read more >[SOLVED] - Headset mixing all output sound and microphone ...
1 Go to control panel in classic view. · 2 Open realtech audio manager utility · 3 go to the mixer tab under...
Read more >Microphone input from speaker output - audio - Super User
First option if you're running windows, is to use the stereo mix virtual device. Once it's enabled, set the microphone in ...
Read more >Using Headphone Jack as Microphone: What You Need to ...
The TRS-type plug can only be used for either microphone input or stereo audio input, and not both. This is why it's common...
Read more >How To Use Earphone as Both Input and Output of Audio in ...
This earphone I got has a 3.5 mm jack plug, and it has mic on the cable too, I was wondering how I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a similar problem ~3 years ago. I tried everything to fix it, without success… until I noticed that, under
alsamixer
controls, there was aLoopback
option enabled. After disabling it, I never had this problem again. To double check:alsamixer
;Loopback
option, make sure it is disabled.If, as @HaHeho suggested, the issue happens independently of the software used for recording, then this could be the cause of it.
Cheers 😃
Thanks for the audio examples. 😃
You indeed described accurately what you were encountering. However, it sounded very unlikely, so I wanted to make sure that we are not talking about acoustic feedback.
The behavior is of course unintended … and I have no idea why it happens. Although, I would say it is very unlikely caused by
sounddevice
. It is rather due to your code … most likely what is happening within thetorch
. I have no experience with that at all, but I could imagine it overrides the data insideframe
during the processing? So maybe also the data ininput_frames
gets altered, since it is was given a reference and not a deep-copy.But then again, I have no idea what exactly is happening in
frame = torch.from_numpy(frame).to(args.device)
(in particular the last part). Maybe an explicit deep-copy withframe = torch.from_numpy(frame.copy()).to(args.device)
already does the trick?In any case, what you should check first is that the behavior is still encountered without any
torch
processing. If not, then you know that you will have to look there. 😉