Streaming using the Python SDK
Streaming using the SDK
Install the Behavioral Signals SDK from PyPI:
pip install behavioralsignals
Then you can easily start a stream as such:
from behavioralsignals import Client, StreamingOptions
from behavioralsignals.utils import make_audio_stream
cid = "<your-cid>"
token = "<your-api-token>"
file_path = "/path/to/audio.wav"
client = Client(cid, token)
audio_stream, sample_rate = make_audio_stream(file_path, chunk_size=250)
options = StreamingOptions(sample_rate=sample_rate, encoding="LINEAR_PCM")
for result in client.behavioral.stream_audio(audio_stream=audio_stream, options=options):
print(result)
- The
client.behavioral.stream_audio
method expects anIterator[bytes]
that correspond to the bytes of the audio stream. - The
StreamingOptions
define thesample rate
andencoding
of the streamed audio.
Also check the 🎤 streaming from microphone and 📁 streaming from file examples in the Github repo
Updated 22 days ago