Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to play a mp3 file in python

from pygame import mixer#if this module in not installed then install it by pip install pygame
mixer.init()
mixer.music.load('alarm.mp3')
mixer.music.play()
Comment

how to play mp3 audio in python

#TO playsound in your python code you need to install play sound module.
# To install playsound moudule-
#(1). Open Terminal 
#(2). "In terminal only" type "pip install playsound"
# After installing playsound you need to write-
import playsound from playsound
# syntax of playsound command
playsound("C:file_linkfile_name")
# note: ````in python you need to specify path using double back slashes "",
# instead of single forward or back slash````
# please read the starting comment lines they are very useful(ignore if readed)
# Enjoy :)
Comment

play mp3 file python

from playsound import playsound
playsound(r"C:path	osong")
Comment

Python How To Play Mp3 File

import pygame
pygame.mixer.init()
pygame.mixer.music.load('sample.mp3')
pygame.mixer.music.play()
Comment

Play Mp3 Files With Python Using the playsound Package

# If you don’t have the playsound package installed on your system,
# you can install it with the command:

"""
$ pip install playsound
"""

import playsound

playsound.playsound('sample.mp3')
Comment

Play Mp3 Files With Python Using webbrowser Package

import webbrowser

webbrowser.open("sample.mp3")

# If you don’t have mpg123 installed on your Linux system,
# you can install it using the following command:

"""
$ sudo apt install mpg123
"""

# For macOS, we use the following code snippet to play an mp3 file using
# os package in Python.


import os

os.system("afplay " + "sample.mp3")
Comment

PREVIOUS NEXT
Code Example
Python :: pandas set condition multi columns 
Python :: how to delete a csv file in python 
Python :: html to docx python 
Python :: pytorch l2 regularization 
Python :: small factorial codechef solution 
Python :: plotly line plot 
Python :: runtime.txt heroku python 
Python :: unix command in python script 
Python :: python ascii 
Python :: joblib 
Python :: python while not 
Python :: ursina python 
Python :: pygame music player 
Python :: python path zsh mac 
Python :: python currency 
Python :: How to draw a rectangle in cv2 
Python :: pre commit python 
Python :: python datetime format 
Python :: how to find empty rows of a dataset in python 
Python :: left join outer apply 
Python :: create an empty dataframe 
Python :: Renaming an index in pandas data frame 
Python :: plot.barh() group by 
Python :: Custom emoji in embed discord.py 
Python :: python close file 
Python :: check missing dates in pandas 
Python :: python timestamp to datetime 
Python :: nohup python command for linux 
Python :: imblearn randomoversampler 
Python :: are tuples mutable 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =