Lightweight Python library that turns any audio file into a Telegram voice note (.ogg/Opus) — and back.
Project description
voicegram
Lightweight Python library that converts any audio file into a Telegram‑ready voice note (OGG/Opus) — and back again.
Why?
Telegram expects voice messages in a fairly specific format: Opus‑encoded OGG, 48 kHz, mono/stereo. Configuring ffmpeg every time is tedious. voicegram wraps those flags in a minimal API, so your code can simply read:
from voicegram import VoiceConverter, mp3_to_opus
vc = VoiceConverter()
vc.mp3_to_opus("song.mp3", "note.ogg") # library call
# or one‑liner helper
mp3_to_opus("song.mp3") # -> song.ogg
No boilerplate, no codec guessing.
Installation
pip install voicegram # Python ≥ 3.9 and ffmpeg ≥ 4.3 required
Quick start
from voicegram import VoiceConverter
vc = VoiceConverter()
# Convert anything ffmpeg can read to Telegram voice note
vc.mp3_to_opus("voice.wav") # → voice.ogg
# Convert it back to MP3 (e.g. for sharing elsewhere)
vc.opus_to_mp3("voice.ogg") # → voice.mp3
API reference
| Method | Purpose |
|---|---|
VoiceConverter.mp3_to_opus(src, dst=None, bitrate="96k", vbr=True) |
Convert arbitrary audio to Opus‑encoded OGG. |
VoiceConverter.opus_to_mp3(src, dst=None, quality="2") |
Convert OGG/Opus back to MP3. |
Additionally, top‑level helpers mp3_to_opus() and opus_to_mp3() proxy to a shared converter instance.
Full docs live in the wiki.
Development
git clone https://github.com/yourname/voicegram
cd voicegram
python -m venv .venv && source .venv/bin/activate
pip install -e .[dev] # pytest, black, mypy, pre‑commit …
pytest -q
Releasing
- Bump version in
pyproject.toml. git tag vX.Y.Z && git push --tags.- GitHub Actions publishes wheels to PyPI via Trusted Publisher.
License
MIT — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file voicegram-0.0.1.tar.gz.
File metadata
- Download URL: voicegram-0.0.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dc9aaa3f17bd1f202626f83ef06afaa13244bc785d041e02b98572e7a1b2913
|
|
| MD5 |
c6dfba296769252ba2414cf5ade86822
|
|
| BLAKE2b-256 |
6b6501d42b808d563f140b9d3ce2e9bc6a65a160b98e39533de4b47c400c1f3f
|
File details
Details for the file voicegram-0.0.1-py3-none-any.whl.
File metadata
- Download URL: voicegram-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02fab9e3bea4d9d3e101d04946e184da222070291bd010d33db4f8d85101190a
|
|
| MD5 |
425930244f2361095ddfe6536753e95d
|
|
| BLAKE2b-256 |
2eb85f1c6da384e40b706600bbd386d592c5646bad4a5eacc082202fd8a14612
|