elevenlabs / elevenlabs-python

The official Python API for ElevenLabs Text to Speech.
https://elevenlabs.io/docs/api-reference/getting-started
MIT License
1.99k stars 222 forks source link

Langchain instructions give errors about missing generate() method #244

Open mspertus opened 3 months ago

mspertus commented 3 months ago

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

dsinghvi commented 3 months ago

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

HelloKevinChen commented 1 month ago

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.

baiziyuandyufei commented 1 week ago

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