Questions tagged [python-sounddevice]
167 questions
1
vote
1 answer
The sounddevice library in Python plays music, how to control the volume of different channels
I use OutputStream in sounddevice to control the music stream and set the volume level of the different streams in its callback function. It is normal for each channel to have a volume of 0, but if I want to make one channel have sound alone, and…

keptupp
- 11
- 1
1
vote
0 answers
Using Python as a speaker to intercept audio
I'm developing an app just for me which should act like a speaker in my Windows computer and record the data being sent to it.
Here's the code so far:
import soundcard as sc
import numpy
outputLib = sc.all_speakers()
speakers = outputLib[3] …

Lamb Sauce
- 81
- 9
1
vote
1 answer
What technique is required to remove unwanted frequencies in my sine wave audio signal
I have created a sine wave that the user can change its frequency in real time using inputs of the key board, however there is a lot of noise I believe to be harmonic waves present in the audio output that I wish to remove. For this project, I…

Merkel
- 13
- 2
1
vote
0 answers
Audio Recording In Python Can't Hear Output
I found some code online that is supposed to record audio using soundfile but after creating the recording, when I play it back, I can't hear anything. However, the recording is the correct duration, I think it just isn't receiving input.
import…

Walker
- 121
- 1
- 9
1
vote
1 answer
Error when recording sound with sounddevice
I want to use sounddevice to capture (record?) audio that is coming out of my speakers. My speakers have two channels.
This is my code (which I found here https://realpython.com/playing-and-recording-sound-python/#python-sounddevice_1):
import…

koegl
- 505
- 2
- 13
1
vote
0 answers
How do you get the correct device for a sounddevice recording
I have been trying to record my device's audio, but I can't get it to work properly.
So far I have tried the following
from sounddevice import rec, default
from soundfile import write
fs = 48000 # Hz
duration = 10 # s
default.device = [6,…

INGIE
- 11
- 1
1
vote
0 answers
How to correctly make use of multithreading to run my program faster?
How can I correctly make my code run faster? Following is my attempt at making use of multithreading. However, I do not understand where to join the threads. I want the results to be printed serially, but computed parallely.
import queue
import…

rawnap
- 171
- 3
1
vote
0 answers
Using python sounddevice query string to select device
I'd like to select a particular sound device to use for audio input via python sounddevice.
The sounddevice docs make reference to using "query strings" to select devices (based on the devices "name" I'm pretty sure.) But I can't figure out how to…

Chris W.
- 37,583
- 36
- 99
- 136
1
vote
0 answers
Sounddevice - Test callback fucntion
I have some code that uses the sounddevice library in a callback function. I need to use pytest inorder to test this callback function.
I am simply trying to test if the callback function does not raise an exception.
however, pytest keeps reporting…

Wheatley
- 35
- 3
1
vote
0 answers
Expose PC playing MP3 files to Android as USB microphone
Probably an unusual request, but here goes...
I'm trying to create a script (ideally in Python, but open to other options) that will stream an mp3 file from a computer to an Android Phone's microphone input. I guess this would require exposing the…

JB515
- 13
- 3
1
vote
1 answer
How to write an audio file that is inside a for loop in python
I have to write an echo code. So I wrote this code. I want to know how to add each of these in a separate wav file. Can someone provide me with an answer. Thanks in advance.
import sounddevice as sd
from scipy.io import wavfile
import numpy as…

Nithyashri Manohar
- 11
- 1
1
vote
1 answer
Is it possible to generate sound within a Python web application deployed with Docker on Google Cloud?
I have built a simple web application, which is supposed to test hearing frequency range of the user. It is built in JustPy framework and it uses pysinewave (in turn based on sounddevice) to generate sound continuously. I have deployed it in a…

adambialy
- 13
- 3
1
vote
2 answers
PortAudioError: Error querying device -1 in google colab when using the sounddevice library
I've installed and imported all the required libraries (at least I think so):
!sudo apt-get install libportaudio2
!pip install sounddevice
import numpy as np
import matplotlib.pyplot as plt
import sounddevice as sd
And I am getting the following…

Diana
- 363
- 2
- 8
1
vote
1 answer
Sending audio data generated by python-sounddevice.RawInputStream to Google Cloud Speech-to-Text for asynchronous recognition
I'm working on a script that sends data from a microphone to Google Cloud Speech-to-Text API. I need to access gRPC API to produce live readings during recording. Once the recording is completed, I need to access REST API for more precise…

Artem Ermakov
- 101
- 7
1
vote
1 answer
When recording on python with module sounddevice it records forever
I am currently making a python script that records for a specific amount of time that the user inputs, and then encrypts it with a password.
But when I start recording, it records forever, and I have to stop the script running to stop…

itsmii
- 11
- 4