Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import tempfile
from enum import Enum
from typing import Any, Dict, Optional, Union

from langchain_core.callbacks import CallbackManagerForToolRun
from langchain_core.tools import BaseTool
from langchain_core.utils import get_from_dict_or_env
from pydantic import model_validator

from types import GeneratorType

Check failure on line 10 in libs/community/langchain_community/tools/eleven_labs/text2speech.py

View workflow job for this annotation

GitHub Actions / cd libs/community / Python 3.11

Ruff (I001)

langchain_community/tools/eleven_labs/text2speech.py:1:1: I001 Import block is un-sorted or un-formatted


def _import_elevenlabs() -> Any:
try:
Expand Down Expand Up @@ -68,7 +70,11 @@
with tempfile.NamedTemporaryFile(
mode="bx", suffix=".mp3", delete=False
) as f:
f.write(speech)
if isinstance(speech, GeneratorType):
for byte_chunk in speech:
f.write(byte_chunk)
else:
f.write(speech)
return f.name
except Exception as e:
raise RuntimeError(f"Error while running ElevenLabsText2SpeechTool: {e}")
Expand Down
Loading