Skip to main content

DTMF tone encoding and decoding in pure Python.

Project description

OpenTone

A data-over-sound toolkit in pure Python. OpenTone carries data through an audio channel using a family of schemes — telephone tones, modems, Morse, image transmission, and watermarking — each in its own submodule, sharing one set of WAV / synthesis / Goertzel primitives. The core schemes have no dependencies.

Install

pip install opentone            # core schemes (no dependencies)
pip install opentone[all]       # + image/DSP schemes (numpy, Pillow)

Schemes

Module What it carries Dependencies
opentone.dtmf Telephone-keypad DTMF tones (text or dial strings)
opentone.morse Morse / CW on-off keyed tones
opentone.fsk Bytes over a Bell 202 frequency-shift-keying modem
opentone.callerid Bell 202 caller-ID (SDMF / MDMF) messages
opentone.mf Multi-frequency (R1) 2-of-6 signalling
opentone.fec Reed-Solomon error correction (shared by the modems)
opentone.sstv Images over slow-scan-TV-style FM numpy, Pillow
opentone.spectrogram An image painted into the audio spectrogram numpy, Pillow
opentone.watermark Hidden data inside existing audio numpy

Quickstart

DTMF (also re-exported at the top level for backwards compatibility):

from opentone import encode_text, decode

encode_text("hello world", "message.wav")
print(decode("message.wav"))          # "hello world"

Morse:

from opentone import morse
morse.encode_text("SOS", "sos.wav")
print(morse.decode("sos.wav"))        # "SOS"

FSK modem, with optional Reed-Solomon error correction:

from opentone import fsk
fsk.encode(b"arbitrary bytes", "data.wav", nsym=8)
print(fsk.decode("data.wav", nsym=8))  # b"arbitrary bytes"

Caller-ID:

from opentone import callerid
callerid.encode("call.wav", number="5551234567", name="JARBAS AI",
                timestamp="06041530", mdmf=True)
print(callerid.decode("call.wav"))

Image into a spectrogram, and slow-scan-TV image transmission:

from opentone import spectrogram, sstv
spectrogram.encode_image("logo.png", "logo.wav")   # view the WAV's spectrogram
sstv.encode_image("photo.png", "photo.wav", width=160, height=120)
img = sstv.decode_image("photo.wav", width=160, height=120)

Hide data in existing audio:

from opentone import watermark
watermark.embed("song.wav", "marked.wav", b"owner-id")
print(watermark.extract("marked.wav", 8))   # b"owner-id"

Input audio

The tone schemes write 8 kHz mono 16-bit WAV. To decode audio from another source, convert it first:

ffmpeg -i some_file.mp3 -acodec pcm_s16le -ac 1 -ar 8000 out.wav

Documentation

Runnable scripts are in examples/.

License

MIT

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

opentone-0.1.2a2.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opentone-0.1.2a2-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file opentone-0.1.2a2.tar.gz.

File metadata

  • Download URL: opentone-0.1.2a2.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opentone-0.1.2a2.tar.gz
Algorithm Hash digest
SHA256 963cfdd9cd3de693cb84aaf3fd8c20d0e1276c4f0885096620371de11f5ac569
MD5 fd0bce476e1239c70d957670f18a1672
BLAKE2b-256 b7def687db2b8ab5fd232aca5159355272e5a461afb35d30fc1bb430bf7fa8a2

See more details on using hashes here.

File details

Details for the file opentone-0.1.2a2-py3-none-any.whl.

File metadata

  • Download URL: opentone-0.1.2a2-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opentone-0.1.2a2-py3-none-any.whl
Algorithm Hash digest
SHA256 d1d89500c4543956ea878349faeef2399bc76de57a860af1f40d8476c1d15ffa
MD5 0b2635f9c221a1f6ea6ffe0b4fe5286d
BLAKE2b-256 60c71521d5807548ce89f2fb03cd8e9273fe65a5afe3ecfb2775aee34c7a73ac

See more details on using hashes here.

Supported by

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