From 0dfa06bd51d56f0f6038239347fa7e98c1993dc2 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 22 Oct 2014 18:06:23 +0200 Subject: [PATCH] fix doc --- doc/source/tutorial/Streaming.rst | 27 +++++++++++++++++++++++++++ doc/source/tutorial/index.rst | 1 + 2 files changed, 28 insertions(+) create mode 100644 doc/source/tutorial/Streaming.rst diff --git a/doc/source/tutorial/Streaming.rst b/doc/source/tutorial/Streaming.rst new file mode 100644 index 0000000..e6f86e6 --- /dev/null +++ b/doc/source/tutorial/Streaming.rst @@ -0,0 +1,27 @@ +.. This file is part of TimeSide + @author: Guillaume Pellerin + +================================= + Streaming encoded audio outside +================================= + +Instead of calling a pipe.run(), the chunks of an encoding processor can also be retrieved and streamed outside the pipe during the process. + +>>> import timeside +>>> from timeside.core import get_processor +>>> from timeside.tools.test_samples import samples +>>> import numpy as np +>>> audio_file = samples['sweep.wav'] +>>> decoder = get_processor('file_decoder') +>>> output = '/tmp/test.mp3' +>>> encoder = get_processor('mp3_encoder')(output, streaming=True) +>>> pipe = decoder | encoder + +Create a process callback method so that you can retrieve end send the chunks: + +>>> def streaming_callback(): +>>> for chunk in pipe.stream(): +>>> # Do something with chunk +>>> yield chunk + +Now you can use the callback to stream the audio data outside TimeSide! diff --git a/doc/source/tutorial/index.rst b/doc/source/tutorial/index.rst index ce16117..7e9ee3e 100644 --- a/doc/source/tutorial/index.rst +++ b/doc/source/tutorial/index.rst @@ -14,5 +14,6 @@ Contents: Quick start Usage of AnalyzerResult Running a pipe with previously decoded frames + Streaming encoded audio outside TimeSide -- 2.39.5