mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-06 08:37:59 +08:00
update default parameters + python updates
- 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
This commit is contained in:
@@ -10,7 +10,7 @@ instance = ggwave.init()
|
||||
|
||||
try:
|
||||
while True:
|
||||
data = stream.read(1024)
|
||||
data = stream.read(1024, exception_on_overflow=False)
|
||||
res = ggwave.decode(instance, data)
|
||||
if (not res is None):
|
||||
try:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import ggwave
|
||||
import pyaudio
|
||||
import numpy as np
|
||||
|
||||
p = pyaudio.PyAudio()
|
||||
|
||||
@@ -8,9 +7,8 @@ p = pyaudio.PyAudio()
|
||||
waveform = ggwave.encode("hello python", txProtocolId = 1, volume = 20)
|
||||
|
||||
print("Transmitting text 'hello python' ...")
|
||||
stream = p.open(format=pyaudio.paInt16, channels=1, rate=48000, output=True, frames_per_buffer=4096)
|
||||
stream.write(np.array(waveform).astype(np.int16), len(waveform))
|
||||
stream.write(np.zeros(16*1024), 16*1024) # short silence at the end
|
||||
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user