mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-29 18:08:36 +00:00
Fix linters, update notebook
This commit is contained in:
parent
882a588264
commit
7b7bea5424
@ -108,7 +108,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"tts.stream(text_to_speak)"
|
||||
"tts.stream_speech(text_to_speak)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -286,8 +286,8 @@ def _get_dataforseo_api_search_json(**kwargs: Any) -> BaseTool:
|
||||
return DataForSeoAPISearchResults(api_wrapper=DataForSeoAPIWrapper(**kwargs))
|
||||
|
||||
|
||||
def _get_eleven_labs_text2speech() -> BaseTool:
|
||||
return ElevenLabsText2SpeechTool()
|
||||
def _get_eleven_labs_text2speech(**kwargs: Any) -> BaseTool:
|
||||
return ElevenLabsText2SpeechTool(**kwargs)
|
||||
|
||||
|
||||
_EXTRA_LLM_TOOLS: Dict[
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
from langchain.tools.eleven_labs.text2speech import ElevenLabsText2SpeechTool
|
||||
|
||||
__all__ = [ElevenLabsText2SpeechTool]
|
||||
__all__ = ["ElevenLabsText2SpeechTool"]
|
||||
|
@ -1,6 +1,7 @@
|
||||
import tempfile
|
||||
from typing import Dict, Union
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
from langchain.callbacks.manager import CallbackManagerForToolRun
|
||||
from langchain.pydantic_v1 import root_validator
|
||||
from langchain.tools.base import BaseTool
|
||||
from langchain.tools.eleven_labs.models import ElevenLabsModel
|
||||
@ -45,7 +46,9 @@ class ElevenLabsText2SpeechTool(BaseTool):
|
||||
f.write(speech)
|
||||
return f.name
|
||||
|
||||
def _run(self, query: str) -> str:
|
||||
def _run(
|
||||
self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None
|
||||
) -> str:
|
||||
"""Use the tool."""
|
||||
try:
|
||||
speech_file = self._text2speech(query)
|
||||
@ -60,7 +63,7 @@ class ElevenLabsText2SpeechTool(BaseTool):
|
||||
|
||||
elevenlabs.play(speech)
|
||||
|
||||
def stream(self, query: str) -> None:
|
||||
def stream_speech(self, query: str) -> None:
|
||||
"""Stream the text as speech as it is generated.
|
||||
Play the text in your speakers."""
|
||||
speech_stream = elevenlabs.generate(text=query, model=self.model, stream=True)
|
||||
|
Loading…
Reference in New Issue
Block a user