Downloaded the sound from https://sounds-mp3.com/, and the syntax of the playsound was from the official site of it. Still there is no sound played and giving me the below mentioned output of execution.
from playsound import playsound
playsound('C:\\Users\\HP\\Downloads\\0003537.mp3')
output:
python -u "c:\Users\HP\Desktop\python files\hello.py"
I doubt it is a problem with the code, it looks fine.
It might be to do with your speakers or the audio file. Try out a wav and see if that works. Check your path too. I have had problems in the past with files downloaded from the web so maybe record something on Audacity and see if that plays. Try playing the audio file with the default software for your os, does it work?
Related
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 am trying to play sound in Python. When I run my code, it finishes successfully but the audio is not played by my computer.
I have tried with all the libraries like playsound, simpleaudio, pydub and kivy core audio.
Sample code I tried is:
from playsound import playsound
playsound('myfile.wav')
As i think it should work, check either your audio file (maybe it's empty) or check your audio drivers and audio output.
OR, You can try
pip install playsound
one more time
I've had this problem before, use the complete path:
from playsound import playsound
playsound(r"C:\some\path\sound.mp3") # the "r" is necessary, or else your code wont work!
I use google-cloud text-to-speech API using python3 on linux.
The mp3 plays with os.startfile(), which opens a player.
Instead sending mp3 file & using mp3 player, I need to play audio through the browser.
I have tried:
“Python Media Player” —-defunct.
“20.1. webbrowser”— defunct.
“Rhythmbox” —simply another player.
“Pygame” — overkill.
"Pyglet" - overkill
SoX and pySoX, —Don’t appear to play the files they manipulate.
I read part of Schwoebel’s “An Introduction to Voice Computing in Python.”
"gl_talk" — Wasn't able to implement; very little documentation.
I need advice on how to mimic what google has done in the browser as in the link here:
https://cloud.google.com/text-to-speech
You can use the gTTS module to do text-to-speech in Python. And then you can use another module to play the sound using Python as well.
First install the following modules...
pip install gTTS
pip install playsound
Then you can do this...
from gtts import gTTS
import playsound
tts = gTTS('hello')
tts.save('hello.mp3')
playsound.playsound('hello.mp3')
This code should give you the same results as google in browser, because gtts uses the same API. If you have any problems you can comment and I will definitely reply :)
I have been looking for ages on ways to find out how to make idle python play sound such as wav.
The solutions I have found are used by programs such as pygame. I can't download pygame or any other program.
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
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. 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). 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.
p.s
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. :)
as i said in Title i have a problem, hope you can help me....
i'm trying to play some wav files using sounddevice library from python 2.7 it took me a while to make it work and be able to use it, i am using it because i need to play some audio files with a bitdepth of 24bits (i'll get the DAC later).
So the problem i have is this. i am trying to run the most easy of the scripts and it is.. just playing a wav file like this.
#!/usr/bin/env python2.7
import numpy
import scipy
from scipy.io.wavfile import read
import sounddevice as sd
fs,sound=scipy.io.wavfile.read('my.wav')
sd.play(sound,fs)
to check if it is working i did sudo python myscript.py... in terminal, but it didn`t sound or showed me an error in the script. next i went to the python shell, ran it... and it sounded! .. i can understand why it doesn't sound when i try to use the terminal, and i need to use it because i also have to use GPIO
i would be thankful if you could help me.