Skip to content
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

community:langchain_community:tools:eleven_labs: Fix the tool #27130

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

venkatram-dev
Copy link
Contributor

@venkatram-dev venkatram-dev commented Oct 5, 2024

Thank you for contributing to LangChain!

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/langchain_community/tools/eleven_labs/text2speech.py](https://localhost:8080/#) in _run(self, query, run_manager)
     58         try:
---> 59             speech = elevenlabs.generate(text=query, model=self.model)
     60             with tempfile.NamedTemporaryFile(

AttributeError: module 'elevenlabs' has no attribute 'generate'

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
3 frames
[/usr/local/lib/python3.10/dist-packages/langchain_community/tools/eleven_labs/text2speech.py](https://localhost:8080/#) in _run(self, query, run_manager)
     64             return f.name
     65         except Exception as e:
---> 66             raise RuntimeError(f"Error while running ElevenLabsText2SpeechTool: {e}")
     67 
     68     def play(self, speech_file: str) -> None:

RuntimeError: Error while running ElevenLabsText2SpeechTool: module 'elevenlabs' has no attribute 'generate'
  • Add tests and docs: If you're adding a new integration, please include
    1. a test for the integration, preferably unit tests that do not rely on network access,
    2. an example notebook showing its use. It lives in docs/docs/integrations directory.

tested using below script

pip install --upgrade elevenlabs langchain-community


import getpass
import os
#ELEVEN_API_KEY = 'aaa'

from langchain_community.tools import ElevenLabsText2SpeechTool

text_to_speak = "Hello world! I am the real slim shady"

#tts = ElevenLabsText2SpeechTool(eleven_api_key=ELEVEN_API_KEY)
tts = ElevenLabsText2SpeechTool()
tts.name
print('tts.name',tts.name)


speech_file = tts.run(text_to_speak)
print('speech_file created')

tts.play(speech_file)
print('played speech file')

# Stream the text as speech
tts.stream_speech("This is a... streaming voice!!")

print('streaming test complete')

Ouput after the change

tts.name eleven_labs_text2speech
speech_file created
played speech file
streaming test complete

Additional guidelines:

  • Make sure optional dependencies are imported within a function.
  • Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests.
  • Most PRs should not touch more than one package.
  • Changes should be backwards compatible.
  • If you are adding something to community, do not re-import it in langchain.

If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.

Copy link

vercel bot commented Oct 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Oct 5, 2024 1:34am

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. community Related to langchain-community 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Oct 5, 2024
@venkatram-dev
Copy link
Contributor Author

venkatram-dev commented Oct 5, 2024

Before the change, gives error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/langchain_community/tools/eleven_labs/text2speech.py](https://localhost:8080/#) in _run(self, query, run_manager)
     58         try:
---> 59             speech = elevenlabs.generate(text=query, model=self.model)
     60             with tempfile.NamedTemporaryFile(

AttributeError: module 'elevenlabs' has no attribute 'generate'

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
3 frames
[/usr/local/lib/python3.10/dist-packages/langchain_community/tools/eleven_labs/text2speech.py](https://localhost:8080/#) in _run(self, query, run_manager)
     64             return f.name
     65         except Exception as e:
---> 66             raise RuntimeError(f"Error while running ElevenLabsText2SpeechTool: {e}")
     67 
     68     def play(self, speech_file: str) -> None:

RuntimeError: Error while running ElevenLabsText2SpeechTool: module 'elevenlabs' has no attribute 'generate'

After the change works good

pip install --upgrade elevenlabs langchain-community

import getpass
import os
#ELEVEN_API_KEY = 'aaa'

from langchain_community.tools import ElevenLabsText2SpeechTool

text_to_speak = "Hello world! I am the real slim shady"

#tts = ElevenLabsText2SpeechTool(eleven_api_key=ELEVEN_API_KEY)
tts = ElevenLabsText2SpeechTool()
tts.name
print('tts.name',tts.name)


speech_file = tts.run(text_to_speak)
print('speech_file created')

tts.play(speech_file)
print('played speech file')

# Stream the text as speech
tts.stream_speech("This is a... streaming voice!!")

print('streaming test complete')

Ouput after the change

tts.name eleven_labs_text2speech
speech_file created
played speech file
streaming test complete

@venkatram-dev venkatram-dev changed the title fix_community_elevenlabs_tool community:langchain_community:tools:eleven_labs: Fix the tool Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature community Related to langchain-community size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

1 participant