Python playsound - play mp3 sound files - CodersLegacy
文章推薦指數: 80 %
The Python playsound library offers an easy and simple way to play sound files in Python. From all the sound libraries, this is the simple... Skiptocontent(PressEnter) CodersLegacyImpartingknowledgetotheFutureSearchfor: HOMEINTRODUCTIONPYTHONGettingstarted–PythonPythonBasicsPythonIntermediatePythonAdvancedPythonLibrariesPythonProblemSolvingPythonBuiltinFunctionsJAVAGettingStarted–JavaJavaBasicsJavaAdvancedVB.NETGettingStarted–VB.NETVB.netBasicsVB.NETAdvancedC++GettingStarted–C++C++BasicsC++Advanced[email protected]Pythonplaysound–playmp3soundfilesreportthisad reportthisad reportthisadThisarticlecoversthePythonplaysoundlibrary.It’sfairlycommontoseetheuseofmp3filesinvariouskindsofsoftwareandgames,rangingfromsimple1secondsoundeffectstohourlongsoundtracks.ThePythonplaysoundlibraryoffersyouaeasyandsimplewaytoplaysoundfilesinPython.ThereareotherlibrariesthatcanalsobeusedsuchasPygame,simpleaudioandwinsoundbutplaysoundisbyfarthemostsimplestandeasytouse,thoughitonlyoffersasinglefeature,whichisthesimpleplaybackofasoundfile.Beforeyouproceedanyfurther,makesureyoudownloadtheplaysoundlibraryfromthecommandpromptusingthepipinstallplaysoundcommand.PythonPlaysoundWe’llbeusingasamplemp3fileforthisexercise,whichyoucanobtainusingthisdownloadlink.Nextupwe’llimporttheplaysoundfunction,fromtheplaysoundmoduleusingthefollowingstatement.fromplaysoundimportplaysound Toplaythesound,wejustneedasinglefunction,withasinglelineandasingleparameter.playsound('example_MP3.mp3') Calltheplaysoundfunction,withthefilepathofthesoundfilepassedintotheparameter.SinceourPythonscriptandsoundfilewereinthesamelocation,wesimplypassedthesoundfilename.Andthat’sit.Yoursoundfilewillbegintoplayandwillendonceit’sdoneplaying.Ifyouwerehopingforsomethingwithmorecontrolthesoundfileplaying,youcanlookuponeoftheothersoundplayinglibrariesinpython.IfyoureceiveaApp-kiterror,installthePyObjClibraryfromthecommandprompt.AlternativesIfyou’relookingforasoundlibrarywithmorecomplexityandfeaturesthanplaysound,tryoneofthebelowaudiolibraries.PyAudioSimpleAudioPygameMixerThismarkstheendofthePythonplaysoundlibrary.AnysuggestionsorcontributionsforCodersLegacyaremorethanwelcome.Questionsregardingthearticlecanbeaskedinthecommentssectionbelow.reportthisadSubscribeLoginNotifyofnewfollow-upcommentsnewrepliestomycommentsLabel {} [+] Name* Email* Website Label {} [+] Name* Email* Website 0CommentsInlineFeedbacksViewallcommentsSearchfor: ProgrammingLanguagesPYTHONTUTORIALSPYTHONLIBRARIESwpDiscuzInsertx
延伸文章資訊
- 1Trying to play an MP3 through python with playsound. Not ...
#!/usr/bin/env python # import required module from playsound import playsound # for playing note...
- 2Python实用模块(二十九)playsound - 迷途小书童的Note - 编程
playsound 支持多平台,仅仅依赖于 python 。 安装. 官方给出的安装方法是 pip install playsound. 但是我在执行的时候, ...
- 3python-playsound-git - AUR (en) - Arch Linux
Package Details: python-playsound-git 1.3.0-5 ... Description: Pure Python, cross platform, singl...
- 4Python playsound - play mp3 sound files - CodersLegacy
The Python playsound library offers an easy and simple way to play sound files in Python. From al...
- 5Play sound in Python - GeeksforGeeks
Play sound in Python · The playsound module contains only a single function named playsound(). · ...