I'm trying to use playsound to play a file within the folder of my code, however every time I run my code it seems it is able to call the file however I always receive this output:
playsound.PlaysoundException:
Error 277 for command:
open "para.mp3" alias playsound_0.9208788744295284
A problem occurred in initializing MCI.
The code that is run is just the use of the playsound function:
from playsound import playsound
playsound("01. Humongous.mp3")
I'm unsure if this is just an issue with my machine or something that I'm missing?
Convert the mp3 file to wav. Worked for me.
Managed to fix it. After hours of ripping my hair out I eventually tried a different file to play and it worked. Not actually sure if there is a bitrate limit with the playsound library but it certainly didn't like that particular file. Tried another file with a lower bitrate and it worked fine.
I also faced the same issue it is not with the bit rate of the file, it seems to be the tags in the music file like "track title, cover art, album name, encoding" and so on is causing it so I would like to recommend you to remove these tags and leave it as such, to do this editing I used mp3tag application you can get it from here. This worked for me. You can check instructables to know how to use this application to edit tags.
If you want those tags you can type it out and check if again the problem arises if it does then don't add the tags.
Try removing the period from the filename you're playing and try again. I don't know what system you're running this on, but it might be interfering with the file reading process.
In playsound,for (.mp3)
you can't directly upload the customized mp3 file because of some issue in bit initailizaing.
To solve this issue,
We need to change our .mp3 file to .mp3 format again on some audio converter application or online converter. Now converted mp3 file can be flawlessly accessed for playsound.playsound(dir/users/converted/song.mp3).Enjoy it..
Related
I'm having problems finding a solution to play a mp4 file with psychopy.
Should I put the file in a special folder? How can I find this folder? And is there a special function to open then the file when running the code?
I tried making a class, but I have problems when defining the path.
Please taking in consideration that I just started programming.
Probe-Code
Thanks in advance
import playsound
playsound.playsound('sample.mp3')
Process to play this song: first create a file play.mp3 and copy the path of file and paste that code on the place of sample.mp3 in your code editor.
I am doing Ai research. I have been using pyttsx3 for the voice. The pyttsx3 function does not produce visemes. It does produce limited timing for each word. I intend to make a function that take in the text, then produce the visemes for animation of an avatar. The problem is that the data is trapped in the engine. I wanted to save the audio to a file, then load and extract it. The problem is that the save_to_file appears to be a dummy function. I have spent days researching it and the best that I have gotten are files with 0 (zero) bytes. What is going on?
I came across this when searching for solutions to the same problem.
Eventually, what I noticed was that it was to do with the file name. When I chose the file name to be 'test.mp3' or 'name.mp3', it saved properly, but if I changed the name to 'text.mp3' or basically anything else while keeping everything else exactly the same, it produced a file of zero bytes in size.
When I saved it to a different folder but the same name, e.g. 'folder/test.mp3', then it also failed, presumably because it's the full absolute path name which matters.
My hack/workaround was to just always use the file name 'test.mp3' in the same directory, and then use python's os module to move it or change the name immediately afterwards, e.g.:
engine.save_to_file(text, "test.mp3")
os.rename("test.mp3", "folder/nameIwanttogive.mp3")
So 'test.mp3' seemed to work for me. Maybe see what works by initially copying and pasting some demo code from a website.
I had the same problem, it was because i forgot a litle thing:
engine.save_to_file('hello', 'test.mp3')
it just for preparation, to implement everything use the code:
import pyttsx3 as tts
engine=tts.init()
engine.save_to_file('hello', 'HelloSound.mp3')
engine.runAndWait() # implement everything
I just update my pyttsx3 to 2.90 and started to work!! Just reinstall!
try:
pip uninstall pyttsx3
and than:
pip install pyttsx3
Recently followed a short Python bootcamp and have been trying to work on it myself a bit more, but get stuck at the start. We need to upload the data, but for some reason I can't get it to work. In the example it was done like this:
Correct way apparently
So I figured it was just about the file path, so tried to copy that but don't get it to work
My wrong attempt
Any help would be thoroughly appreciated!
Did you try saving the notebook in the same directory where the CSV file exists and use a relative path to import the CSV?
data/titatic.csv
or
titatic.csv
I have been having some issues for the past few days to get this to work. All I need is to learn it once to get it later. So what I need is a good example of working source code to play a simple wav file. I do not want to use an external library only to get this to work. I honestly don't see the point in getting a huge library to substitute for one problem :/. So if I can get a (Once again, NON-EXTERNAL) example, that would be great. (I'm using windows, so winsound should work, but I can't get the winsound.PlaySound('Example'.wav, SND_FILENAME) thing to work.) Thanks!
I'm learning how to program in Python, and have been going through Langtangen's A Primer on Scientific Programming with Python. The book refers to a website that has book examples or working code samples/programs posted there (http://hplgit.github.io/scipro-primer/), and among those are also a couple that use SciTools (EasyViz), generate a couple of plots and then try to save them in a .gif file (which is the default output format for a movie, I guess).
The problem is that I get an error when I run the programs. I see the evolution through changing figures, but at the end when the program is supposed to save those .png files into a movie, I get the following error message:
Found 73 files of the format tmp_*.png.
scitools.easyviz.movie function runs the command:
convert -delay 50 tmp_*.png tmp_heatwave.gif
Invalid Parameter - 50
scitools.easyviz.movie could not make movie
Traceback (most recent call last):
File "D:\Workspaces\Eclipse Python Workspace\Book Examples\src\plot\heatwave.py", line 41, in <module>
output_file='tmp_heatwave.gif')
File "C:\Python27\lib\site-packages\scitools\easyviz\movie.py", line 1151, in movie
me.encode()
File "C:\Python27\lib\site-packages\scitools\easyviz\movie.py", line 153, in encode
raise SystemError('Check error messages from the encoder in the terminal window')
SystemError: Check error messages from the encoder in the terminal window
I looked at the code in the movie module and the parameter 50 seems to refer to the delay in fps. For example, in another sample program, it's set to 4, and you also get the same return message. And if I delete that delay line in the module implemented in the SciTools bundle itself, the error would read:
Invalid Parameter - tmp_heatwave.gif
Can anyone tell me what's going on? I didn't change the code and I'm sure it's correct, yet I can't save movies as I'm supposed to!
I ran into the same trouble (also learning from the same book).
For me it happened when I ran the bisection_movie.py file.
In my case the way I solved it was the following way:
In the following website they mention that I needed to have the software ImageMagick installed, so I installed it following the instructions listed here.
Then after that I installed the python interface with ImageMagick called Python Magick (didn't know if I needed but I still did).
After all this I still was having troubles, and I decided to do what the error message suggested with was to check the command window for the error message from the encoder. It was long but one of the pieces said
No such file or directory # error/ps.c/ReadPSImage/837
After looking this error online, I found that what I still was missing was the "Ghostscript delegate library" (don't ask me what it is, i dont quite know). After installing the Ghostscript delegate library for windows (32 bit since that's what my python version is). It got solved and it was able to create the movie.
I would suggest installing the ghostscript delegate library first and check if that is enough. If it is, post back that it worked, so i know of all the damn things I did, what was it that made the code work.