|
5 | 5 | import pytest |
6 | 6 |
|
7 | 7 | from haystack import Pipeline |
8 | | -from haystack.components.audio import LocalWhisperTranscriber |
9 | 8 | from haystack.components.audio.whisper_remote import RemoteWhisperTranscriber |
10 | 9 | from haystack.components.fetchers import LinkContentFetcher |
11 | 10 | from haystack.dataclasses import ByteStream |
@@ -100,7 +99,7 @@ def test_to_dict_with_custom_init_parameters(self, monkeypatch): |
100 | 99 | }, |
101 | 100 | } |
102 | 101 |
|
103 | | - def test_from_dict_with_defualt_parameters(self, monkeypatch): |
| 102 | + def test_from_dict_with_default_parameters(self, monkeypatch): |
104 | 103 | monkeypatch.setenv("OPENAI_API_KEY", "test_api_key") |
105 | 104 |
|
106 | 105 | data = { |
@@ -147,7 +146,7 @@ def test_from_dict_with_custom_init_parameters(self, monkeypatch): |
147 | 146 | "temperature": "0.5", |
148 | 147 | } |
149 | 148 |
|
150 | | - def test_from_dict_with_defualt_parameters_no_env_var(self, monkeypatch): |
| 149 | + def test_from_dict_with_default_parameters_no_env_var(self, monkeypatch): |
151 | 150 | monkeypatch.delenv("OPENAI_API_KEY", raising=False) |
152 | 151 |
|
153 | 152 | data = { |
@@ -189,3 +188,25 @@ def test_whisper_remote_transcriber(self, test_files_path): |
189 | 188 | assert str(test_files_path / "audio" / "the context for this answer is here.wav") == docs[1].meta["file_path"] |
190 | 189 |
|
191 | 190 | assert docs[2].content.strip().lower() == "answer." |
| 191 | + |
| 192 | + @pytest.mark.skipif( |
| 193 | + not os.environ.get("OPENAI_API_KEY", None), |
| 194 | + reason="Export an env var called OPENAI_API_KEY containing the OpenAI API key to run this test.", |
| 195 | + ) |
| 196 | + @pytest.mark.integration |
| 197 | + def test_whisper_remote_transcriber_pipeline_and_url_source(self): |
| 198 | + pipe = Pipeline() |
| 199 | + pipe.add_component("fetcher", LinkContentFetcher()) |
| 200 | + pipe.add_component("transcriber", RemoteWhisperTranscriber()) |
| 201 | + |
| 202 | + pipe.connect("fetcher", "transcriber") |
| 203 | + result = pipe.run( |
| 204 | + data={ |
| 205 | + "fetcher": { |
| 206 | + "urls": [ |
| 207 | + "https://github.com/deepset-ai/haystack/raw/refs/heads/main/test/test_files/audio/MLK_Something_happening.mp3" |
| 208 | + ] # noqa: E501 |
| 209 | + } |
| 210 | + } |
| 211 | + ) |
| 212 | + assert "masses of people" in result["transcriber"]["documents"][0].content |
0 commit comments