Skip to main content

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)

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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file stream_converter-1.0.0.tar.gz.

File metadata

  • Download URL: stream_converter-1.0.0.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for stream_converter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 affba3e0cc32630aaf384b0df11a197e713aadd7f3ec046c962637d648c872c6
MD5 c99e7534d9063c3ec611b375e7d917c7
BLAKE2b-256 7dfc006c950e498fe36b6f872a33917f3eff62a2d595ed5959348a57e1815bba

See more details on using hashes here.

File details

Details for the file stream_converter-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stream_converter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 403687a3be55b608847fb530e8e48efaf2ec514f6de7a4674ba52d649fcf03b7
MD5 abc03a4c84fe7918b6c440ef2633b6a8
BLAKE2b-256 7e261e2d51a6fa9e17102c33c6334dbba400f6e478efe20283ec27e01ad3f6fc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page