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: 'Protocol' = <Protocol.ULTRASOUND_FASTEST: 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
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 pyggwave-0.4.2.7.tar.gz.
File metadata
- Download URL: pyggwave-0.4.2.7.tar.gz
- Upload date:
- Size: 157.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35e8689720386e39c9a737453374c7b376cab0302f1cd7028727799394e7736f
|
|
| MD5 |
40bd4d394aadc4a77ee7f1b2fee25871
|
|
| BLAKE2b-256 |
a138092271226c549a8db6580f235357bda0306bbb481edb6c79da548009bb59
|
File details
Details for the file pyggwave-0.4.2.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyggwave-0.4.2.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 631.7 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba304305d7e497e570d5cd019ddcc7006eac086d34ef222e9a13021e47ba30c1
|
|
| MD5 |
b3e38857ee37013d7a89920ed0dc26fb
|
|
| BLAKE2b-256 |
52fb5eb30ff32b5442b8ab830fb347dc2ab3784d96aede7ec6d7e5b04418d394
|