Overview

The @outspeed.streaming_endpoint decorator is used to define asynchronous functions that handle streaming data in outspeed applications. This decorator allows the function to process continuous streams of data such as audio, video, or any other streamable data types.

Creating Streaming Functions

Streaming functions are defined using the @outspeed.streaming_endpoint decorator. Below is an example of how to create a streaming function that processes audio and video streams:

import outspeed as sp

@sp.App()
class MediaProcessor:

    @sp.streaming_endpoint()
    async def run(self, audio_input: sp.AudioStream, video_input: sp.VideoStream):
    # Process the incoming streams
        processed_audio = await self.process_audio(audio_input)
        processed_video = await self.process_video(video_input)
        return processed_audio, processed_video

Note the type hints in the function’s arguments. These are strictly required. Type hints are picked up by the outspeed package, and are used to generate the streams.

Specifying Additional Data for Streaming Functions

You can customize the environment of your streaming functions using various parameters in the @outspeed.streaming_endpoint decorator:

ParameterTypeDescriptionDefault
namestrDefines the name of the streaming functionDefault is determined by the system
python_versionstrSpecifies the Python version to be usedDefault is determined by the system
python_packagesList[str]Specifies additional Python packages to be installed[]
system_packagesList[str]Specifies additional system packages to be installed[]
metadataoutspeed.MetadataProvides additional metadata about the function to be displayed on the dashboardNone

These parameters help tailor the execution environment to the specific needs of your streaming function, ensuring optimal performance and compatibility.