======
ggwave
======
Tiny data-over-sound library.
.. code:: python
# generate audio waveform for string "hello python"
waveform = ggwave.encode("hello python")
# decode audio waveform
text = ggwave.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 ggwave
---
API
---
encode()
--------
.. code:: python
encode(payload, [protocolId], [volume], [instance])
Encodes ``payload`` into an audio waveform.
Output of ``help(ggwave.encode)``:
.. code::
built-in function encode in module ggwave
encode(...)
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()
--------
.. code:: python
decode(instance, waveform)
Analyzes and decodes ``waveform`` into to try and obtain the original payload.
A preallocated ggwave ``instance`` is required.
Output of ``help(ggwave.decode)``:
.. code::
built-in function decode in module ggwave
decode(...)
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:
.. code:: python
import ggwave
import pyaudio
p = pyaudio.PyAudio()
# generate audio waveform for string "hello python"
waveform = ggwave.encode("hello python", protocolId = 1, volume = 20)
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)
stream.stop_stream()
stream.close()
p.terminate()
* Capture and decode audio data:
.. code:: python
import ggwave
import pyaudio
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, input=True, frames_per_buffer=1024)
print('Listening ... Press Ctrl+C to stop')
instance = ggwave.init()
try:
while True:
data = stream.read(1024, exception_on_overflow=False)
res = ggwave.decode(instance, data)
if (not res is None):
try:
print('Received text: ' + res.decode("utf-8"))
except:
pass
except KeyboardInterrupt:
pass
ggwave.free(instance)
stream.stop_stream()
stream.close()
p.terminate()
----
More
----
Check out `<http://github.com/ggerganov/ggwave>`_ for more information about ggwave!
-----------
Development
-----------
Check out `ggwave python package on Github <https://github.com/ggerganov/ggwave/tree/master/bindings/python>`_.
Raw data
{
"_id": null,
"home_page": "https://github.com/ggerganov/ggwave",
"name": "ggwave-fork",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "data-over-sound fsk ecc serverless pairing qrcode ultrasound",
"author": "Georgi Gerganov",
"author_email": "ggerganov@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5f/86/82ab032f51740b3309b85f328f1ac89248f1e76010d9efc06c6debe579a3/ggwave_fork-0.4.2.tar.gz",
"platform": null,
"description": "\n======\nggwave\n======\n\nTiny data-over-sound library.\n\n\n.. code:: python\n\n # generate audio waveform for string \"hello python\"\n waveform = ggwave.encode(\"hello python\")\n\n # decode audio waveform\n text = ggwave.decode(instance, waveform)\n\n\n--------\nFeatures\n--------\n\n* Audible and ultrasound transmissions available\n* Bandwidth of 8-16 bytes/s (depending on the transmission protocol)\n* Robust FSK modulation\n* Reed-Solomon based error correction\n\n------------\nInstallation\n------------\n::\n\n pip install ggwave\n\n---\nAPI\n---\n\nencode()\n--------\n\n.. code:: python\n\n encode(payload, [protocolId], [volume], [instance])\n\nEncodes ``payload`` into an audio waveform.\n\n\nOutput of ``help(ggwave.encode)``:\n\n.. code::\n\n built-in function encode in module ggwave\n \n encode(...)\n Encode payload into an audio waveform.\n @param {string} payload, the data to be encoded\n @return Generated audio waveform bytes representing 16-bit signed integer samples.\n \n\ndecode()\n--------\n\n.. code:: python\n\n decode(instance, waveform)\n\nAnalyzes and decodes ``waveform`` into to try and obtain the original payload.\nA preallocated ggwave ``instance`` is required.\n\n\nOutput of ``help(ggwave.decode)``:\n\n.. code::\n\n built-in function decode in module ggwave\n \n decode(...)\n Analyze and decode audio waveform to obtain original payload\n @param {bytes} waveform, the audio waveform to decode\n @return The decoded payload if successful.\n \n\n\n-----\nUsage\n-----\n\n* Encode and transmit data with sound:\n\n.. code:: python\n\n import ggwave\n import pyaudio\n\n p = pyaudio.PyAudio()\n\n # generate audio waveform for string \"hello python\"\n waveform = ggwave.encode(\"hello python\", protocolId = 1, volume = 20)\n\n print(\"Transmitting text 'hello python' ...\")\n stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, output=True, frames_per_buffer=4096)\n stream.write(waveform, len(waveform)//4)\n stream.stop_stream()\n stream.close()\n\n p.terminate()\n\n* Capture and decode audio data:\n\n.. code:: python\n\n import ggwave\n import pyaudio\n\n p = pyaudio.PyAudio()\n\n stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, input=True, frames_per_buffer=1024)\n\n print('Listening ... Press Ctrl+C to stop')\n instance = ggwave.init()\n\n try:\n while True:\n data = stream.read(1024, exception_on_overflow=False)\n res = ggwave.decode(instance, data)\n if (not res is None):\n try:\n print('Received text: ' + res.decode(\"utf-8\"))\n except:\n pass\n except KeyboardInterrupt:\n pass\n\n ggwave.free(instance)\n\n stream.stop_stream()\n stream.close()\n\n p.terminate()\n\n----\nMore\n----\n\nCheck out `<http://github.com/ggerganov/ggwave>`_ for more information about ggwave!\n\n-----------\nDevelopment\n-----------\n\nCheck out `ggwave python package on Github <https://github.com/ggerganov/ggwave/tree/master/bindings/python>`_.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Tiny data-over-sound library.",
"version": "0.4.2",
"project_urls": {
"Homepage": "https://github.com/ggerganov/ggwave"
},
"split_keywords": [
"data-over-sound",
"fsk",
"ecc",
"serverless",
"pairing",
"qrcode",
"ultrasound"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fb4fff26b4a8151d0fba53508f179af5a4522a667889d90221a160cdbbb97b97",
"md5": "750c4720312bf5743f9d3082a263230e",
"sha256": "a37d5cd2d1fdc54bb2cf72dc57cb8ba4b6cbef292f87e2d26c727e92b5a78222"
},
"downloads": -1,
"filename": "ggwave_fork-0.4.2-cp311-cp311-macosx_14_0_arm64.whl",
"has_sig": false,
"md5_digest": "750c4720312bf5743f9d3082a263230e",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 56378,
"upload_time": "2024-07-11T07:35:02",
"upload_time_iso_8601": "2024-07-11T07:35:02.605023Z",
"url": "https://files.pythonhosted.org/packages/fb/4f/ff26b4a8151d0fba53508f179af5a4522a667889d90221a160cdbbb97b97/ggwave_fork-0.4.2-cp311-cp311-macosx_14_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5f8682ab032f51740b3309b85f328f1ac89248f1e76010d9efc06c6debe579a3",
"md5": "c5cc87a14db590fef5ca01c67ddaaa8b",
"sha256": "58e127da2f373f68752530b0f589e6c7b3da6e1d750f44b9bbe4f9d14057eabd"
},
"downloads": -1,
"filename": "ggwave_fork-0.4.2.tar.gz",
"has_sig": false,
"md5_digest": "c5cc87a14db590fef5ca01c67ddaaa8b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 76698,
"upload_time": "2024-07-11T07:35:05",
"upload_time_iso_8601": "2024-07-11T07:35:05.165859Z",
"url": "https://files.pythonhosted.org/packages/5f/86/82ab032f51740b3309b85f328f1ac89248f1e76010d9efc06c6debe579a3/ggwave_fork-0.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-11 07:35:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ggerganov",
"github_project": "ggwave",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ggwave-fork"
}