Skip to content

Commit

Permalink
Add default file name
Browse files Browse the repository at this point in the history
  • Loading branch information
awinml committed Oct 26, 2023
1 parent 3714122 commit 5fbbbb5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions haystack/preview/components/audio/whisper_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5fbbbb5

Please sign in to comment.