I've a problem with Playsound and i don't know why... for me it's not understandable...
The code
from playsound import playsound
playsound(r"C:\\Users\\Toto\\Desktop\\songs\\dring.mp3")
It's work i'm happy, now i copy/paste the same directory (songs\dring.mp3) away from the desk for example my usb device (or other, no matter where i put it)
On my code i change the path
from playsound import playsound
playsound(r"D:\\songs\\ding.mp3)
i've always this error
Error 259 for command:
the driver cannot recognize the specified command parameter.
It's work only my desktop, elsewhere it does not work.. can you help me?
Thank
I found the solution...
you need to uninstall playsound 1.3.0 using :
pip uninstall playsound
(press y to proceed)
Then uninstall the old and pure version of playsound by this command :
pip install playsound==1.2.2
It worked perfectly for me
Related
I've been using the Python playsound module to play audio, and in VScode it works great, but when I play it outside of VScode in the console instead of the audio playing like usual, I get an error saying:
ModuleNotFoundError: No module named 'playsound'
I write in from playsound import playsound to import the module, and if I just try and write, import playsound, it doesn't even work in VScode, saying "'module' object is not callable".
I've uninstalled and reinstalled the new version, uninstalled and reinstalled version 1.2.2, and I'm beginning to lose hope with playsound. Has anyone out there experienced this?
At first, second part of your question:
You cannot just
import playsound
playsound(...)
because playsound is a module in this case, which is not callable (as the interpreter told you).
you need to import function playsound from the module, that is why
from playsound import playsound
playsound(...)
works.
First part of your question:
It might be possible vscode is using another version of python from one you're calling from the command line. Without more information about your environment setup I can only guess. Try to do this:
$ python -m pip install playsound
then
$ python -m playsound "path-to-your-mp3-file.mp3"
that should work without a problem.
I found out what was causing the problem. I had to edit the environment variables that point to pip and it started to work again.
So basically I was trying to create a music playing program that would play music when you asked it to. I was just trying to get the song playing portion to actually work, so I wrote a super simple code to test it out:
import playsound
playsound('sample.mp3')
This was done in replit, and I added the mp3 file into the files section
when I hit run, it gives me TypeError: 'module' object is not callable. What can I do to fix this?
you need to install the PyObjC by writing below command.
if you are using python version 3
pip3 install PyObjC
if you are using python version 2
pip install PyObjC
After that you write below code in your terminal
from playsound import playsound
playsound("path of your audio file/testing_audio_file.mp3")
if you are facing any issue regarding path then use below pattern for (use two forward slash) Windows
playsound("D:\\path_of_your_audio_file\\testing_audio_file.mp3")
Replace
import playsound
with...
from playsound import playsound
I have been trying to add sound to my python code. I tried using playsound, pygame, pydub and tkinter but in vsc it doesn't let me install any using the command pip3 install pygame...(and so on)
here I have tried it with pydub but this sais that there is no module named pydub and it doesn't let me install it. Can someone help me add this sound to my code?
from pydub import AudioSegment
from pydub.playback import play
psong = AudioSegment.from_mp3("song.mp3")
play(song)
I have two suggestions for this issue:
Install pyaudio (pip3 install pyaudio) as this is the best module that pydub uses.
Change your audio file format to wav instead of mp3 and also change this section of code: psong = AudioSegment.from_mp3("song.mp3") to psong = AudioSegment.from_wav("song.wav").
Source for answer
from playsound import playsound
from gtts import gTTS,gTTSError
def playaudio(audio):
playsound(audio)
def convert_to_audio(text):
audio =gTTS(text)
>- audio.save("textaud.mp3") -<
playaudio("textaud.mp3")
convert_to_audio("my name is joe")
I'm using Anaconda Environments.
I'm getting a error in highlighted line.
That error is:Failed to connect. Probable cause: Unknown
https://i.stack.imgur.com/wZMVI.png
The solutions I tried:
Updated Windows
Uninstalled and Reinstalled gTTS
So I have used gtts in a recent project and one thing I noticed is that I get this error every time I run my code without an internet connection. As soon as my device is connected, it works fine for me. Even the code you provided worked as it should (after correcting the indentation and deleting ">-" from your save audio command), so be sure to be connected to the internet. Hope this'll help!
Try doing this.
from playsound
from gtts import gTTS
def playaudio(audio):
playsound(audio)
def convert_to_audio(text):
audio =gTTS(text=text, lang='en', tld='com')
audio.save("textaud.mp3")
playaudio("textaud.mp3")
convert_to_audio("my name is joe")
So, I'm trying to make a simple keylogger and I have this next bit of code:
try:
import pyHook, pythoncom
except:
os.system("pip install pypiwin32")
os.system("pip install pyHook")
import pyHook, pythoncom
the installation of pypiwin32 works, and after doing the command
os.system("pip install pypiwin32")
I can use pythoncom.
however, the second command doesn't seem to work.
I want this to work on every computer, hence - without a need to download a whl file. is it possible to install pyHook like that?
thanks.
I mean. Your asking people to help you to essentially steal stuff. But sure I'll help. https://pypi.python.org/pypi/keyboard/
Check this out
I don't think your code would 100% work on an pcs.