功能需求
Elevenlabs的langchain API集成应该包含一个非常重要的参数voice
。
动机
如果没有voice参数,Elevenlabs的langchain集成将无法使用,因为play()
在每次执行时都会随机切换语音。
你的贡献
我追踪到了Elevenlabs-langchain集成API中相关的代码,一直到这个部分:
def _run(
self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None
) -> str:
"""Use the tool."""
elevenlabs = _import_elevenlabs()
try:
speech = elevenlabs.generate(text=query, model=self.model)
with tempfile.NamedTemporaryFile(
mode="bx", suffix=".wav", delete=False
) as f:
f.write(speech)
return f.name
except Exception as e:
raise RuntimeError(f"Error while running ElevenLabsText2SpeechTool: {e}")
[[docs]](https://api.python.langchain.com/en/latest/tools/langchain.tools.eleven_labs.text2speech.ElevenLabsText2SpeechTool.html#langchain.tools.eleven_labs.text2speech.ElevenLabsText2SpeechTool.play) def play(self, speech_file: str) -> None:
"""Play the text as speech."""
elevenlabs = _import_elevenlabs()
with open(speech_file, mode="rb") as f:
speech = f.read()
elevenlabs.play(speech)
[[docs]](https://api.python.langchain.com/en/latest/tools/langchain.tools.eleven_labs.text2speech.ElevenLabsText2SpeechTool.html#langchain.tools.eleven_labs.text2speech.ElevenLabsText2SpeechTool.stream_speech) def stream_speech(self, query: str) -> None:
"""Stream the text as speech as it is generated.
Play the text in your speakers."""
elevenlabs = _import_elevenlabs()
speech_stream = elevenlabs.generate(text=query, model=self.model, stream=True)
elevenlabs.stream(speech_stream)
必须用voice
参数扩展对elevenlabs.generate
和elevenlabs.play
的调用。
在此更改后,可以像从ElevenLabs API发出的调用一样进行langchain调用run
、play
以及最重要的是stream_speech
,例如在这个仓库中看到的:
prediction = agent_chain.run(input=user_input.text)
audio = generate(
text=prediction,
voice="Adam",
model="eleven_monolingual_v1"
)
5条答案
按热度按时间hpxqektj1#
你好,@agilebean
我正在帮助LangChain团队管理他们的待办事项列表,并将此问题标记为过时。你打开的问题请求将“voice”参数集成到Elevenlabs-langchain API中,以解决每次执行“play()”函数时随机切换声音的问题。该问题没有进一步的活动或评论。
请问这个问题是否仍然与LangChain仓库的最新版本相关?如果是,请在问题上发表评论通知LangChain团队。否则,请随意关闭此问题,或者它将在7天后自动关闭。谢谢!
2ul0zpep2#
修复这个问题仍然有效且相关。如果不修复,ElevenLabs的API将无法使用!
ycl3bljg3#
@baskaryan, could you please assist @agilebean with the integration of the 'voice' parameter into the Elevenlabs-langchain API? The issue is still relevant and crucial for the usability of the API. Thank you!
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
jdg4fx2g4#
我也需要这个功能。
wyyhbhjk5#
请重新打开,否则Elevenlabs API将无法使用!