Skip to main content

Tiny data-over-sound library with better documentation and more functions.

Project description

A fork of tiny data-over-sound library with improved documentation and Python compatibility.

# generate audio waveform for string "hello python"
waveform = pyggwave.encode("hello python")

# decode audio waveform
text = pyggwave.decode(instance, waveform)

Features

  • Audible and ultrasound transmissions available

  • Bandwidth of 8-16 bytes/s (depending on the transmission protocol)

  • Robust FSK modulation

  • Reed-Solomon based error correction

Installation

pip install pyggwave

API

encode()

encode(payload, [protocolId], [volume], [instance])

Encodes payload into an audio waveform.

Output of help(pyggwave.encode):

cython_function_or_method in module pyggwave

encode(
    self,
    payload: 'bytes | str',
    protocol_id: 'int' = 5,
    volume: 'int' = 100
) -> 'bytes'
    Encode payload into an audio waveform.
    @param {string} payload, the data to be encoded
    @return Generated audio waveform bytes representing 16-bit signed integer samples.

decode()

decode(instance, waveform)

Analyzes and decodes waveform into to try and obtain the original payload. A preallocated pyggwave instance is required.

Output of help(pyggwave.decode):

cython_function_or_method in module pyggwave

decode(self, frame: 'bytes') -> 'bytes | None'
    Analyze and decode audio waveform to obtain original payload
    @param {bytes} waveform, the audio waveform to decode
    @return The decoded payload if successful.

Usage

  • Encode and transmit data with sound:

import pyggwave
import pyaudio

p = pyaudio.PyAudio()

ggwave = pyggwave.GGWave()

# generate audio waveform for string "hello python"
waveform = ggwave.encode("hello python", protocol_id=3)

print("Transmitting text 'hello python' ...")
stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, output=True, frames_per_buffer=4096)
stream.write(waveform, len(waveform) // 4)

ggwave.free()

stream.stop_stream()
stream.close()

p.terminate()
  • Capture and decode audio data:

import pyggwave
import pyaudio

p = pyaudio.PyAudio()

ggwave = pyggwave.GGWave()

stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, input=True, frames_per_buffer=1024)

print('Listening ... Press Ctrl+C to stop')

try:
    while True:
        data = stream.read(1024, exception_on_overflow=False)
        res = ggwave.decode(data)

        if res:
            try:
                print('Received text: ' + res.decode("utf-8"))
            except as exc:
                print(exc)
except KeyboardInterrupt:
    pass

ggwave.free()

stream.stop_stream()
stream.close()

p.terminate()

More

Check out http://github.com/ggerganov/ggwave for more information about ggwave!

Development

Check out pyggwave python package on Github.

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

pyggwave-0.4.2.6.tar.gz (123.5 kB view details)

Uploaded Source

Built Distribution

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

pyggwave-0.4.2.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (110.4 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64manylinux: glibc 2.24+ x86-64

File details

Details for the file pyggwave-0.4.2.6.tar.gz.

File metadata

  • Download URL: pyggwave-0.4.2.6.tar.gz
  • Upload date:
  • Size: 123.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for pyggwave-0.4.2.6.tar.gz
Algorithm Hash digest
SHA256 1139ff2118920a95a8834642ab55ba84b8dd1e76663994f66e45a7900adcc498
MD5 25c66de6e5ed97ee9dbd07d8788844b7
BLAKE2b-256 610b7c1ff4eb3ff309247357b161b3f46dbd3c140bd1d34c9ea16b9ef8e5eb60

See more details on using hashes here.

File details

Details for the file pyggwave-0.4.2.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pyggwave-0.4.2.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 ff1009642c4ff2a70962a1d8597ed5b06bfe88a0f852ec7cbf0f70d4f9807808
MD5 7f541b07e27cf98b36112e3536d6c1a4
BLAKE2b-256 aeae28dbc6fe897afe25dc0853f289cc0b4e5f7308973198d64110174bfa7e4f

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