mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-07 01:11:22 +08:00
- by default ggwave will now output 32-bit float samples - python samples no longer use numpy - python test now decodes payload - fix buffer overflow in receive.py example
16 lines
419 B
Python
16 lines
419 B
Python
import ggwave
|
|
import pyaudio
|
|
|
|
p = pyaudio.PyAudio()
|
|
|
|
# generate audio waveform for string "hello python"
|
|
waveform = ggwave.encode("hello python", txProtocolId = 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()
|