Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAlpha VantageApifyArXivAWS LambdaShell (bash)Bearly Code InterpreterBing SearchBrave SearchChatGPT PluginsDall-E Image GeneratorDataForSeoDuckDuckGo SearchEden AIEleven Labs Text2SpeechFile SystemGolden QueryGoogle DriveGoogle PlacesGoogle SearchGoogle SerperGradioGraphQLHuggingFace Hub ToolsHuman as a toolIFTTT WebHooksLemon AgentMetaphor SearchNuclia UnderstandingOpenWeatherMapPubMedRequestsSceneXplainSearch ToolsSearchApiSearxNG SearchSerpAPITwilioWikipediaWolfram AlphaYahoo Finance NewsYouTubeZapier Natural Language ActionsAgents and toolkitsMemoryCallbacksChat loadersComponentsToolsEleven Labs Text2SpeechOn this pageEleven Labs Text2SpeechThis notebook shows how to interact with the ElevenLabs API to achieve text-to-speech capabilities.First, you need to set up an ElevenLabs account. You can follow the instructions here.# !pip install elevenlabsimport osos.environ["ELEVEN_API_KEY"] = ""Usage‚Äãfrom langchain.tools import ElevenLabsText2SpeechTooltext_to_speak = "Hello world! I am the real slim shady"tts = ElevenLabsText2SpeechTool()tts.name    'eleven_labs_text2speech'We can generate audio, save it to the temporary file and then play it.speech_file = tts.run(text_to_speak)tts.play(speech_file)Or stream audio directly.tts.stream_speech(text_to_speak)Use within an Agent‚Äãfrom langchain.llms import OpenAIfrom langchain.agents import initialize_agent, AgentType, load_toolsllm = OpenAI(temperature=0)tools = load_tools(["eleven_labs_text2speech"])agent = initialize_agent(    tools=tools,    llm=llm,    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,    verbose=True,)audio_file = agent.run("Tell me a joke and read it out for me.")            > Entering new AgentExecutor chain...
This notebook shows how to interact with the ElevenLabs API to achieve text-to-speech capabilities.
This notebook shows how to interact with the ElevenLabs API to achieve text-to-speech capabilities. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAlpha VantageApifyArXivAWS LambdaShell (bash)Bearly Code InterpreterBing SearchBrave SearchChatGPT PluginsDall-E Image GeneratorDataForSeoDuckDuckGo SearchEden AIEleven Labs Text2SpeechFile SystemGolden QueryGoogle DriveGoogle PlacesGoogle SearchGoogle SerperGradioGraphQLHuggingFace Hub ToolsHuman as a toolIFTTT WebHooksLemon AgentMetaphor SearchNuclia UnderstandingOpenWeatherMapPubMedRequestsSceneXplainSearch ToolsSearchApiSearxNG SearchSerpAPITwilioWikipediaWolfram AlphaYahoo Finance NewsYouTubeZapier Natural Language ActionsAgents and toolkitsMemoryCallbacksChat loadersComponentsToolsEleven Labs Text2SpeechOn this pageEleven Labs Text2SpeechThis notebook shows how to interact with the ElevenLabs API to achieve text-to-speech capabilities.First, you need to set up an ElevenLabs account. You can follow the instructions here.# !pip install elevenlabsimport osos.environ["ELEVEN_API_KEY"] = ""Usage‚Äãfrom langchain.tools import ElevenLabsText2SpeechTooltext_to_speak = "Hello world! I am the real slim shady"tts = ElevenLabsText2SpeechTool()tts.name    'eleven_labs_text2speech'We can generate audio, save it to the temporary file and then play it.speech_file = tts.run(text_to_speak)tts.play(speech_file)Or stream audio directly.tts.stream_speech(text_to_speak)Use within an Agent‚Äãfrom langchain.llms import OpenAIfrom langchain.agents import initialize_agent, AgentType, load_toolsllm = OpenAI(temperature=0)tools = load_tools(["eleven_labs_text2speech"])agent = initialize_agent(    tools=tools,    llm=llm,    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,    verbose=True,)audio_file = agent.run("Tell me a joke and read it out for me.")            > Entering new AgentExecutor chain...