Metadata-Version: 2.4
Name: lofi-gen
Version: 0.1.0
Summary: A Python package for generating Lofi music using AI models
Author-email: Nikesh Gyawali <gnikesh03@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Nikesh Gyawali
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/gnikesh/lofi-gen
Project-URL: Repository, https://github.com/gnikesh/lofi-gen
Project-URL: Issues, https://github.com/gnikesh/lofi-gen/issues
Keywords: music-generation,lofi,ai,audio,musicgen
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.0.0
Requires-Dist: transformers>=4.30.0
Requires-Dist: numpy>=1.21.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: librosa>=0.10.0
Requires-Dist: soundfile>=0.12.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Provides-Extra: midi
Requires-Dist: midiutil>=1.2.1; extra == "midi"
Requires-Dist: pydub>=0.25.0; extra == "midi"
Provides-Extra: all
Requires-Dist: lofi-gen[dev,midi]; extra == "all"
Dynamic: license-file

# lofi-gen

A Python package for generating Lofi music using AI models like MusicGen.

## Features

- Generate lofi music from text prompts using Meta's MusicGen model
- Create seamless long-form music loops (extend short clips to hours-long sessions)
- Easy-to-use API for music generation
- Spectral crossfading for smooth transitions

## Installation

### From PyPI

```bash
pip install lofi-gen
```

### From Source

```bash
git clone https://github.com/gnikesh/lofi-gen.git
cd lofi-gen
pip install -e .
```

## Quick Start

### Basic Music Generation

```python
from lofi_gen.music.models import MusicGenModel

# Initialize the model
model = MusicGenModel(model_size="large")  # Options: "small", "medium", "large"

# Generate music from a text prompt
audio, sample_rate = model.generate_music(
    prompt="lofi hip hop beat with soft piano, chill vibes",
    duration_seconds=30
)

# Save the generated audio
model.save_audio(audio, sample_rate, "output.wav")
```

### Generate Long-Form Music

```python
from lofi_gen.music.models import MusicGenModel
from lofi_gen.music.pipelines import LongMusicGenerator

# Generate initial clip
model = MusicGenModel()
audio, sample_rate = model.generate_music(
    prompt="relaxing nepali lofi with bansuri flute",
    duration_seconds=60
)
model.save_audio(audio, sample_rate, "base_clip.wav")

# Extend it to a long seamless loop
extender = LongMusicGenerator(crossfade_sec=3.0, variation=True)
extender.generate(
    input_file="base_clip.wav",
    output_file="extended_lofi.wav",
    target_duration_mins=60  # Create a 60-minute loop
)
```


## Requirements

- Python >= 3.8
- PyTorch >= 2.0.0
- transformers >= 4.30.0
- librosa >= 0.10.0
- scipy, numpy, soundfile

See [requirements.txt](requirements.txt) for full dependencies.

## Model Sizes

MusicGen comes in three sizes:

- **small**: Fastest, lower quality (~300MB)
- **medium**: Balanced speed and quality (~1.5GB)
- **large**: Best quality, slower (~3.3GB)

Choose based on your hardware and quality requirements.

## Advanced Usage

### Custom Generation Parameters

```python
audio, sample_rate = model.generate_music(
    prompt="lofi hip hop beat",
    duration_seconds=30,
    guidance_scale=3.0,      # How closely to follow the prompt (1.0-15.0)
    temperature=1.0,         # Randomness (0.1-2.0)
    top_k=250,              # Sampling diversity
    top_p=0.0               # Nucleus sampling (0 to disable)
)
```

### Seamless Loop Configuration

```python
extender = LongMusicGenerator(
    crossfade_sec=3.0,    # Crossfade duration
    variation=True        # Add subtle variations to prevent monotony
)
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Meta AI for the [MusicGen](https://github.com/facebookresearch/audiocraft) model
- Hugging Face for the Transformers library
- The open-source community for various audio processing tools


## Support

For issues, questions, or suggestions:
- Open an issue on [GitHub](https://github.com/gnikesh/lofi-gen/issues)


## Roadmap

- [ ] Add more AI models (AudioLDM, Stable Audio, etc.)
- [ ] Video generation capabilities
- [ ] CLI interface for easy command-line usage
- [ ] Pre-trained models fine-tuned on Nepali music
- [ ] Web interface for music generation
