mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-07 01:11:22 +08:00
* wip : python package * wip : minor fixes * wip : upload package to main pypi * wip : initial text encoding * wip : extending C api * wip : use map of global instances * wip : added decode functionality * update main README
17 lines
458 B
Python
17 lines
458 B
Python
import ggwave
|
|
import pyaudio
|
|
import numpy as np
|
|
|
|
p = pyaudio.PyAudio()
|
|
|
|
# generate audio waveform for string "hello python"
|
|
waveform = ggwave.encode("hello python", txProtocol = 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.stop_stream()
|
|
stream.close()
|
|
|
|
p.terminate()
|