Questions tagged [winsound]

Use this tag for questions related to winsound module.

The winsound is a python module for playing sound on Windows. This API allow python script to invoke Windows system sound (e.g. SystemExit) and external wav files or memory stream.

79 questions
1
vote
0 answers

Why does Winsound have a pulse for certain frequencies?

I was trying to make music by purely using python's winsound module. However, almost every single pitch (frequency) pulsates. A few that doesn't are like A 440 or anything higher than around 2000 hertz. Is this just how winsound works or is this…
Rational
  • 19
  • 2
1
vote
0 answers

When attempting to play sound, computer continuously plays Windows Error sound

I've tried multiple forms of playing sound. I first tried using playsound. Here's my code: import playsound from playsound import playsound playsound('Sunflower.mp3') I've also attempted using winsound, although using my computer's native mp3…
1
vote
2 answers

Play Sound whenever key is pressed in Python

I am writing a Python script wherein everytime a key is pressed, a sound is played. I am using the Winsound module to play the sound, and I want something like this: import winsound while True: if any_key_is_being_pressed: # Replace this with…
ShakeyGames
  • 277
  • 1
  • 3
  • 11
1
vote
0 answers

I cannot play .wav file and a windows alert sound is played

from gtts import gTTS import winsound Text = "Hello world" Audio = gTTS(text=Text,lang="en",slow=False) Audio.save("T.wav") winsound.PlaySound("T.wav", winsound.SND_FILENAME) When the code is run there are no errors but a default windows alert…
1
vote
1 answer

Winsound python doesn't work with arrays that have been appended to

import random import winsound songsArray = [] with open("test.txt") as f: for line in f: songsArray.append(line) songAmount = len(songsArray) selectedSong = songsArray[2] print…
Garje
  • 25
  • 5
1
vote
1 answer

How do I stop sounds stacking on top of each other with winsound? (Python and tkinter)

I'm trying to create a simple soundboard in python using tkinter. My aim is to just have one button, in this instance titled "bruh", where every time the button is clicked, it plays the "bruh.wav" sound. So far it seems to work, however if I was to…
1
vote
0 answers

Python Winsound not playing WAV file

im trying to let background music play when opening my application (currently a TKinter window) I want to do that using winsound (its been the first module ive found) However, when i start my app, all it does is playing that default windows…
1Day2Die
  • 29
  • 9
1
vote
1 answer

Clock's clicking does not work in simoultaneous with countdown timer

I am using tkinter and winsound. I want the sound and the countdown timer to work simultaneously. Right now, once the clicking sound is over the timer appears. I have seen some countdown timers examples which use "after". Ex: self.after(1000,…
Aizzaac
  • 3,146
  • 8
  • 29
  • 61
1
vote
1 answer

How can I change the volume of an individual note and overlap three notes in python?

I need to create a shepard tones in python, and each tone has three notes in which one has a high volume, the second medium and the third low. How can I individually modify the volumes of these notes, and how can I play all three notes at the same…
1
vote
2 answers

using winsound, plays error sound instead of chosen sound

I am using winsound to play a swoosh sound: winsound.PlaySound("D:\GamesImade\pythonpong\bounce.wav", winsound.SND_ASYNC) When I run it with my IDE it works. But if I run the exe file by itself it doesn't work, it plays the windows error sound.
1
vote
1 answer

Behaviour of createBackgroundSubtractorMOG2 function in opencv

I am trying to create a motion detecting alarm by using the cv2.createBackgroundSubtractorMOG2() function to check for moving objects and sound an alarm. This is my code: import cv2 import numpy as np import…
1
vote
0 answers

Better sound in winsound?

I am trying to automate playing sounds using python's winsound module. I've come to the point where I can give the function any number of notes (whose names I've stored as frequencies), and a tempo in BPM. However, the default beep sound in winsound…
1
vote
1 answer

Extract a segment from a .wav file

I have the following code to load a .wav file and play it: import base64 import winsound with open('file.wav','rb') as f: data = base64.b64encode(f.read()) winsound.PlaySound(base64.b64decode(data), winsound.SND_MEMORY) It plays the file no…
magicsword
  • 1,179
  • 3
  • 16
  • 26
1
vote
1 answer

Python background sound, how to know when it stops

I'm using the winsound library to play a file asynchronously. However, I would like to know when the sound is done playing. If the sound is done, then I keep the flag set to 1. Otherwise, I set flag to 0. This is my current code: import…
1
vote
1 answer

Trouble playing long .wav files in winsound

I'm having trouble with some simple winsound code: import winsound winsound.PlaySound("song.wav", winsound.SND_FILENAME) The problem is that whenever I try to play a .wav file, all I get is a Windows error sound and then the program continues…