From 49a6c6cab780aac4dbb0866dfb4199f669ac6a09 Mon Sep 17 00:00:00 2001 From: Oguzhan Yilmaz Date: Mon, 9 Dec 2024 18:37:08 +0300 Subject: [PATCH] add BASE_AUDIO_DIRECTORY --- pycrossfade/cli.py | 18 ++++++++++++++++-- pycrossfade/config.py | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pycrossfade/cli.py b/pycrossfade/cli.py index 044d7a3..106795a 100644 --- a/pycrossfade/cli.py +++ b/pycrossfade/cli.py @@ -5,6 +5,7 @@ from typing_extensions import Annotated, Optional, List import numpy as np import transition +import config from pprint import pprint app = typer.Typer( no_args_is_help=True, @@ -25,10 +26,15 @@ def crossfade( verbose: Annotated[ Optional[bool], typer.Option('--verbose', '-v',help="Print details about the crossfade") ] = False, mark_transitions: Annotated[ Optional[bool], typer.Option('--mark-transitions',help="Play a beep sound at time-stretch, crossfade, and slave starts") ] = False, ): + output = config.BASE_AUDIO_DIRECTORY+output + # print(f"filepath={filepath}") # print("> Processing master audio...") + master_filepath = config.BASE_AUDIO_DIRECTORY+master_filepath master_song = Song(master_filepath) # print("> Processing slave audio...") + + slave_filepath = config.BASE_AUDIO_DIRECTORY+slave_filepath slave_song = Song(slave_filepath) crossfade = transition.crossfade(master_song, slave_song, len_crossfade=len_crossfade, len_time_stretch=len_time_stretch) @@ -62,8 +68,10 @@ def crossfade_many( verbose: Annotated[ Optional[bool], typer.Option('--verbose', '-v',help="Print details about the crossfade") ] = False, mark_transitions: Annotated[ Optional[bool], typer.Option('--mark-transitions',help="Play a beep sound at time-stretch, crossfade, and slave starts") ] = False, ): + output = config.BASE_AUDIO_DIRECTORY+output + # print(f"filepath={filepath}") - song_list = [Song(filepath) for filepath in song_filepaths] + song_list = [Song(config.BASE_AUDIO_DIRECTORY+filepath) for filepath in song_filepaths] multi_transition = transition.crossfade_multiple(song_list, len_crossfade=len_crossfade, len_time_stretch=len_time_stretch) @@ -95,6 +103,8 @@ def group_by_three(lst): @app.command(no_args_is_help=True, short_help="Process song and print metadata") def song(filepath: Annotated[str, typer.Argument(help="Filepath to song")]): # print(f"filepath={filepath}") + filepath = config.BASE_AUDIO_DIRECTORY+filepath + print("> Processing audio...") s = Song(filepath) print("> Audio loaded!") @@ -106,6 +116,7 @@ def extract( filepath: Annotated[str, typer.Argument(help="Filepath to song")], # output: Annotated[Optional[bool], typer.Option('--output', '-o')] = False, ): + filepath = config.BASE_AUDIO_DIRECTORY+filepath # print(f"filepath={filepath}") print("> Processing audio...") s = Song(filepath) @@ -118,6 +129,8 @@ def mark_downbeats( filepath: Annotated[str, typer.Argument(help="Filepath to song")], output: Annotated[Optional[str], typer.Option('--output', '-o')] = "", ): + filepath = config.BASE_AUDIO_DIRECTORY+filepath + output = config.BASE_AUDIO_DIRECTORY+output s = Song(filepath) if not output: output = f"{s.song_name}--marked-downbeats.wav" @@ -134,7 +147,8 @@ def cut_song( ): assert from_downbeat < to_downbeat - + filepath = config.BASE_AUDIO_DIRECTORY+filepath + output = config.BASE_AUDIO_DIRECTORY+output s = Song(filepath) dbeats = s.get_downbeats() diff --git a/pycrossfade/config.py b/pycrossfade/config.py index f8d6c97..fa0bb18 100644 --- a/pycrossfade/config.py +++ b/pycrossfade/config.py @@ -1,3 +1,4 @@ from os import environ -ANNOTATIONS_DIRECTORY=environ.get('ANNOTATIONS_DIRECTORY', 'pycrossfade_annotations') \ No newline at end of file +ANNOTATIONS_DIRECTORY=environ.get('ANNOTATIONS_DIRECTORY', 'pycrossfade_annotations') +BASE_AUDIO_DIRECTORY=environ.get('BASE_AUDIO_DIRECTORY', '')