Skip to main content

Add a short description here

Project description

spectro-utils

Conversion from wav file to spectro image and from spectro image to wav file

install

pip install spectro-utils

how to use

get started

wav file to spectro image

import spectro_utils.audio2spectro as a2s
a2s.audio2spectro_img(audio_paths)

spectro image to wav file

import spectro_utils.spectro2audio as s2a
s2a.img2wav_file(image_paths)

more details of audio2spectro

read_audio_lazy

Reads a wav file using delayed evaluation. It saves memory compared to normal loading.

audios=a2s.read_audio_lazy(paths)

wave2spectro_lazy

Converts the waves to an spectrum using delayed evaluation.

spectros=a2s.wave2spectro_lazy(audios)

spectro2img

Save the spectro images as a image files(png or bmp).

a2s.spectro2img(spectros,image_names)

example of custom pipeline

def split_four_audio_lazy(audios):
    for audio in audios:
        n=len(audio)/4
        for i in range(4):
            start=n*i
            yield audio[start:start+n]

def custom_pipeline(paths:list[str],image_names:list[str])->None:
    g=a2s.read_audio_lazy(paths)
    g=split_four_audio_lazy(g)
    g=a2s.wave2spectro_lazy(g)
    a2s.spectro2img(g,image_names)

more details of spectro2audio

read_img_lazy

Reads a image file using delayed evaluation. It saves memory compared to normal loading.

images=s2a.read_img_lazy(paths)

img2amp_lazy

Converts the image to an power spectrum using delayed evaluation.

amplitudes=s2a.img2amp_lazy(images)

amp2wave_lazy

Converts power spectrum to sound waves using delay evaluation.

waves=s2a.amp2wave_lazy(amplitudes)

wave2wav_file

Save the sound wave as a wav file.

s2a.wave2wav_file(waves,file_names)

example of custom pipeline

def volume_up_lazy(amplitudes):
    for amp in amplitudes:
        yield amp*2000

def custom_pipeline(paths)->None:
    g=s2a.read_img_lazy(paths)
    g=s2a.img2amp_lazy(g)
    g=volume_up_lazy(g)
    g=s2a.amp2wave_lazy(g)
    return g

g=custom_pipeline(['./data/image/1.png'])
display(IPython.display.Audio(g.__next__(), rate=44100))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spectro_utils-0.1.4.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

spectro_utils-0.1.4-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file spectro_utils-0.1.4.tar.gz.

File metadata

  • Download URL: spectro_utils-0.1.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for spectro_utils-0.1.4.tar.gz
Algorithm Hash digest
SHA256 750056462949e250580be2ae39be9b4e52f3942e4a41ffebf06246af78a3a2a1
MD5 916ba328376e863304b6a511afaf1c91
BLAKE2b-256 f85e7e1abd430154ebede1dff24b8c5a4da13d6d3de18a8ce59ab54e3e829610

See more details on using hashes here.

File details

Details for the file spectro_utils-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for spectro_utils-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5e830480cc18064209125297583b9f7009299936184f08871bed15427de5da47
MD5 5058e5f37b5dd9751a01608e56fd3afd
BLAKE2b-256 88d9a20ec6f0d6ded11d258f4809c210da7b6e4e9bbcb055680f81b75cdb87bb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page