Skip to content

dubbing error #337

Open
Open
@wanglongpeng1

Description

@wanglongpeng1

我在使用过程中调用了这个函数
I called this function during use

def download_dubbed_file(dubbing_id: str, language_code: str) -> str:
"""
Downloads the dubbed file for a given dubbing ID and language code.

Args:
    dubbing_id: The ID of the dubbing project.
    language_code: The language code for the dubbing.

Returns:
    The file path to the downloaded dubbed file.
"""
dir_path = f"data/{dubbing_id}"
os.makedirs(dir_path, exist_ok=True)

file_path = f"{dir_path}/{language_code}.mp4"
with open(file_path, "wb") as file:
    for chunk in client.dubbing.get_dubbed_file(dubbing_id, language_code):
        file.write(chunk)

return file_path

在这一行中发生了报错
An error has occurred in this line
”for chunk in client.dubbing.get_dubbed_file(dubbing_id, language_code):
file.write(chunk)“

以下是报错信息
The following is the error message.

Traceback (most recent call last):
File "/datahdd/wyz/wlp/11LABS_Dubbings/examples/create_a_dub_from_file.py", line 65, in
result = create_dub_from_file(
^^^^^^^^^^^^^^^^^^^^^
File "/datahdd/wyz/wlp/11LABS_Dubbings/examples/create_a_dub_from_file.py", line 58, in create_dub_from_file
output_file_path = download_dubbed_file(dubbing_id, target_language)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/datahdd/wyz/wlp/11LABS_Dubbings/examples/dubbing_utils.py", line 39, in download_dubbed_file
for chunk in client.dubbing.get_dubbed_file(dubbing_id, language_code):
TypeError: 'NoneType' object is not iterable

经过排查,发现/elevenlabs/dubbing/client.py 文件中函数get_dubbed_file 返回的是None
After investigation, it was found that the function get_dubbed_file in the/elevenlabs/dubbing/client.py file returned None.,

def get_dubbed_file(
self, dubbing_id: str, language_code: str, *, request_options: typing.Optional[RequestOptions] = None
) -> None:
"""
Returns dubbed file as a streamed file. Videos will be returned in MP4 format and audio only dubs will be returned in MP3.

    Parameters:
        - dubbing_id: str. ID of the dubbing project.

        - language_code: str. ID of the language.

        - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
    ---
    from elevenlabs.client import ElevenLabs

    client = ElevenLabs(
        api_key="YOUR_API_KEY",
    )
    client.dubbing.get_dubbed_file(
        dubbing_id="dubbing_id",
        language_code="language_code",
    )
    """
    # print("在这里/anaconda3/envs/eleventlabs_wlp_t/lib/python3.11/site-packages/elevenlabs/dubbing/client.py")
    _response = self._client_wrapper.httpx_client.request(
        "GET",
        urllib.parse.urljoin(
            f"{self._client_wrapper.get_base_url()}/",
            f"v1/dubbing/{jsonable_encoder(dubbing_id)}/audio/{jsonable_encoder(language_code)}",
        ),
        params=jsonable_encoder(
            request_options.get("additional_query_parameters") if request_options is not None else None
        ),
        headers=jsonable_encoder(
            remove_none_from_dict(
                {
                    **self._client_wrapper.get_headers(),
                    **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                }
            )
        ),
        timeout=request_options.get("timeout_in_seconds")
        if request_options is not None and request_options.get("timeout_in_seconds") is not None
        else self._client_wrapper.get_timeout(),
        retries=0,
        max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
    )
    if 200 <= _response.status_code < 300:
        return
    if _response.status_code == 422:
        raise UnprocessableEntityError(
            typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json()))  # type: ignore
        )
    try:
        _response_json = _response.json()
    except JSONDecodeError:
        raise ApiError(status_code=_response.status_code, body=_response.text)
    raise ApiError(status_code=_response.status_code, body=_response_json)

我不知道是不是这个原因,是我下载的版本有问题吗?
I don't know if this is the reason. Is there a problem with the version I downloaded?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions