Skip to main content

A package for applying real-time transformations on streaming data.

Project description

A simple package for applying transformations to streaming data.

Stream Conversion

This package can handle stream functions and stream generators.

Here's an example with functions:

from random import randint
from stream_converter.converter import convert_function_stream


def get_random_number() -> int:
    return randint(0, 100)


converted_stream = convert_function_stream(
    stream_function=get_random_number,
    conversion_function=lambda byte: str(byte),
)
for converted_chunk in converted_stream:
    print(converted_chunk)

And here's an example with generators:

from random import randint
from typing import Generator
from stream_converter.converter import convert_generator_stream


def get_random_number_generator() -> Generator[int, None, None]:
    while True:
        yield randint(0, 100)


converted_stream = convert_generator_stream(
    stream_generator=get_random_number_generator(),
    conversion_function=lambda int: "odd" if int % 2 else "even"
)
for converted_chunk in converted_stream:
    print(converted_chunk)

Built-In Stream Support

Microphone via PyAudio

from stream_converter.converter import convert_generator_stream, convert_function_stream
from stream_converter.microphone_stream import get_microphone_stream_generator, MicrophoneStream


# generator
converted_stream = convert_generator_stream(
    stream_generator=get_microphone_stream_generator(),
    conversion_function=lambda byte: str(byte),
)
for converted_chunk in converted_stream:
    print(converted_chunk)


# function
with MicrophoneStream() as microphone_stream:
    converted_stream = convert_function_stream(
        stream_function=microphone_stream.read,
        conversion_function=lambda byte: str(byte),
    )
    for converted_chunk in converted_stream:
        print(converted_chunk)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stream_converter-1.0.0.tar.gz (2.1 kB view hashes)

Uploaded Source

Built Distribution

stream_converter-1.0.0-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page