0
votes

i trying to make a program which converts normal audio into 8d audio i grabbed this code from github https://github.com/TheJoin95/ambisonics-3d-audio/blob/master/init.py

from glob import glob
from pydub import AudioSegment
from pydub.generators import WhiteNoise
from math import *
from random import *
import sys

if len(sys.argv) > 2:
    AudioSegment.converter = sys.argv[1] #ffmpeg installation exe dir path
    AudioSegment.ffmpeg = sys.argv[1] #ffmpeg installation exe dir path
    AudioSegment.ffprobe = sys.argv[2] #ffprobe installation exe dir path

def calc_pan(index):
    return cos(radians(index))

#playlist_songs = [AudioSegment.from_mp3(mp3_file) for mp3_file in glob("mp3/*.mp3")]

#first_song = playlist_songs.pop(0)
interval = 0.2 * 1000 # sec
song = AudioSegment.from_mp3('mp3/hellomp.mp3')
song_inverted = song.invert_phase()
song.overlay(song_inverted)

splitted_song = splitted_song_inverted = []
song_start_point = 0

print("split song in part")
while song_start_point+interval < len(song):
    splitted_song.append(song[song_start_point:song_start_point+interval])
    song_start_point += interval

if song_start_point < len(song):
    splitted_song.append(song[song_start_point:])

print("end splitting")
print("total pieces: " + str(len(splitted_song)))

ambisonics_song = splitted_song.pop(0)
pan_index = 0
for piece in splitted_song:
    pan_index += 5
    piece = piece.pan(calc_pan(pan_index))
    ambisonics_song = ambisonics_song.append(piece, crossfade=interval/50)


# lets save it!
out_f = open("compiled/everlong.mp3", 'wb')

ambisonics_song.export(out_f, format='mp3')


i expected to be an 8D audio but i got some errors how can i fix it and make my code work

Warning (from warnings module): File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\utils.py", line 165 warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning) RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work Traceback (most recent call last): File "C:/Users/lenovo/AppData/Local/Programs/Python/Python37-32/8dmusic.py", line 20, in song = AudioSegment.from_mp3('mp3/hellomp.mp3') File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\audio_segment.py", line 716, in from_mp3 return cls.from_file(file, 'mp3', parameters=parameters) File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\audio_segment.py", line 610, in from_file file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False) File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\utils.py", line 57, in _fd_or_path_or_tempfile fd = open(fd, mode=mode) FileNotFoundError: [Errno 2] No such file or directory: 'mp3/hellomp.mp3'

2
You need to install on your machine either ffmpeg or avconv for the program to workphiloez98
my path is 100 % correct ,i checked it twiceRohan Jain

2 Answers

0
votes

The traceback gives you the answer "[Errno 2] No such file or directory: 'mp3/hellomp.mp3'

python audio mp3".

The program is trying to find a file in a folder that doesnt exist. Check the folder is there, then check the path is 100% correct

0
votes

I think you need file path like absolute path. mp3/hellomp.mp3 looks like a relative path but you should check the current directory path containing source code. That word adds '../' or './' for reasonable.