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

No sound output on Linux Mint #575

Open
ullix opened this issue Dec 26, 2024 · 2 comments
Open

No sound output on Linux Mint #575

ullix opened this issue Dec 26, 2024 · 2 comments

Comments

@ullix
Copy link

ullix commented Dec 26, 2024

Using sounddevice in Python 3.11.2 on Linux Mint LMDE6 (based on debian12) but not getting any sound output using this simple test program:

import sounddevice as sd
import soundfile   as sf

path = "gres/bip.wav"

print("sounddevice")
data, samplerate = sf.read(path)
sd.play(data, samplerate)
sd.wait()

No error message of any kind. It works well when using playsound3 instead.

And both work well on Win11 Pro 23H2.

@ullix
Copy link
Author

ullix commented Dec 26, 2024

Just a thought: does sounddevice require pulseaudio, or does it work just as well with pipewire?

@iplayfast
Copy link

iplayfast commented Jan 21, 2025

I'm on linux mint 22 (wilma) and it works.
This file produces sound on my machine. #578

import numpy as np
import sounddevice as sd
import time
# Configuration
sample_rate = 44100  # Sampling frequency
frequency = 1000  # Frequency of the beep (Hz)
beep_duration = 0.2  # Duration of each beep (seconds)
pause_duration = 0.5  # Duration of silence between beeps (seconds)
num_beeps = 4  # Number of beeps

# Generate one beep
t_beep = np.linspace(0, beep_duration, int(sample_rate * beep_duration), endpoint=False)
beep = 0.5 * np.sin(2 * np.pi * frequency * t_beep)  # Amplitude = 0.5

# Generate silence
silence = np.zeros(int(sample_rate * pause_duration))

# Concatenate beeps and silence into a single sample
pattern = [beep, silence] * (num_beeps - 1) + [beep]  # No silence after the last beep
audio_sample = np.concatenate(pattern)

# Play the sample
print("playing 4 beeps with blocking = True (I hear 3)")
sd.play(audio_sample, sample_rate, blocking=True)
time.sleep(1)
print("playing 4 beeps again with blocking =True  (this time I hear 4)")
sd.play(audio_sample, sample_rate, blocking=True)

print("playing 4 beeps with blocking =False (I hear 1 to 2 all run together)")
sd.play(audio_sample, sample_rate, blocking=False)
time.sleep(1)
print("playing 4 beeps again with blocking = False (this time I hear ?)")
sd.play(audio_sample, sample_rate, blocking=False)

print("last time playing 4 beeps with blocking = True (I hear 4)")
sd.play(audio_sample, sample_rate, blocking=True)
time.sleep(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants