# fetch\_media and stream.apply

**URL:** <https://support.prodi.gy/t/fetch-media-and-stream-apply/7452>\
**Category:** Uncategorized\
**Tags:** front-end, streams\
**Created:** [December 2, 2024, 9:49am UTC](https://support.prodi.gy/t/fetch-media-and-stream-apply/7452 "2024-12-02T09:49:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ft8c3](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@ft8c3](https://support.prodi.gy/u/ft8c3)\
**Post date:** [December 2, 2024, 6:46pm UTC](https://support.prodi.gy/t/fetch-media-and-stream-apply/7452/2 "2024-12-02T18:46:27Z")

</div>

I have done more testing to identify potential cause. The following code (based on [a previous question](https://support.prodi.gy/t/labeling-with-both-text-and-audio-data/7217/2)) causes `Uncaught (in promise) TypeError: Window.fetch: data:audio/mp3;base64` in **Firefox**. However, there was no error in Google Chrome. Is there a known issue for `fetch_media` in Firefox?

```python
# the recipe audio_multiple_options.py
from pathlib import Path
from typing import Union

import jinja2
import prodigy
from prodigy import set_hashes
from prodigy.components.preprocess import \
    fetch_media as fetch_media_preprocessor
from prodigy.components.stream import get_stream
from prodigy.util import msg

@prodigy.recipe(
    "multiple.choice",
    dataset=("The dataset to use", "positional", None, str),
    source=("The source data as a JSONL file", "positional", None, str),
)
def multiple_choice(
    dataset: str,
    source: str,
):
    stream = get_stream(source, loader="jsonl", input_key="audio")
    stream.apply(fetch_media_preprocessor, input_keys=["audio", "video"])
    labels = ["Label1", "Label2", "Label3"]

    def add_template(stream, labels):
        for ex in stream:
            yield set_hashes(ex)

    # custom_js = Path("custom.js").read_text()

    def before_db(examples):
        for ex in examples:
            del ex["html"]
            if "audio" in ex and ex["audio"].startswith("data:") and "path" in ex:
                ex["audio"] = ex["path"]
        return examples

    return {
        "view_id": "blocks",
        "dataset": dataset, # Name of dataset to save annotations
        "stream": add_template(stream, labels), # Incoming stream of examples
        "config": {
            "blocks": [
                {"view_id": "audio"},
                {"view_id": "html"},
            ],
        },
        "before_db": before_db,
    }

```

I used the following `.jsonl` file for testing:

```json
{"audio": "/tmp/test.mp3"}

```

---

_[View the full topic](https://support.prodi.gy/t/fetch-media-and-stream-apply/7452)._
