elevenlabs-python icon indicating copy to clipboard operation
elevenlabs-python copied to clipboard

Langchain instructions give errors about missing generate() method

Open mspertus opened this issue 1 year ago • 3 comments

When I follow the instructions for using the langchain Eleven Labs Text2SpeechTool here, I get the following error.

Type "help", "copyright", "credits" or "license" for more information.
>>> from langchain_community.tools import ElevenLabsText2SpeechTool
>>>
>>> text_to_speak = "Hello world! I am the real slim shady"
>>>
>>> tts = ElevenLabsText2SpeechTool()
>>> speech_file = tts.run(text_to_speak)
Traceback (most recent call last):
  File "C:\Users\mike\anaconda3\envs\baseClone\Lib\site-packages\langchain_community\tools\eleven_labs\text2speech.py", line 58, in _run
    speech = elevenlabs.generate(text=query, model=self.model)
             ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'elevenlabs' has no attribute 'generate'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\mike\anaconda3\envs\baseClone\Lib\site-packages\langchain_core\tools.py", line 422, in run
    raise e
  File "C:\Users\mike\anaconda3\envs\baseClone\Lib\site-packages\langchain_core\tools.py", line 381, in run
    self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
  File "C:\Users\mike\anaconda3\envs\baseClone\Lib\site-packages\langchain_community\tools\eleven_labs\text2speech.py", line 65, in _run
    raise RuntimeError(f"Error while running ElevenLabsText2SpeechTool: {e}")
RuntimeError: Error while running ElevenLabsText2SpeechTool: module 'elevenlabs' has no attribute 'generate'

My langchain package versions are langchain-0.1.14, langchain-community-0.0.31, langchain-core-0.1.38, langchain-text-splitters-0.0.1 langsmith-0.1.38 and my elevenlabs version is 1.0.3. I believe I followed the instructions in the langchain docs above correctly.

Any advice appreciated, Mike

mspertus avatar Apr 02 '24 17:04 mspertus

@mspertus it looks like langchain hasn't upgraded to v1.x of the SDK (there were some breaks from v0.x to v1.x).

dsinghvi avatar Apr 03 '24 11:04 dsinghvi

You can lower the version of elevenlabs to below 1.0. I have tried multiple times and found that the properties have not been changed above 1. x example: pip install --upgrade elevenlabs==0.2.27, it's workful for me.

HelloKevinChen avatar May 27 '24 09:05 HelloKevinChen

the same issuse

% pip list |grep -i langchain
langchain                                0.2.6
langchain-chroma                         0.1.1
langchain-community                      0.2.6
langchain-core                           0.2.10
langchain-experimental                   0.0.61
langchain-fireworks                      0.1.3
langchain-google-vertexai                1.0.6
langchain-groq                           0.1.4
langchain-openai                         0.1.8
langchain-text-splitters                 0.2.1
langchainhub                             0.1.18

baiziyuandyufei avatar Jun 26 '24 06:06 baiziyuandyufei

This Issue Still persists, @HelloKevinChen Thanks for your tip; it's workful worked for me. example: pip install --upgrade elevenlabs==0.2.27,

Pavun-KumarCH avatar Oct 07 '24 08:10 Pavun-KumarCH