-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
169 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from haystack.preview.components.audio.whisper_remote import RemoteWhisperTranscriber | ||
|
||
|
||
SAMPLES_PATH = Path(__file__).parent.parent / "test_files" | ||
|
||
|
||
@pytest.mark.skipif( | ||
not os.environ.get("OPENAI_API_KEY", None), | ||
reason="Export an env var called OPENAI_API_KEY containing the OpenAI API key to run this test.", | ||
) | ||
def test_whisperremotetranscriber(): | ||
comp = RemoteWhisperTranscriber(api_key=os.environ.get("OPENAI_API_KEY")) | ||
|
||
output = comp.run( | ||
audio_files=[ | ||
SAMPLES_PATH / "audio" / "this is the content of the document.wav", | ||
str((SAMPLES_PATH / "audio" / "the context for this answer is here.wav").absolute()), | ||
open(SAMPLES_PATH / "audio" / "answer.wav", "rb"), | ||
] | ||
) | ||
docs = output.documents | ||
assert len(docs) == 3 | ||
|
||
assert "this is the content of the document." == docs[0].content.strip().lower() | ||
assert SAMPLES_PATH / "audio" / "this is the content of the document.wav" == docs[0].metadata["audio_file"] | ||
|
||
assert "the context for this answer is here." == docs[1].content.strip().lower() | ||
assert ( | ||
str((SAMPLES_PATH / "audio" / "the context for this answer is here.wav").absolute()) | ||
== docs[1].metadata["audio_file"] | ||
) | ||
|
||
assert "answer." == docs[2].content.strip().lower() | ||
assert "<<binary stream>>" == docs[2].metadata["audio_file"] |
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+97.5 KB
test/preview/test_files/audio/the context for this answer is here.wav
Binary file not shown.
Binary file added
BIN
+87.5 KB
test/preview/test_files/audio/this is the content of the document.wav
Binary file not shown.