-
Notifications
You must be signed in to change notification settings - Fork 184
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
1 parent
c813030
commit 4a705be
Showing
6 changed files
with
148 additions
and
14 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
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,15 @@ | ||
from __future__ import annotations | ||
|
||
from attrs import define, field | ||
|
||
from griptape.artifacts import AudioArtifact | ||
from griptape.drivers.text_to_speech.base_text_to_speech_driver import BaseTextToSpeechDriver | ||
|
||
|
||
@define | ||
class MockTextToSpeechDriver(BaseTextToSpeechDriver): | ||
model: str = field(default="test-model", kw_only=True) | ||
mock_output: str = field(default="mock output", kw_only=True) | ||
|
||
def try_text_to_audio(self, prompts: list[str]) -> AudioArtifact: | ||
return AudioArtifact(value=self.mock_output, format="mp3") |
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
28 changes: 28 additions & 0 deletions
28
tests/unit/drivers/text_to_speech/test_base_audio_transcription_driver.py
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,28 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
|
||
from griptape.events.event_listener import EventListener | ||
from tests.mocks.mock_text_to_speech_driver import MockTextToSpeechDriver | ||
|
||
|
||
class TestBaseTextToSpeechDriver: | ||
@pytest.fixture() | ||
def driver(self): | ||
return MockTextToSpeechDriver() | ||
|
||
def test_text_to_audio_publish_events(self, driver): | ||
mock_handler = Mock() | ||
driver.add_event_listener(EventListener(handler=mock_handler)) | ||
|
||
driver.run_text_to_audio( | ||
["foo", "bar"], | ||
) | ||
|
||
call_args = mock_handler.call_args_list | ||
|
||
args, _kwargs = call_args[0] | ||
assert args[0].type == "StartTextToSpeechEvent" | ||
|
||
args, _kwargs = call_args[1] | ||
assert args[0].type == "FinishTextToSpeechEvent" |
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