Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mono #54

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Mono #54

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions polymath.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ def audio_process(vids, videos):
if vid.endswith(".mp3"):
# convert mp3 to wav and save it
print('converting mp3 to wav:', vid)
y, sr = librosa.load(path=vid, sr=None, mono=False)
songArray, sr = librosa.load(path=vid, sr=None, mono=False)
path = os.path.join(os.getcwd(), 'library', audioid+'.wav')
# resample to 44100k if required
if sr != 44100:
print('converting audio file to 44100:', vid)
y = librosa.resample(y, orig_sr=sr, target_sr=44100)
sf.write(path, np.ravel(y), 44100)
songArray = librosa.resample(songArray, orig_sr=sr, target_sr=44100)

if songArray.ndim > 1:
songArray = np.mean(songArray, axis=0)

sf.write(path, np.ravel(songArray), 44100)
vid = path

# check if is wav and copy it to local folder
Expand Down