-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Text2Speech: Keeping speech in memory #11
base: master
Are you sure you want to change the base?
Changes from all commits
d5af48d
ffc6e8d
ed8e86a
dcb2a20
eb24bfa
dc44100
2bc6e38
c79e399
eb9ebc7
34e1b7b
18bd6e9
069f4c2
6ec0689
befb02d
8bfcb84
b525844
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import tempfile | ||
from enum import Enum | ||
from typing import Any, Dict, Optional, Union | ||
|
||
|
@@ -56,20 +55,14 @@ def _run( | |
elevenlabs = _import_elevenlabs() | ||
try: | ||
speech = elevenlabs.generate(text=query, model=self.model) | ||
with tempfile.NamedTemporaryFile( | ||
mode="bx", suffix=".wav", delete=False | ||
) as f: | ||
f.write(speech) | ||
return f.name | ||
self.play(speech) | ||
return "Speech has been generated" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think the best usage would be to have a single tool which can have different implementation provided, similar to PythonREPLTool. |
||
except Exception as e: | ||
raise RuntimeError(f"Error while running ElevenLabsText2SpeechTool: {e}") | ||
|
||
def play(self, speech_file: str) -> None: | ||
def play(self, speech: bytes) -> None: | ||
"""Play the text as speech.""" | ||
elevenlabs = _import_elevenlabs() | ||
with open(speech_file, mode="rb") as f: | ||
speech = f.read() | ||
|
||
elevenlabs.play(speech) | ||
|
||
def stream_speech(self, query: str) -> None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you breaking agents by those changes?