Python Forum
How to change the sound volume with python ?
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change the sound volume with python ?
#1
Hello, I'm new here !

My hobby is microcontrollers and now I'm doing a project where I could change the sound volume with buttons on my breadboard. I tried a program which can open a website by pushing a button on the breadboard which I took from the book that I read.


Here is that program from the book called "Make: AVR programming" by Elliot Williams

## Simple demo
## Sits forever listening to serial port
## When you press button, opens website of your choosing.
## Extend this to many buttons and you'll have a physical
##  web-launcher.  

BOSS_SITE = "http://animal-dream.com/data_images/badger/badger1.jpg"
## or perhaps more topical...
XKCD = "http://xkcd.com/353/"

SERIAL_PORT = "COM5"
BAUD_RATE = 9600

import serial
import webbrowser

sp = serial.Serial(SERIAL_PORT, BAUD_RATE, timeout = 5)
sp.flush()
print ("Boss Button")

while(1):                       # Sit and wait forever
    response = sp.read(1)       # get one byte
    if response == "O":
        print "Got OK Byte.  Waiting for button press."
    elif response == "X":
        print "Got Boss Byte!  Alarm!"
        webbrowser.open(BOSS_SITE)
    else:
        print "Got nothing.  Still waiting."
How do I change this code so I can change the sound volume on my computer ? I use windows 7.
likes this post
Reply


Messages In This Thread
How to change the sound volume with python ? - by Lightningwalrus - Sep-30-2016, 05:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Calculate the volume of piles of materials using aerial drone images WtonS 0 680 Oct-29-2024, 09:21 PM
Last Post: WtonS
  mute spotify by the mixer of volume garze23 0 981 Feb-27-2024, 05:42 PM
Last Post: garze23
  Image to Sound Python Project ankitdixit 1 4,503 Jul-26-2021, 08:20 PM
Last Post: snippsat
  Real Time Audio Processing with Python Sound-Device not working Slartybartfast 2 6,898 Mar-14-2021, 07:20 PM
Last Post: Slartybartfast
  Play fixed frequency sound in python 3 jpezz 2 4,161 Feb-07-2021, 08:21 PM
Last Post: jpezz
  Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable kmarien 3 5,300 Nov-30-2020, 04:10 PM
Last Post: buran
  Create a 3D volume with some properties. Rosendo 0 2,008 Jul-18-2020, 08:20 PM
Last Post: Rosendo
  Windows Volume Control using python Arun 1 5,725 May-17-2019, 02:50 PM
Last Post: Larz60+
  Working with large volume of data (RAM is not enough) evonevo 6 5,671 Oct-21-2018, 09:24 PM
Last Post: Larz60+
  Change Windows Sound Output Device with Python delfar 1 12,262 Sep-15-2017, 12:11 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020