semvec/pypi-packages huggingface dataset:
tsa-lth 0.0.4
Package for time series analysis course on LTH
Requires Python: >=3.8

# Python package for Time Series Analysis course at LTH.
Written by Filipp Lernbo.

## Installation
I assume you have python 3.8 or later installed on your computer.
### 1. Create virtual environment
Install virtualenv if not already installed. This is done by typing `pip install virtualenv` in your terminal.

Open terminal and navigate to your time-series directory. Type `python -m venv tsa_venv` to create the virtual environment
### 2. Activate the virtual environment
In the newly created directory, there is a bin-folder. Among other things, this contains an activation script: `<tsa-folder>/bin/activate`. Type `source <path-to-activate-file>` to activate your virtual environment.

*Tip! You can create an alias for this step. If you're on mac, you can open the file `~/.bash_profile` and add a line: `alias tsa="source <path-to-activate-file>"`. Next time you open terminal, you only need to write "tsa" to activate the virtual environment.*
### 3. Install this package
Navigate to the root of this project and type `pip install -r requirements.txt` followed by `pip install --editable .`.

Now, when you're in this virtual environment you can always import files from this repo, where ever you are on the computer.

## Contributing
Read the `CONTRIBUTING.md` file before pushing code.
spectro-utils 0.1.4
Add a short description here
Requires Python: >=3.11

# 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
```python
import spectro_utils.audio2spectro as a2s
a2s.audio2spectro_img(audio_paths)
```

#### spectro image to wav file
```python
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.
```python
audios=a2s.read_audio_lazy(paths)
```

#### wave2spectro_lazy
Converts the waves to an spectrum using delayed evaluation.
```python
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
```python
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.
```python
images=s2a.read_img_lazy(paths)
```

#### img2amp_lazy
Converts the image to an power spectrum using delayed evaluation.
```python
amplitudes=s2a.img2amp_lazy(images)
```

#### amp2wave_lazy
Converts power spectrum to sound waves using delay evaluation.
```python
waves=s2a.amp2wave_lazy(amplitudes)
```

#### wave2wav_file
Save the sound wave as a wav file.
```python
s2a.wave2wav_file(waves,file_names)
```

#### example of custom pipeline
```python
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))
```