From 5fbbbb5c17fc5dcbce196c49cfd14c562577c63c Mon Sep 17 00:00:00 2001 From: awinml <97467100+awinml@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:33:01 +0530 Subject: [PATCH] Add default file name --- haystack/preview/components/audio/whisper_remote.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/haystack/preview/components/audio/whisper_remote.py b/haystack/preview/components/audio/whisper_remote.py index 65f64df290..4ef4821b30 100644 --- a/haystack/preview/components/audio/whisper_remote.py +++ b/haystack/preview/components/audio/whisper_remote.py @@ -125,15 +125,11 @@ def run(self, streams: List[ByteStream]): documents = [] for stream in streams: + file = io.BytesIO(stream.data) try: - file = io.BytesIO(stream.data) file.name = stream.metadata["file_path"] - except KeyError as e: - logger.warning( - "Could not read audio file. Skipping it. Make sure the 'file_path' is present in the metadata. Error message: %s", - e, - ) - continue + except KeyError: + file.name = "audio_input.wav" content = openai.Audio.transcribe(file=file, model=self.model_name, **self.whisper_params) doc = Document(text=content["text"], metadata=stream.metadata)