Skip to main content

Quiet Modem, to transmit data with sound

Project description

quiet.py

Python ctypes bindings for libquiet to transmit data with sound.

Requirements

  • numpy

Install

  • For ARM platform, binary package is available on pypi, just use pip to install it:

    sudo apt install python-numpy
    pip install --no-deps quiet.py
    

    We install numpy separately, as installing numpy via pip requires compiling numpy from source.

  • For x86/amd64

    sudo apt install cmake
    git clone https://github.com/xiongyihui/quiet.py && cd quiet.py
    ./scripts/libs.sh
    pip install .
    

Usage

  1. Encode a message, and then decode it
from quiet import Encode, Decoder

def test():
    encoder = Encoder()
    decoder = Decoder()

    for chunk in encoder.encode('hello, world'):
        message = decoder.decode(chunk)
        if message is not None:
            print(message)


test()
  1. decode messages from recording in realtime
import sys
import numpy
import pyaudio
from quiet import Encode, Decoder

def decode():
    if sys.version_info[0] < 3:
        import Queue as queue
    else:
        import queue

    FORMAT = pyaudio.paFloat32
    CHANNELS = 1
    RATE = 44100
    CHUNK = 16384  # int(RATE / 100)

    p = pyaudio.PyAudio()
    q = queue.Queue()

    def callback(in_data, frame_count, time_info, status):
        q.put(in_data)
        return (None, pyaudio.paContinue)

    stream = p.open(format=FORMAT,
                    channels=CHANNELS,
                    rate=RATE,
                    input=True,
                    frames_per_buffer=CHUNK,
                    stream_callback=callback)

    count = 0
    with Decoder(profile_name='ultrasonic-experimental') as decoder:
        while True:
            try:
                audio = q.get()
                audio = numpy.fromstring(audio, dtype='float32')
                # audio = audio[::CHANNELS]
                code = decoder.decode(audio)
                if code is not None:
                    count += 1
                    print(code.tostring().decode('utf-8', 'ignore'))
            except KeyboardInterrupt:
                break


decode()

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dataos-0.1-py3-none-any.whl (86.2 kB view details)

Uploaded Python 3

File details

Details for the file dataos-0.1-py3-none-any.whl.

File metadata

  • Download URL: dataos-0.1-py3-none-any.whl
  • Upload date:
  • Size: 86.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for dataos-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6dc8b7fd6f871126f3b972138113c3d0163d313e0923ae512bb6d282f96b5b33
MD5 fbebe1f6892e72eff670fe7d2e478160
BLAKE2b-256 7feb803faf1644daa3fb1f7e95be539438113f16dc09dfa65e0ee83bb1c74a72

See more details on using hashes here.

Supported by

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