Reputation: 111
I've been trying to convert a MP3 file to an OGG one, but I keep getting this error message:
C:\Users\Administrador\AppData\Local\Programs\Python\Python39\lib\site-
File "c:\Users\Administrador\Desktop\Codigo python\boludez.py", line 5, in <module>
data = urlopen('C:\\Users\\Administrador\\Desktop\\Codigo python\\Asistente\\Me at the
return opener.open(url, data, timeout)
File "C:\Users\Administrador\AppData\Local\Programs\Python\Python39\lib\urllib\request.py",
line 517, in open
response = self._open(req, data)
File "C:\Users\Administrador\AppData\Local\Programs\Python\Python39\lib\urllib\request.py",
line 539, in _open
return self._call_chain(self.handle_open, 'unknown',
File "C:\Users\Administrador\AppData\Local\Programs\Python\Python39\lib\urllib\request.py",
line 494, in _call_chain
result = func(*args)
File "C:\Users\Administrador\AppData\Local\Programs\Python\Python39\lib\urllib\request.py",
line 1413, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: c>
The code is the following one:
import tempfile
from pydub import AudioSegment
from urllib.request import urlopen
data = urlopen('C:\\Users\\Administrador\\Desktop\\Codigo python\\Asistente\\Me at the
zoo.mp3').read()
f = tempfile.NamedTemporaryFile(delete=False)
f.write(data)
AudioSegment.from_mp3(f.name).export('result.ogg', format='ogg')
f.close()
I installed ffmpeg with pip but I keep getting the exception. I want to add it to my path but I don't know which file do I have to add nor where to find the installed library.
I would really thank you for some help, Im with this a couple of hours ago. Thanks in advance!
Upvotes: 0
Views: 70
Reputation: 21
C:\\Users\\Administrador
is not a URL. And you should not use urllib
. You can use this:
with open('C:\\Users\\Administrador\\Desktop\\Codigo python\\Asistente\\Me at the zoo.mp3') as data:
data = data.read()
Upvotes: 2