> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Strumieniowanie

API ElevenLabs obsługuje strumieniowanie audio w czasie rzeczywistym dla wybranych endpointów. Zwraca surowe bajty audio (np. dane MP3) bezpośrednio przez HTTP z użyciem kodowania chunked transfer. Dzięki temu klienci mogą stopniowo przetwarzać lub odtwarzać audio podczas generowania.

Nasze oficjalne biblioteki [Node](https://github.com/elevenlabs/elevenlabs-js) i [Python](https://github.com/elevenlabs/elevenlabs-python) zawierają narzędzia ułatwiające obsługę tego ciągłego strumienia audio.

Strumieniowanie jest obsługiwane przez [Text to Speech API](/docs/pl/api-reference/text-to-speech/stream), [Voice Changer API](/docs/pl/api-reference/speech-to-speech/stream) i [Audio Isolation API](/docs/pl/api-reference/audio-isolation/stream). Ta sekcja opisuje działanie strumieniowania dla żądań do Text to Speech API.

W Pythonie żądanie strumieniowe wygląda tak:

```python
from elevenlabs import stream
from elevenlabs.client import ElevenLabs

elevenlabs = ElevenLabs()

audio_stream = elevenlabs.text_to_speech.stream(
    text="This is a test",
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    model_id="eleven_multilingual_v2"
)

# option 1: play the streamed audio locally
stream(audio_stream)

# option 2: process the audio bytes manually
for chunk in audio_stream:
    if isinstance(chunk, bytes):
        print(chunk)
```

W Node / Typescript żądanie strumieniowe wygląda tak:

```javascript maxLines=0
import { ElevenLabsClient, stream } from "@elevenlabs/elevenlabs-js";
import { Readable } from "stream";

const elevenlabs = new ElevenLabsClient();

async function main() {
  const audioStream = await elevenlabs.textToSpeech.stream("JBFqnCBsd6RMkjVDRZzb", {
    text: "This is a test",
    modelId: "eleven_v4",
  });

  // option 1: play the streamed audio locally
  await stream(Readable.from(audioStream));

  // option 2: process the audio manually
  for await (const chunk of audioStream) {
    console.log(chunk);
  }
}

main();
```