mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
Fix linters
This commit is contained in:
parent
800fe4a73f
commit
c6149aacef
@ -285,6 +285,7 @@ def _get_dataforseo_api_search(**kwargs: Any) -> BaseTool:
|
||||
def _get_dataforseo_api_search_json(**kwargs: Any) -> BaseTool:
|
||||
return DataForSeoAPISearchResults(api_wrapper=DataForSeoAPIWrapper(**kwargs))
|
||||
|
||||
|
||||
def _get_eleven_labs_text2speech() -> BaseTool:
|
||||
return ElevenLabsText2SpeechTool()
|
||||
|
||||
@ -344,9 +345,7 @@ _EXTRA_OPTIONAL_TOOLS: Dict[str, Tuple[Callable[[KwArg(Any)], BaseTool], List[st
|
||||
_get_dataforseo_api_search_json,
|
||||
["api_login", "api_password", "aiosession"],
|
||||
),
|
||||
"eleven_labs_text2speech": (
|
||||
_get_eleven_labs_text2speech, ["eleven_api_key"]
|
||||
)
|
||||
"eleven_labs_text2speech": (_get_eleven_labs_text2speech, ["eleven_api_key"]),
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
"""Eleven Labs Services Tools."""
|
||||
|
||||
from langchain.tools.eleven_labs.text2speech import (
|
||||
ElevenLabsText2SpeechTool
|
||||
)
|
||||
|
||||
from langchain.tools.eleven_labs.text2speech import ElevenLabsText2SpeechTool
|
||||
|
||||
__all__ = [ElevenLabsText2SpeechTool]
|
||||
|
@ -17,15 +17,14 @@ class ElevenLabsText2SpeechTool(BaseTool):
|
||||
description: str = (
|
||||
"A wrapper around Eleven Labs Text2Speech. "
|
||||
"Useful for when you need to convert text to speech. "
|
||||
"It supports multiple languages, including English, German, Polish, Spanish, Italian, French, Portuguese, and Hindi. "
|
||||
"It supports multiple languages, including English, German, Polish, "
|
||||
"Spanish, Italian, French, Portuguese, and Hindi. "
|
||||
)
|
||||
|
||||
@root_validator(pre=True)
|
||||
def validate_environment(cls, values: Dict) -> Dict:
|
||||
"""Validate that api key exists in environment."""
|
||||
_ = get_from_dict_or_env(
|
||||
values, "eleven_api_key", "ELEVEN_API_KEY"
|
||||
)
|
||||
_ = get_from_dict_or_env(values, "eleven_api_key", "ELEVEN_API_KEY")
|
||||
|
||||
return values
|
||||
|
||||
@ -39,10 +38,8 @@ class ElevenLabsText2SpeechTool(BaseTool):
|
||||
"Run `pip install elevenlabs` to install."
|
||||
)
|
||||
|
||||
speech = generate(text=text, model='eleven_multilingual_v1')
|
||||
with tempfile.NamedTemporaryFile(
|
||||
mode="bx", suffix=".wav", delete=False
|
||||
) as f:
|
||||
speech = generate(text=text, model="eleven_multilingual_v1")
|
||||
with tempfile.NamedTemporaryFile(mode="bx", suffix=".wav", delete=False) as f:
|
||||
f.write(speech)
|
||||
return f.name
|
||||
|
||||
@ -73,7 +70,7 @@ class ElevenLabsText2SpeechTool(BaseTool):
|
||||
"""Stream the text as speech."""
|
||||
|
||||
try:
|
||||
from elevenlabs import stream, generate
|
||||
from elevenlabs import generate, stream
|
||||
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
@ -81,6 +78,7 @@ class ElevenLabsText2SpeechTool(BaseTool):
|
||||
"Run `pip install elevenlabs` to install."
|
||||
)
|
||||
|
||||
speech_stream = generate(text=query, model='eleven_multilingual_v1', stream=True)
|
||||
speech_stream = generate(
|
||||
text=query, model="eleven_multilingual_v1", stream=True
|
||||
)
|
||||
stream(speech_stream)
|
||||
|
Loading…
Reference in New Issue
Block a user