marl / marl/SpatialScaper

API conventions

Open
#34 2 comments 0 reactions 1 assignee View on GitHub

@iranroman is already working on this.

Since Jan 22, 2024.

Dominant language
Jupyter Notebook
Stars
78
Forks
9
PR merge metrics
No merged PRs in 30d

Description

API version 0.1.0 proposes an API #31 that resembles [Scaper](https://github.com/justinsalamon/scaper) but with the spatial functionalities added. Here is an example script:

```
import numpy as np
import spatialscaper as ss
import os

# Constants
NSCAPES = 25
FOREGROUND_DIR = "datasets/sound_event_datasets/FSD50K_FMA"
BACKGROUND_DIR = ""
RIR_DIR = "datasets/rir_datasets"
ROOM = "metu"
FORMAT = "mic"
MIN_EVENTS = 3
MAX_EVENTS = 8
DURATION = 60.0 # Duration in seconds
SR = 24000 # Sampling rate
OUTPUT_DIR = "output"
REF_DB = -65 # Reference decibel level


# Function to generate a soundscape
def generate_soundscape(index):
track_name = f"fold5_room1_mix00{index + 1}"
ssc = ss.Scaper(
DURATION, FOREGROUND_DIR, BACKGROUND_DIR, RIR_DIR, ROOM, FORMAT, SR
)
ssc.ref_db = REF_DB

# Add background
ssc.add_background()

# Add a random number of foreground events
n_events = np.random.randint(MIN_EVENTS, MAX_EVENTS + 1)
for _ in range(n_events):
ssc.add_event(event_position=("moving", ("uniform", None, None)))

audiofile = os.path.join(OUTPUT_DIR, FORMAT, track_name)
labelfile = os.path.join(OUTPUT_DIR, "labels", track_name)

ssc.generate(audiofile, labelfile)


# Main loop for generating soundscapes
for iscape in range(NSCAPES):
print(f"Generating soundscape: {iscape + 1}/{NSCAPES}")
generate_soundscape(iscape)
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.