简体   繁体   English

如何在Python中播放声音而无需下载任何内容

[英]How do you play sound in Python WITHOUT downloading anything

I have been looking for ages on ways to find out how to make idle python play sound such as wav. 我一直在寻找方法来寻找如何使诸如wav之类的空闲python播放声音的年龄。

The solutions I have found are used by programs such as pygame. 我发现的解决方案被pygame之类的程序使用。 I can't download pygame or any other program. 我无法下载pygame或任何其他程序。

Many thanks 非常感谢

To play a sound without downloading anything, you use the code: 要播放声音而不下载任何内容,请使用以下代码:

import winsound

winsound.PlaySound('FILENAMEHERE.wav', winsound.SND_FILENAME)

keep everything the same apart from FILENAMEHERE 除了FILENAMEHERE外,其他所有内容均保持相同

Why are you unable to download anything? 为什么无法下载任何内容? https://pypi.python.org/pypi/playsound/1.2.1 - link for playsound module it is very easy to download. https://pypi.python.org/pypi/playsound/1.2.1-播放模块的链接,非常容易下载。 You can download it using pip by navigating with cmd to your python folder (usualy C:\\Users\\UserName\\AppData\\Local\\Programs\\Python\\Python35-32) and writing: python -m pip install playsound (if you are using python 3). 您可以通过使用cmd导航到您的python文件夹(通常为C:\\ Users \\ UserName \\ AppData \\ Local \\ Programs \\ Python \\ Python35-32)并使用以下命令来使用pip下载它:python -m pip install playsound(如果您使用的是python) 3)。 I think that is the easiest and the fastest way for you to play sound if you have any other questions about this let me know. 如果您对此还有其他疑问,我认为这是您播放声音的最简单,最快的方法。

ps If you need to you can download pip here: https://pip.pypa.io/en/stable/installing/https://pip.pypa.io/en/stable/installing/ Hope I was helpful. ps如果需要,可以在此处下载pip: https ://pip.pypa.io/en/stable/installing/https: //pip.pypa.io/en/stable/installing/希望我有所帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM