-
Notifications
You must be signed in to change notification settings - Fork 186
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
a973dc7
commit 7b85d66
Showing
33 changed files
with
265 additions
and
106 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,33 @@ | ||
## Overview | ||
|
||
[Text to Speech Drivers](../../reference/griptape/drivers/text_to_speech/index.md) are used by [Text To Speech Engines](../engines/audio/text-to-speech-engine.md) to build and execute API calls to audio generation models. | ||
|
||
Provide a Driver when building an [Engine](../engines/audio-generation-engines.md), then pass it to a [Tool](../tools/index.md) for use by an [Agent](../structures/agents.md): | ||
|
||
### Eleven Labs | ||
|
||
The [Eleven Labs Text to Speech Driver](../../reference/griptape/drivers/text_to_speech/elevenlabs_text_to_speech_driver.md) provides support for text-to-speech models hosted by Eleven Labs. This Driver supports configurations specific to Eleven Labs, like voice selection and output format. | ||
|
||
```python | ||
import os | ||
|
||
from griptape.drivers import ElevenLabsTextToSpeechDriver | ||
from griptape.engines import TextToSpeechEngine | ||
from griptape.tools.text_to_speech_client.tool import TextToSpeechClient | ||
from griptape.structures import Agent | ||
|
||
|
||
driver = ElevenLabsTextToSpeechDriver( | ||
api_key=os.getenv("ELEVEN_LABS_API_KEY"), | ||
model="eleven_multilingual_v2", | ||
voice="Matilda", | ||
) | ||
|
||
tool = TextToSpeechClient( | ||
engine=TextToSpeechEngine( | ||
text_to_speech_driver=driver, | ||
), | ||
) | ||
|
||
Agent(tools=[tool]).run("Generate audio from this text: 'Hello, world!'") | ||
``` |
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,29 @@ | ||
## Overview | ||
|
||
[Audio Generation Engines](../../reference/griptape/engines/audio/index.md) facilitate audio generation. Audio Generation Engines provides a `run` method that accepts the necessary inputs for its particular mode and provides the request to the configured [Driver](../drivers/text-to-speech/index.md). | ||
|
||
### Text to Speech Engine | ||
|
||
This Engine facilitates synthesizing speech from text inputs. | ||
|
||
```python | ||
import os | ||
|
||
from griptape.drivers import ElevenLabsTextToSpeechDriver | ||
from griptape.engines import TextToSpeechEngine | ||
|
||
|
||
driver = ElevenLabsTextToSpeechDriver( | ||
api_key=os.getenv("ELEVEN_LABS_API_KEY"), | ||
model="eleven_multilingual_v2", | ||
voice="Rachel", | ||
) | ||
|
||
engine = TextToSpeechEngine( | ||
text_to_speech_driver=driver, | ||
) | ||
|
||
engine.run( | ||
prompts=["Hello, world!"], | ||
) | ||
``` |
27 changes: 27 additions & 0 deletions
27
docs/griptape-tools/official-tools/text-to-speech-client.md
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,27 @@ | ||
# TextToSpeechClient | ||
|
||
This tool enables LLMs to synthesize speech from text using [Text to Speech Engines](../../reference/griptape/engines/audio/text_to_speech_engine.md) and [Text to Speech Drivers](../../reference/griptape/drivers/text_to_speech/index.md). | ||
|
||
```python | ||
import os | ||
|
||
from griptape.drivers import ElevenLabsTextToSpeechDriver | ||
from griptape.engines import TextToSpeechEngine | ||
from griptape.tools.text_to_speech_client.tool import TextToSpeechClient | ||
from griptape.structures import Agent | ||
|
||
|
||
driver = ElevenLabsTextToSpeechDriver( | ||
api_key=os.getenv("ELEVEN_LABS_API_KEY"), | ||
model="eleven_multilingual_v2", | ||
voice="Matilda", | ||
) | ||
|
||
tool = TextToSpeechClient( | ||
engine=TextToSpeechEngine( | ||
text_to_speech_driver=driver, | ||
), | ||
) | ||
|
||
Agent(tools=[tool]).run("Generate audio from this text: 'Hello, world!'") | ||
``` |
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
File renamed without changes.
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
4 changes: 2 additions & 2 deletions
4
...neration/dummy_audio_generation_driver.py → ..._to_speech/dummy_text_to_speech_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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from __future__ import annotations | ||
|
||
from attr import define, field | ||
|
||
from griptape.artifacts.audio_artifact import AudioArtifact | ||
from griptape.drivers import BaseTextToSpeechDriver | ||
|
||
|
||
@define | ||
class TextToSpeechEngine: | ||
text_to_speech_driver: BaseTextToSpeechDriver = field(kw_only=True) | ||
|
||
def run(self, prompts: list[str], *args, **kwargs) -> AudioArtifact: | ||
return self.text_to_speech_driver.try_text_to_audio(prompts=prompts) |
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
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
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
Oops, something went wrong.