We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Improve the `WhisperTranscriber` API docs
The `run` function in the API reference seems to be missing the return type. This should probably be fixed in the codebase. 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `haystack/nodes/audio/whisper_transcriber.py`
Content:
```
1 import json
2 from typing import List, Optional, Dict, Any, Union, BinaryIO, Literal
3 
4 import requests
5 from requests import PreparedRequest
6 
7 from haystack import MultiLabel, Document
8 from haystack.errors import OpenAIError, OpenAIRateLimitError
9 from haystack.nodes.base import BaseComponent
10 from haystack.utils.import_utils import is_whisper_available
11 from haystack.lazy_imports import LazyImport
12 
13 
14 with LazyImport(message="Run 'pip install farm-haystack[inference]'") as torch_import:
15     import torch
16 
17 
18 WhisperModel = Literal["tiny", "small", "medium", "large", "large-v2"]
19 
20 
21 class WhisperTranscriber(BaseComponent):
22     """
23     Transcribes audio files using OpenAI's Whisper. This class supports two underlying implementations:
24 
25     - API (default): Uses the OpenAI API and requires an API key. See the [OpenAI blog post](https://beta.openai.com/docs/api-reference/whisper for more details.
26     - Local (requires installing Whisper): Uses the local installation
27     of [Whisper](https://github.com/openai/whisper).
28 
29     To use Whisper locally, install it following the instructions on
30     the Whisper [GitHub repo](https://github.com/openai/whisper) and omit the `api_key` parameter.
31     You can work around a dependency conflict caused by openai-whisper pinning an older tiktoken version than required
32     by Haystack if you install via `pip install --no-deps numba llvmlite 'openai-whisper>=20230918'`.
33 
34     To use the API implementation, provide an api_key. You can get one by signing up
35     for an [OpenAI account](https://beta.openai.com/).
36 
37     For the supported audio formats, languages, and other parameters, see the
38     [Whisper API documentation](https://platform.openai.com/docs/guides/speech-to-text) and the official Whisper
39     [github repo](https://github.com/openai/whisper).
40     """
41 
42     # If it's not a decision component, there is only one outgoing edge
43     outgoing_edges = 1
44 
45     def __init__(
46         self,
47         api_key: Optional[str] = None,
48         model_name_or_path: WhisperModel = "medium",
49         device: Optional[Union[str, "torch.device"]] = None,
50         api_base: str = "https://api.openai.com/v1",
51     ) -> None:
52         """
53         Creates a WhisperTranscriber instance.
54 
55         :param api_key: OpenAI API key. If None, a local installation of Whisper is used.
56         :param model_name_or_path: Name of the model to use. If using a local installation of Whisper, set this to one of the following values: "tiny", "small", "medium", "large", "large-v2". If using
57         the API, set this value to: "whisper-1" (default).
58         :param device: Device to use for inference. Only used if you're using a local
59         installation of Whisper. If None, the device is automatically selected.
60         :param api_base: The OpenAI API Base url, defaults to `https://api.openai.com/v1`.
61         """
62         super().__init__()
63         self.api_key = api_key
64         self.api_base = api_base
65         self.use_local_whisper = is_whisper_available() and self.api_key is None
66 
67         if self.use_local_whisper:
68             import whisper
69 
70             self._model = whisper.load_model(model_name_or_path, device=device)
71         else:
72             if api_key is None:
73                 raise ValueError(
74                     "Provide a valid api_key for OpenAI API. Alternatively, "
75                     "install OpenAI Whisper (see [Whisper](https://github.com/openai/whisper) for more details)."
76                 )
77 
78     def transcribe(
79         self,
80         audio_file: Union[str, BinaryIO],
81         language: Optional[str] = None,
82         return_segments: bool = False,
83         translate: bool = False,
84         **kwargs,
85     ) -> Dict[str, Any]:
86         """
87         Transcribe an audio file.
88 
89         :param audio_file: Path to the audio file or a binary file-like object.
90         :param language: Language of the audio file. If None, the language is automatically detected.
91         :param return_segments: If True, returns the transcription for each segment of the audio file. Supported with
92         local installation of whisper only.
93         :param translate: If True, translates the transcription to English.
94 
95         """
96         transcript: Dict[str, Any] = {}
97 
98         new_kwargs = {k: v for k, v in kwargs.items() if v is not None}
99         if language is not None:
100             new_kwargs["language"] = language
101 
102         if self.use_local_whisper:
103             new_kwargs["return_segments"] = return_segments
104             transcript = self._invoke_local(audio_file, translate, **new_kwargs)
105         elif self.api_key:
106             transcript = self._invoke_api(audio_file, translate, **new_kwargs)
107         return transcript
108 
109     def _invoke_api(
110         self, audio_file: Union[str, BinaryIO], translate: Optional[bool] = False, **kwargs
111     ) -> Dict[str, Any]:
112         if isinstance(audio_file, str):
113             with open(audio_file, "rb") as f:
114                 return self._invoke_api(f, translate, **kwargs)
115         else:
116             headers = {"Authorization": f"Bearer {self.api_key}"}
117             request = PreparedRequest()
118             url: str = (
119                 f"{self.api_base}/audio/transcriptions" if not translate else f"{self.api_base}/audio/translations"
120             )
121 
122             request.prepare(
123                 method="POST",
124                 url=url,
125                 headers=headers,
126                 data={"model": "whisper-1", **kwargs},
127                 files=[("file", (audio_file.name, audio_file, "application/octet-stream"))],
128             )
129             response = requests.post(url, data=request.body, headers=request.headers, timeout=600)
130 
131             if response.status_code != 200:
132                 openai_error: OpenAIError
133                 if response.status_code == 429:
134                     openai_error = OpenAIRateLimitError(f"API rate limit exceeded: {response.text}")
135                 else:
136                     openai_error = OpenAIError(
137                         f"OpenAI returned an error.\n"
138                         f"Status code: {response.status_code}\n"
139                         f"Response body: {response.text}",
140                         status_code=response.status_code,
141                     )
142                 raise openai_error
143 
144             return json.loads(response.content)
145 
146     def _invoke_local(
147         self, audio_file: Union[str, BinaryIO], translate: Optional[bool] = False, **kwargs
148     ) -> Dict[str, Any]:
149         torch_import.check()
150 
151         if isinstance(audio_file, str):
152             with open(audio_file, "rb") as f:
153                 return self._invoke_local(f, translate, **kwargs)
154         else:
155             return_segments = kwargs.pop("return_segments", None)
156             kwargs["task"] = "translate" if translate else "transcribe"
157             transcription = self._model.transcribe(audio_file.name, **kwargs)
158             if not return_segments:
159                 transcription.pop("segments", None)
160 
161             return transcription
162 
163     def run(
164         self,
165         query: Optional[str] = None,
166         file_paths: Optional[List[str]] = None,
167         labels: Optional[MultiLabel] = None,
168         documents: Optional[List[Document]] = None,
169         meta: Optional[dict] = None,
170     ):  # type: ignore
171         """
172         Transcribe audio files.
173 
174         :param query: Ignored
175         :param file_paths: List of paths to audio files.
176         :param labels: Ignored
177         :param documents: Ignored
178         :param meta: Ignored
179         """
180         transcribed_documents: List[Document] = []
181         if file_paths:
182             for file_path in file_paths:
183                 transcription = self.transcribe(file_path)
184                 d = Document.from_dict(transcription, field_map={"text": "content"})
185                 transcribed_documents.append(d)
186 
187         output = {"documents": transcribed_documents}
188         return output, "output_1"
189 
190     def run_batch(
191         self,
192         queries: Optional[Union[str, List[str]]] = None,
193         file_paths: Optional[List[str]] = None,
194         labels: Optional[Union[MultiLabel, List[MultiLabel]]] = None,
195         documents: Optional[Union[List[Document], List[List[Document]]]] = None,
196         meta: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None,
197         params: Optional[dict] = None,
198         debug: Optional[bool] = None,
199     ):  # type: ignore
200         """
201         Transcribe audio files.
202 
203         :param queries: Ignored
204         :param file_paths: List of paths to audio files.
205         :param labels: Ignored
206         :param documents: Ignored
207         :param meta: Ignored
208         :param params: Ignored
209         :param debug: Ignored
210         """
211         if file_paths and isinstance(file_paths[0], list):
212             all_files = []
213             for files_list in file_paths:
214                 all_files += files_list
215             return self.run(file_paths=all_files)
216         return self.run(file_paths=file_paths)
217
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/haystack/nodes/audio/whisper_transcriber.py b/haystack/nodes/audio/whisper_transcriber.py
--- a/haystack/nodes/audio/whisper_transcriber.py
+++ b/haystack/nodes/audio/whisper_transcriber.py
@@ -91,6 +91,7 @@
         :param return_segments: If True, returns the transcription for each segment of the audio file. Supported with
         local installation of whisper only.
         :param translate: If True, translates the transcription to English.
+        :return: A dictionary containing the transcription text and metadata like timings, segments etc.
 
         """
         transcript: Dict[str, Any] = {}
@@ -176,6 +177,8 @@
         :param labels: Ignored
         :param documents: Ignored
         :param meta: Ignored
+        :return: A dictionary containing a list of Document objects, one for each input file.
+
         """
         transcribed_documents: List[Document] = []
         if file_paths:

{"golden_diff": "diff --git a/haystack/nodes/audio/whisper_transcriber.py b/haystack/nodes/audio/whisper_transcriber.py\n--- a/haystack/nodes/audio/whisper_transcriber.py\n+++ b/haystack/nodes/audio/whisper_transcriber.py\n@@ -91,6 +91,7 @@\n         :param return_segments: If True, returns the transcription for each segment of the audio file. Supported with\n         local installation of whisper only.\n         :param translate: If True, translates the transcription to English.\n+        :return: A dictionary containing the transcription text and metadata like timings, segments etc.\n \n         \"\"\"\n         transcript: Dict[str, Any] = {}\n@@ -176,6 +177,8 @@\n         :param labels: Ignored\n         :param documents: Ignored\n         :param meta: Ignored\n+        :return: A dictionary containing a list of Document objects, one for each input file.\n+\n         \"\"\"\n         transcribed_documents: List[Document] = []\n         if file_paths:\n", "issue": "Improve the `WhisperTranscriber` API docs\nThe `run` function in the API reference seems to be missing the return type. This should probably be fixed in the codebase. \r\n\n", "before_files": [{"content": "import json\nfrom typing import List, Optional, Dict, Any, Union, BinaryIO, Literal\n\nimport requests\nfrom requests import PreparedRequest\n\nfrom haystack import MultiLabel, Document\nfrom haystack.errors import OpenAIError, OpenAIRateLimitError\nfrom haystack.nodes.base import BaseComponent\nfrom haystack.utils.import_utils import is_whisper_available\nfrom haystack.lazy_imports import LazyImport\n\n\nwith LazyImport(message=\"Run 'pip install farm-haystack[inference]'\") as torch_import:\n    import torch\n\n\nWhisperModel = Literal[\"tiny\", \"small\", \"medium\", \"large\", \"large-v2\"]\n\n\nclass WhisperTranscriber(BaseComponent):\n    \"\"\"\n    Transcribes audio files using OpenAI's Whisper. This class supports two underlying implementations:\n\n    - API (default): Uses the OpenAI API and requires an API key. See the [OpenAI blog post](https://beta.openai.com/docs/api-reference/whisper for more details.\n    - Local (requires installing Whisper): Uses the local installation\n    of [Whisper](https://github.com/openai/whisper).\n\n    To use Whisper locally, install it following the instructions on\n    the Whisper [GitHub repo](https://github.com/openai/whisper) and omit the `api_key` parameter.\n    You can work around a dependency conflict caused by openai-whisper pinning an older tiktoken version than required\n    by Haystack if you install via `pip install --no-deps numba llvmlite 'openai-whisper>=20230918'`.\n\n    To use the API implementation, provide an api_key. You can get one by signing up\n    for an [OpenAI account](https://beta.openai.com/).\n\n    For the supported audio formats, languages, and other parameters, see the\n    [Whisper API documentation](https://platform.openai.com/docs/guides/speech-to-text) and the official Whisper\n    [github repo](https://github.com/openai/whisper).\n    \"\"\"\n\n    # If it's not a decision component, there is only one outgoing edge\n    outgoing_edges = 1\n\n    def __init__(\n        self,\n        api_key: Optional[str] = None,\n        model_name_or_path: WhisperModel = \"medium\",\n        device: Optional[Union[str, \"torch.device\"]] = None,\n        api_base: str = \"https://api.openai.com/v1\",\n    ) -> None:\n        \"\"\"\n        Creates a WhisperTranscriber instance.\n\n        :param api_key: OpenAI API key. If None, a local installation of Whisper is used.\n        :param model_name_or_path: Name of the model to use. If using a local installation of Whisper, set this to one of the following values: \"tiny\", \"small\", \"medium\", \"large\", \"large-v2\". If using\n        the API, set this value to: \"whisper-1\" (default).\n        :param device: Device to use for inference. Only used if you're using a local\n        installation of Whisper. If None, the device is automatically selected.\n        :param api_base: The OpenAI API Base url, defaults to `https://api.openai.com/v1`.\n        \"\"\"\n        super().__init__()\n        self.api_key = api_key\n        self.api_base = api_base\n        self.use_local_whisper = is_whisper_available() and self.api_key is None\n\n        if self.use_local_whisper:\n            import whisper\n\n            self._model = whisper.load_model(model_name_or_path, device=device)\n        else:\n            if api_key is None:\n                raise ValueError(\n                    \"Provide a valid api_key for OpenAI API. Alternatively, \"\n                    \"install OpenAI Whisper (see [Whisper](https://github.com/openai/whisper) for more details).\"\n                )\n\n    def transcribe(\n        self,\n        audio_file: Union[str, BinaryIO],\n        language: Optional[str] = None,\n        return_segments: bool = False,\n        translate: bool = False,\n        **kwargs,\n    ) -> Dict[str, Any]:\n        \"\"\"\n        Transcribe an audio file.\n\n        :param audio_file: Path to the audio file or a binary file-like object.\n        :param language: Language of the audio file. If None, the language is automatically detected.\n        :param return_segments: If True, returns the transcription for each segment of the audio file. Supported with\n        local installation of whisper only.\n        :param translate: If True, translates the transcription to English.\n\n        \"\"\"\n        transcript: Dict[str, Any] = {}\n\n        new_kwargs = {k: v for k, v in kwargs.items() if v is not None}\n        if language is not None:\n            new_kwargs[\"language\"] = language\n\n        if self.use_local_whisper:\n            new_kwargs[\"return_segments\"] = return_segments\n            transcript = self._invoke_local(audio_file, translate, **new_kwargs)\n        elif self.api_key:\n            transcript = self._invoke_api(audio_file, translate, **new_kwargs)\n        return transcript\n\n    def _invoke_api(\n        self, audio_file: Union[str, BinaryIO], translate: Optional[bool] = False, **kwargs\n    ) -> Dict[str, Any]:\n        if isinstance(audio_file, str):\n            with open(audio_file, \"rb\") as f:\n                return self._invoke_api(f, translate, **kwargs)\n        else:\n            headers = {\"Authorization\": f\"Bearer {self.api_key}\"}\n            request = PreparedRequest()\n            url: str = (\n                f\"{self.api_base}/audio/transcriptions\" if not translate else f\"{self.api_base}/audio/translations\"\n            )\n\n            request.prepare(\n                method=\"POST\",\n                url=url,\n                headers=headers,\n                data={\"model\": \"whisper-1\", **kwargs},\n                files=[(\"file\", (audio_file.name, audio_file, \"application/octet-stream\"))],\n            )\n            response = requests.post(url, data=request.body, headers=request.headers, timeout=600)\n\n            if response.status_code != 200:\n                openai_error: OpenAIError\n                if response.status_code == 429:\n                    openai_error = OpenAIRateLimitError(f\"API rate limit exceeded: {response.text}\")\n                else:\n                    openai_error = OpenAIError(\n                        f\"OpenAI returned an error.\\n\"\n                        f\"Status code: {response.status_code}\\n\"\n                        f\"Response body: {response.text}\",\n                        status_code=response.status_code,\n                    )\n                raise openai_error\n\n            return json.loads(response.content)\n\n    def _invoke_local(\n        self, audio_file: Union[str, BinaryIO], translate: Optional[bool] = False, **kwargs\n    ) -> Dict[str, Any]:\n        torch_import.check()\n\n        if isinstance(audio_file, str):\n            with open(audio_file, \"rb\") as f:\n                return self._invoke_local(f, translate, **kwargs)\n        else:\n            return_segments = kwargs.pop(\"return_segments\", None)\n            kwargs[\"task\"] = \"translate\" if translate else \"transcribe\"\n            transcription = self._model.transcribe(audio_file.name, **kwargs)\n            if not return_segments:\n                transcription.pop(\"segments\", None)\n\n            return transcription\n\n    def run(\n        self,\n        query: Optional[str] = None,\n        file_paths: Optional[List[str]] = None,\n        labels: Optional[MultiLabel] = None,\n        documents: Optional[List[Document]] = None,\n        meta: Optional[dict] = None,\n    ):  # type: ignore\n        \"\"\"\n        Transcribe audio files.\n\n        :param query: Ignored\n        :param file_paths: List of paths to audio files.\n        :param labels: Ignored\n        :param documents: Ignored\n        :param meta: Ignored\n        \"\"\"\n        transcribed_documents: List[Document] = []\n        if file_paths:\n            for file_path in file_paths:\n                transcription = self.transcribe(file_path)\n                d = Document.from_dict(transcription, field_map={\"text\": \"content\"})\n                transcribed_documents.append(d)\n\n        output = {\"documents\": transcribed_documents}\n        return output, \"output_1\"\n\n    def run_batch(\n        self,\n        queries: Optional[Union[str, List[str]]] = None,\n        file_paths: Optional[List[str]] = None,\n        labels: Optional[Union[MultiLabel, List[MultiLabel]]] = None,\n        documents: Optional[Union[List[Document], List[List[Document]]]] = None,\n        meta: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None,\n        params: Optional[dict] = None,\n        debug: Optional[bool] = None,\n    ):  # type: ignore\n        \"\"\"\n        Transcribe audio files.\n\n        :param queries: Ignored\n        :param file_paths: List of paths to audio files.\n        :param labels: Ignored\n        :param documents: Ignored\n        :param meta: Ignored\n        :param params: Ignored\n        :param debug: Ignored\n        \"\"\"\n        if file_paths and isinstance(file_paths[0], list):\n            all_files = []\n            for files_list in file_paths:\n                all_files += files_list\n            return self.run(file_paths=all_files)\n        return self.run(file_paths=file_paths)\n", "path": "haystack/nodes/audio/whisper_transcriber.py"}], "after_files": [{"content": "import json\nfrom typing import List, Optional, Dict, Any, Union, BinaryIO, Literal\n\nimport requests\nfrom requests import PreparedRequest\n\nfrom haystack import MultiLabel, Document\nfrom haystack.errors import OpenAIError, OpenAIRateLimitError\nfrom haystack.nodes.base import BaseComponent\nfrom haystack.utils.import_utils import is_whisper_available\nfrom haystack.lazy_imports import LazyImport\n\n\nwith LazyImport(message=\"Run 'pip install farm-haystack[inference]'\") as torch_import:\n    import torch\n\n\nWhisperModel = Literal[\"tiny\", \"small\", \"medium\", \"large\", \"large-v2\"]\n\n\nclass WhisperTranscriber(BaseComponent):\n    \"\"\"\n    Transcribes audio files using OpenAI's Whisper. This class supports two underlying implementations:\n\n    - API (default): Uses the OpenAI API and requires an API key. See the [OpenAI blog post](https://beta.openai.com/docs/api-reference/whisper for more details.\n    - Local (requires installing Whisper): Uses the local installation\n    of [Whisper](https://github.com/openai/whisper).\n\n    To use Whisper locally, install it following the instructions on\n    the Whisper [GitHub repo](https://github.com/openai/whisper) and omit the `api_key` parameter.\n    You can work around a dependency conflict caused by openai-whisper pinning an older tiktoken version than required\n    by Haystack if you install via `pip install --no-deps numba llvmlite 'openai-whisper>=20230918'`.\n\n    To use the API implementation, provide an api_key. You can get one by signing up\n    for an [OpenAI account](https://beta.openai.com/).\n\n    For the supported audio formats, languages, and other parameters, see the\n    [Whisper API documentation](https://platform.openai.com/docs/guides/speech-to-text) and the official Whisper\n    [github repo](https://github.com/openai/whisper).\n    \"\"\"\n\n    # If it's not a decision component, there is only one outgoing edge\n    outgoing_edges = 1\n\n    def __init__(\n        self,\n        api_key: Optional[str] = None,\n        model_name_or_path: WhisperModel = \"medium\",\n        device: Optional[Union[str, \"torch.device\"]] = None,\n        api_base: str = \"https://api.openai.com/v1\",\n    ) -> None:\n        \"\"\"\n        Creates a WhisperTranscriber instance.\n\n        :param api_key: OpenAI API key. If None, a local installation of Whisper is used.\n        :param model_name_or_path: Name of the model to use. If using a local installation of Whisper, set this to one of the following values: \"tiny\", \"small\", \"medium\", \"large\", \"large-v2\". If using\n        the API, set this value to: \"whisper-1\" (default).\n        :param device: Device to use for inference. Only used if you're using a local\n        installation of Whisper. If None, the device is automatically selected.\n        :param api_base: The OpenAI API Base url, defaults to `https://api.openai.com/v1`.\n        \"\"\"\n        super().__init__()\n        self.api_key = api_key\n        self.api_base = api_base\n        self.use_local_whisper = is_whisper_available() and self.api_key is None\n\n        if self.use_local_whisper:\n            import whisper\n\n            self._model = whisper.load_model(model_name_or_path, device=device)\n        else:\n            if api_key is None:\n                raise ValueError(\n                    \"Provide a valid api_key for OpenAI API. Alternatively, \"\n                    \"install OpenAI Whisper (see [Whisper](https://github.com/openai/whisper) for more details).\"\n                )\n\n    def transcribe(\n        self,\n        audio_file: Union[str, BinaryIO],\n        language: Optional[str] = None,\n        return_segments: bool = False,\n        translate: bool = False,\n        **kwargs,\n    ) -> Dict[str, Any]:\n        \"\"\"\n        Transcribe an audio file.\n\n        :param audio_file: Path to the audio file or a binary file-like object.\n        :param language: Language of the audio file. If None, the language is automatically detected.\n        :param return_segments: If True, returns the transcription for each segment of the audio file. Supported with\n        local installation of whisper only.\n        :param translate: If True, translates the transcription to English.\n        :return: A dictionary containing the transcription text and metadata like timings, segments etc.\n\n        \"\"\"\n        transcript: Dict[str, Any] = {}\n\n        new_kwargs = {k: v for k, v in kwargs.items() if v is not None}\n        if language is not None:\n            new_kwargs[\"language\"] = language\n\n        if self.use_local_whisper:\n            new_kwargs[\"return_segments\"] = return_segments\n            transcript = self._invoke_local(audio_file, translate, **new_kwargs)\n        elif self.api_key:\n            transcript = self._invoke_api(audio_file, translate, **new_kwargs)\n        return transcript\n\n    def _invoke_api(\n        self, audio_file: Union[str, BinaryIO], translate: Optional[bool] = False, **kwargs\n    ) -> Dict[str, Any]:\n        if isinstance(audio_file, str):\n            with open(audio_file, \"rb\") as f:\n                return self._invoke_api(f, translate, **kwargs)\n        else:\n            headers = {\"Authorization\": f\"Bearer {self.api_key}\"}\n            request = PreparedRequest()\n            url: str = (\n                f\"{self.api_base}/audio/transcriptions\" if not translate else f\"{self.api_base}/audio/translations\"\n            )\n\n            request.prepare(\n                method=\"POST\",\n                url=url,\n                headers=headers,\n                data={\"model\": \"whisper-1\", **kwargs},\n                files=[(\"file\", (audio_file.name, audio_file, \"application/octet-stream\"))],\n            )\n            response = requests.post(url, data=request.body, headers=request.headers, timeout=600)\n\n            if response.status_code != 200:\n                openai_error: OpenAIError\n                if response.status_code == 429:\n                    openai_error = OpenAIRateLimitError(f\"API rate limit exceeded: {response.text}\")\n                else:\n                    openai_error = OpenAIError(\n                        f\"OpenAI returned an error.\\n\"\n                        f\"Status code: {response.status_code}\\n\"\n                        f\"Response body: {response.text}\",\n                        status_code=response.status_code,\n                    )\n                raise openai_error\n\n            return json.loads(response.content)\n\n    def _invoke_local(\n        self, audio_file: Union[str, BinaryIO], translate: Optional[bool] = False, **kwargs\n    ) -> Dict[str, Any]:\n        torch_import.check()\n\n        if isinstance(audio_file, str):\n            with open(audio_file, \"rb\") as f:\n                return self._invoke_local(f, translate, **kwargs)\n        else:\n            return_segments = kwargs.pop(\"return_segments\", None)\n            kwargs[\"task\"] = \"translate\" if translate else \"transcribe\"\n            transcription = self._model.transcribe(audio_file.name, **kwargs)\n            if not return_segments:\n                transcription.pop(\"segments\", None)\n\n            return transcription\n\n    def run(\n        self,\n        query: Optional[str] = None,\n        file_paths: Optional[List[str]] = None,\n        labels: Optional[MultiLabel] = None,\n        documents: Optional[List[Document]] = None,\n        meta: Optional[dict] = None,\n    ):  # type: ignore\n        \"\"\"\n        Transcribe audio files.\n\n        :param query: Ignored\n        :param file_paths: List of paths to audio files.\n        :param labels: Ignored\n        :param documents: Ignored\n        :param meta: Ignored\n        :return: A dictionary containing a list of Document objects, one for each input file.\n\n        \"\"\"\n        transcribed_documents: List[Document] = []\n        if file_paths:\n            for file_path in file_paths:\n                transcription = self.transcribe(file_path)\n                d = Document.from_dict(transcription, field_map={\"text\": \"content\"})\n                transcribed_documents.append(d)\n\n        output = {\"documents\": transcribed_documents}\n        return output, \"output_1\"\n\n    def run_batch(\n        self,\n        queries: Optional[Union[str, List[str]]] = None,\n        file_paths: Optional[List[str]] = None,\n        labels: Optional[Union[MultiLabel, List[MultiLabel]]] = None,\n        documents: Optional[Union[List[Document], List[List[Document]]]] = None,\n        meta: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None,\n        params: Optional[dict] = None,\n        debug: Optional[bool] = None,\n    ):  # type: ignore\n        \"\"\"\n        Transcribe audio files.\n\n        :param queries: Ignored\n        :param file_paths: List of paths to audio files.\n        :param labels: Ignored\n        :param documents: Ignored\n        :param meta: Ignored\n        :param params: Ignored\n        :param debug: Ignored\n        \"\"\"\n        if file_paths and isinstance(file_paths[0], list):\n            all_files = []\n            for files_list in file_paths:\n                all_files += files_list\n            return self.run(file_paths=all_files)\n        return self.run(file_paths=file_paths)\n", "path": "haystack/nodes/audio/whisper_transcriber.py"}]}