my problem starts here:
pyttsx and gTTS module errors
gTTS works well, takes text from text file, but first creates mp3 file, then if I want listen, I must call
webbrowser
should be part of you standard python install.
Check if there is a webbrowser.py
under C:\Your_Python_Folder\Lib
.
Below code works just fine for me as webbrowser.py
is present at above mentioned folder.
import webbrowser
webbrowser.open("rec.mp3")
You can use "subprocess".
from subprocess import call
from gtts import gTTS
import os
blabla = input('Type IN: ')
tts = gTTS(text=blabla, lang='en')
tts.save("test.mp3")
call(["vlc", "test.mp3"])
This program asks user to type in anything and it will say that trough vlc.
I use this on Linux but i don't now if it works on Windows.
I don't know the solution to all of the questions, but the issue you're having with pydub is that you don't have ffmpeg or avconv installed. There are instructions on the pydub github:
Windows:
- Download and extract libav from Windows binaries provided here.
- Add the libav /bin folder to your PATH envvar
- pip install pydub
If AVbin error occurs...
First download AVbin.exe and Install it then Go to local disk C --> windows --> System32 --> search the Avbin.dll and copy that file then paste that particular file in your root directory
Error will vanish
You can use playsound module
from playsound import playsound
playsound(file.mp3)
Boom that's it.it plays the audio right way works like charm
Same problem here. It works with playsound 1.2.1 for me.
Install with :
$ pip install playsound
test with:
>>>from playsound import playsound
>>>playsound('/path/to/a/sound/file/you/want/to/play.mp3')