brownify package

Submodules

brownify.actions module

class brownify.actions.Brownifier[source]

Bases: object

static change_pitch(track: brownify.models.Track, n_steps: int, bins_per_octave: int = 12) brownify.models.Track[source]

Change the pitch of the track without changing the track speed

Parameters
  • track – The track to modify

  • n_steps – Number of steps to modify by (positive or negative)

  • bins_per_octave – Number of steps in an octave. Defaults to 12.

Returns

The track with the pitch changed

static early(track: brownify.models.Track) brownify.models.Track[source]

Shift the track forward in time by about a 35 milliseconds

Parameters

track – The track to modify

Returns

The track which is now early

static flat(track: brownify.models.Track) brownify.models.Track[source]

Make the track flat by one semitone

Parameters

track – The track to modify

Returns

The track which is now flat

static half_flat(track: brownify.models.Track) brownify.models.Track[source]

Make the track flat by one quarter tone

Parameters

track – The track to modify

Returns

The track which is now half-flat

static half_sharp(track: brownify.models.Track) brownify.models.Track[source]

Make the track sharp by one quarter tone

Parameters

track – The track to modify

Returns

The track which is now half-sharp

static late(track: brownify.models.Track) brownify.models.Track[source]

Shift a track backward in time by about a 35 milliseconds

Parameters

track – The track to modify

Returns

The track which is now late

static octave_down(track: brownify.models.Track) brownify.models.Track[source]

Move the track down by a full octave

Parameters

track – The track to modify

Returns

The track which is now an octave lower

static octave_up(track: brownify.models.Track) brownify.models.Track[source]

Move the track up by a full octave

Parameters

track – The track to modify

Returns

The track which is now an octave higher

static sharp(track: brownify.models.Track) brownify.models.Track[source]

Make the track sharp by one semitone

Parameters

track – The track to modify

Returns

The track which is now sharp

static time_shift(track: brownify.models.Track, seconds_shift: float) brownify.models.Track[source]

Shift the track forward or backward in time

The track is shifted forward or backward in time by rolling the values and wrapping where the track ends back to the beginning or vice-versa

Parameters
  • track – The track to modify

  • seconds_shift – The number of seconds to shift by

Returns

The track which has been shifted in time

brownify.cli module

brownify.cli.get_args() argparse.Namespace[source]
brownify.cli.main() int[source]

brownify.downloaders module

class brownify.downloaders.YoutubeDownloader[source]

Bases: object

YoutubeDownloader downloads audio to files from Youtube

YoutubeDownloader is a convenience class for fetching audio files from Youtube links.

static get_audio(url: str, filename: str) None[source]

Method to fetch the audio file

Parameters
  • url – URL for the YouTube video to download audio from

  • filename – The path to save the fetched aduio file to. This

  • file (must include an extension such as ".mp3" to fetch an audio) –

  • youtube. (from) –

Raises

NoAudioStreamFoundError – If no audio stream can be found for the provided URL given the provided file type and bitrate

brownify.errors module

exception brownify.errors.BrownifyError[source]

Bases: Exception

Generic error for brownify

exception brownify.errors.DownloadError[source]

Bases: brownify.errors.BrownifyError

Error raised when unable to download an audio stream

DownloadError is raised when a downloader fails to fetch audio desired by the caller.

exception brownify.errors.InvalidInputError[source]

Bases: brownify.errors.BrownifyError

Error raised when invalid user input provided to brownify

exception brownify.errors.MergingError[source]

Bases: brownify.errors.BrownifyError

Error raised when an error occurs during audio merging

MergingError should be raised when an error occurs while merging multiple separate tracks into a final track.

exception brownify.errors.NoAudioStreamFoundError[source]

Bases: brownify.errors.BrownifyError

Error raised when a referenced audio stream does not exist

NoAudioStreamFoundError should be raised when an audio stream referenced by a caller does not exist.

exception brownify.errors.NoPipelineSourceError[source]

Bases: brownify.errors.BrownifyError

Error raised when a pipeline has a source which does not exist

NoPipelineSourceError should be raised when a pipeline has been defined using a source name that has no backing track available.

exception brownify.errors.SplittingError[source]

Bases: brownify.errors.BrownifyError

Error raised when unable to split a track into multiple tracks

SplitterError is raised when an error is detected during the splitting process.

exception brownify.errors.TokenNotInGrammarError[source]

Bases: brownify.errors.BrownifyError

Error raised when an token is invalid but passed the parser

TokenNotInGrammarError should be raised when performing post-processing steps over input which has already been processed by the grammar. It is used to catch issues where the expected syntax of a token in post-processing code does not match the expected syntax of the grammar. In general, this should not happen unless there is a bug caused by a mismatch between the grammar and the current code logic.

exception brownify.errors.UnexpectedTokenTypeError[source]

Bases: brownify.errors.BrownifyError

Error raised when an unexpected token is seen after parsing

UnexpectedTokenTypeError should be raised when performing post-processing steps over input which has already been processed by the grammar. It is used to catch issues where the syntax defined by the configuration language allows for a class of token which is not semantically understood by the program. In general, this should not happen unless there is a bug caused by a mismatch between the grammar and the current code logic.

brownify.models module

class brownify.models.Pipeline(source: str, actions: List[Callable], sink: str, save: bool)[source]

Bases: object

A processing sequence for an audio source

Pipelines define an audio source name, a series of actions to apply, and an audio sink name. They also include a flag noting whether or not the track should be saved for merging.

Parameters
  • source – Name of an audio source

  • actions – Series of actions to apply to the source

  • sink – New name for the processed audio

  • save – Mark a sink to be saved into the final merged file

actions: List[Callable]
save: bool
sink: str
source: str
class brownify.models.Track(audio: numpy.ndarray, num_channels: int, sample_rate: int, save: bool)[source]

Bases: object

A container for an audio track

Track includes the audio details needed for managing an audio track throughout the processing stages.

Parameters
  • audio – Array containing the an sequence of audio data; the first dimension represents time, and the second dimension (if present) represents channels

  • num_channels – Number of channels in the audio data

  • sample_rate – The rate at which the audio data was sampled

  • save – Mark a track to be saved in the final merged file

audio: numpy.ndarray
clone() brownify.models.Track[source]

Clone a track

Create a deep copy of a track with the save parameter always initialized to False

Returns

A deep copy of the original track

num_channels: int
sample_rate: int
save: bool

brownify.parsers module

class brownify.parsers.ActionParser[source]

Bases: object

ActionParser defines and parses the recipe grammar

ActionParser takes in the user provided recipe for the final audio file and converts it into a series of Pipelines for processing. It contains the grammar definition and also semantic-level processing for the conversion of the recipe into Pipelines.

get_pipelines(program: str) List[brownify.models.Pipeline][source]

Get audio processing pipelines given a recipe

Parameters

program – Recipe defining the steps to perform over the audio

Raises

InvalidInputError – If an invalid recipe is provided

Returns

Sequence of pipelines to be run

brownify.runners module

class brownify.runners.AudioMerger[source]

Bases: object

static merge(files: List[str]) pydub.audio_segment.AudioSegment[source]

Merge the list of audio sources into an AudioSegment

Parameters

files – List of track sources to merge

Raises
  • InvalidInputError – If no files were provided to merge, then this is likely the result of a bad input recipe.

  • MergingError – If the tracks are unabled to be merged

Returns

The overlaid tracks merged into an AudioSegment

static save_file(filename: str, audio: pydub.audio_segment.AudioSegment) None[source]

Save the merged audio file

Parameters
  • filename – Path to use for the merged file

  • audio – AudioSegment to save

Raises

MergingError – If unable to save the merged track

class brownify.runners.PipelineProcessor(target: str, splitter: brownify.splitters.AudioSplitter)[source]

Bases: object

Class for processing a series of Pipeline objects

process(pipelines: List[brownify.models.Pipeline], output_file: str) None[source]

Process a series of pipelines and output a processed audio file

Parameters
  • pipelines – List of pipelines to apply to generate an audio track

  • output_file – Path to output the track to

brownify.splitters module

class brownify.splitters.AudioSplitter[source]

Bases: abc.ABC

Abstract class for an object that splits audio files into sources

AudioSplitter is the top of the class hierarchy for objects which can take in audio files and split them into multiple separated sources

abstract get_channels() List[str][source]

Get the list of named of channels that the splitter will create

separator: spleeter.separator.Separator
split(filename: str) None[source]

Split an audio file into multiple sources

Parameters

filename (str) – Path to the file which should be split into multiple sources

Raises

SplittingError – If unable to perform the operation of splitting into multiple tracks

class brownify.splitters.AudioSplitter2Channel[source]

Bases: brownify.splitters.AudioSplitter

Split a file into vocal and other tracks

AudioSplitter2Channel objects can split a single track into separate voice and other tracks. It may provide the cleanest track separation if only vocal isolation is desired.

CHANNELS = ['other', 'vocals']
get_channels() List[str][source]

Get the list of named of channels that the splitter will create

separator: spleeter.separator.Separator
class brownify.splitters.AudioSplitter4Channel[source]

Bases: brownify.splitters.AudioSplitter

Split a file into bass, drums, vocals, and other tracks

AudioSplitter4Channel objects can split a single track into separate bass, drum, vocals, and other tracks. It is useful when an audio source should be split into all of those tracks with the potential of a less clean separation than the other splitters with fewer tracks.

CHANNELS = ['bass', 'drums', 'other', 'vocals']
get_channels() List[str][source]

Get the list of named of channels that the splitter will create

separator: spleeter.separator.Separator
class brownify.splitters.AudioSplitter5Channel[source]

Bases: brownify.splitters.AudioSplitter

Split a file into bass, drums, piano, vocals, and other tracks

AudioSplitter5Channel objects can split a single track into separate bass, drum, piano, vocals, and other tracks. It is useful when an audio source should be split into all of those tracks with the potential of a less clean separation than the other splitters with fewer tracks.

CHANNELS = ['bass', 'drums', 'other', 'piano', 'vocals']
get_channels() List[str][source]

Get the list of named of channels that the splitter will create

separator: spleeter.separator.Separator
class brownify.splitters.AudioSplitterFactory[source]

Bases: object

Factory class for creating AudioSplitter objects

static get_audio_splitter(audio_splitter_type: brownify.splitters.AudioSplitterType = AudioSplitterType.FIVE_STEM) brownify.splitters.AudioSplitter[source]

Method for getting AudioSplitter instances

Parameters
  • audio_splitter_type (AudioSplitterType, optional) – Type of

  • type (AudioSplitter to create. See the class documentation of each) –

  • AudioSplitterType.FIVE_STEM. (for assistance choosing. Defaults to) –

Returns

A concrete instance of an AudioSplitter

Return type

AudioSplitter

class brownify.splitters.AudioSplitterType(value)[source]

Bases: enum.Enum

Enumerate AudioSplitter types for the AudioSplitterFactory

FIVE_STEM = 3
FOUR_STEM = 2
ONLY_VOCALS = 1

Module contents