File size: 6,310 Bytes
95c87c2
 
 
 
 
 
 
 
 
 
4811c3b
 
 
95c87c2
4811c3b
95c87c2
 
4811c3b
95c87c2
4811c3b
 
a0010af
4811c3b
a0010af
95c87c2
 
 
4811c3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95c87c2
4811c3b
 
 
 
95c87c2
4811c3b
 
 
95c87c2
4811c3b
 
 
95c87c2
4811c3b
 
 
 
95c87c2
4811c3b
 
95c87c2
4811c3b
 
 
 
 
 
 
 
 
95c87c2
 
4811c3b
95c87c2
4811c3b
95c87c2
4811c3b
 
 
95c87c2
4811c3b
95c87c2
4811c3b
 
 
95c87c2
 
4811c3b
 
 
 
 
 
 
 
 
 
 
 
95c87c2
 
4811c3b
95c87c2
4811c3b
 
 
 
 
 
 
 
 
 
 
 
95c87c2
 
4811c3b
 
 
 
 
95c87c2
4811c3b
95c87c2
4811c3b
 
 
 
 
 
 
 
95c87c2
4811c3b
95c87c2
 
 
4811c3b
95c87c2
 
 
4811c3b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
license: other
license_name: stability-ai-community-license
license_link: LICENSE.md
tags:
  - audio
  - text-to-audio
  - music-generation
  - allegretto-mini
  - onnx
  - onnxruntime
  - local-ai
  - generative-ai
library_name: onnxruntime
pipeline_tag: text-to-audio
---

# Allegretto Mini

**Allegretto Mini** is a lightweight, local-first AI music generation model developed by **OSAMA INC** (India). It synthesizes stereo audio at 44.1 kHz directly from text prompts β€” no cloud API, no server-side GPU required. Run it entirely on your own machine.

> πŸ€– **HuggingFace Model**: [https://huggingface.co/Dev4285/Allegretto-Mini](https://huggingface.co/Dev4285/Allegretto-Mini)
> πŸ’» **GitHub**: [https://github.com/aryanisproinroblox-source/Allegretto-Mini](https://github.com/aryanisproinroblox-source/Allegretto-Mini)
> 🎧 **Live Demo**: [https://huggingface.co/spaces/Dev4285/Allegretto-Mini-Demo](https://huggingface.co/spaces/Dev4285/Allegretto-Mini-Demo) β€” try it right now in your browser!

## About OSAMA INC

**OSAMA INC** is an Indian AI research company building next-generation audio synthesis tools for creators, musicians, and developers. Allegretto Mini is our flagship release β€” a production-grade text-to-music model designed to run locally on consumer hardware, giving users full ownership of their creative workflow without dependency on external services.

| | |
|---|---|
| 🏒 **Company** | OSAMA INC (India) |
| 🎡 **Model** | Allegretto Mini |
| 🎧 **Output** | Stereo audio, 44.1 kHz |
| πŸ’Ύ **Size** | ~640 MB (int4 quantized) |
| ⚑ **Default** | 10 seconds, 8 diffusion steps |
| πŸ”’ **License** | Stability AI Community License |

## Quick Start β€” Local Inference

Allegretto Mini uses ONNX Runtime so you can run inference locally on any machine β€” CPU or GPU β€” without Python or PyTorch dependencies. Just download the weights and go.

### Python (ONNX Runtime)

```python
import onnxruntime as ort
import numpy as np
from tokenizers import Tokenizer

# Load tokenizer and config
tokenizer = Tokenizer.from_file("tokenizer/tokenizer.json")
config = json.load(open("config.json"))

# Encode your text prompt
encoding = tokenizer.encode("upbeat electronic dance track with synth pads")
tokens = np.array([encoding.ids], dtype=np.int32)

# Create sessions
text_encoder = ort.InferenceSession("onnx/text_encoder_q4.onnx")
dit = ort.InferenceSession("onnx/dit_q4.onnx")
decoder = ort.InferenceSession("onnx/decoder_q4.onnx")

# Generate latent, run diffusion loop, decode to audio
# See the full pipeline in the examples directory
```

### JavaScript / Node.js

```js
const ort = require("onnxruntime-node");
const tokenizer = await Tokenizer.fromFile("tokenizer/tokenizer.json");

// Same pipeline β€” encode β†’ condition β†’ diffuse β†’ decode
// Works in Node.js, Electron, or bundled for the web
```

## Model Architecture

Allegretto Mini is built on a three-stage generative pipeline:

1. **Text Encoder** β€” T5Gemma-based encoder processes your text prompt into rich conditioning embeddings (768-dim, 256 tokens + 1 duration embedding).
2. **DiT (Diffusion Transformer)** β€” A 20-layer transformer with cross-attention generates latent audio representations through an 8-step rectified-flow sampling loop.
3. **SAME-S Decoder** β€” Converts latents to stereo waveforms at 44.1 kHz with 2-channel output.

A lightweight **Number Conditioner** embeds the desired duration (in seconds) so you can control clip length at inference time.

While the underlying architecture draws from the same family as Stability AI's stable-audio-3-small, Allegretto Mini has been independently optimized, quantized, and packaged by OSAMA INC for efficient local deployment.

## Model Files

```
config.json                         Runtime configuration
number_conditioner.npz              Duration embedder weights
tokenizer/
  tokenizer.json                    T5Gemma tokenizer
  tokenizer_config.json             Tokenizer settings
onnx/
  text_encoder_q4.onnx              Text encoder graph (~213 MB weights)
  dit_q4.onnx                       Diffusion transformer graph (~380 MB weights)
  decoder_q4.onnx                   Audio decoder graph (~45 MB weights)
  number_conditioner.onnx           Duration embedder graph (~0.8 MB)
  *_chunks.json                     Weight manifest per graph
  *_chunk_*.data                    Quantized weight data (split ≀100 MB each)
```

Total download size: **~640 MB** of int4 quantized weights across 9 external data chunks.

## Inference Specs

- **Latent shape**: `(1, 256, T_lat)` where `T_lat = ceil((seconds + 6) * 44100 / 8192) * 2`
- **Cross-attention conditioning**: `(1, 257, 768)` β€” 256 text tokens + 1 duration embedding
- **Global conditioning (adaLN)**: `(1, 768)` β€” duration embedding
- **Output**: `(1, 2, T_lat * 4096)` β€” stereo audio at 44.1 kHz, values clamped to [-1, 1]
- **Default generation**: 10 seconds, 8 steps
- **CFG**: Disabled at inference time (`cfg_scale = 1.0`)

## Sampling

Allegretto Mini uses a rectified-flow denoiser with the **pingpong** sampler:

```
denoised = x - t_curr * dit(x, t_curr, conditioning)
x = (1 - t_next) * denoised + t_next * randn_like(x)
```

The schedule uses `LogSNRShift(rate=0, anchor_logsnr=-6.2, logsnr_end=2.0)` β€” a closed-form formula that works for any duration without recomputing the schedule. Fast, deterministic, and sequence-length-invariant.

## Performance

| Metric | Value |
|---|---|
| DiT q4 vs fp32 SNR | ~10 dB |
| Decoder q4 vs fp32 SNR | ~15 dB |
| Text encoder q4 vs fp32 SNR | ~13 dB |
| End-to-end envelope correlation | β‰ˆ 0.88 |
| Local CPU (single thread) | ~60–120s per 10s clip |
| With GPU acceleration | Significantly faster |

Quantization uses **int4 MatMulNBits** (`block_size=16`) for weight-bearing nodes, **GatherBlockQuantized** for embedding tables, and fp32 for LayerNorm scales, biases, and Conv1d kernels β€” keeping quality high while slashing size to ~640 MB.

## License

This model is released under the **Stability AI Community License**. The T5Gemma encoder components additionally fall under Google's **Gemma Terms of Use**. Both license files are included in this repository; see `NOTICE` for combined attribution.

---

*Allegretto Mini β€” developed and released by OSAMA INC (India)*