GithubHelp home page GithubHelp logo

Comments (6)

ThioJoe avatar ThioJoe commented on July 28, 2024

Hm I’ll have to investigate. But I think it might be because elevenlabs returned an error. Notice how up higher it says “Error 400”. So it didnt return a file which would explain why the script couldn’t find one. I’ll have to add more detailed error handling so it’s more obvious what the problem is exactly.

Also it looks like it might be an API key issue: https://help.elevenlabs.io/hc/en-us/articles/19572237925521-API-Error-Code-400-or-401-API-Key-

Did you set an API key with the elevenlabs_api_key setting in the cloud_service_settings.ini file?

from auto-synced-translated-dubs.

ThioJoe avatar ThioJoe commented on July 28, 2024

With the latest release it should provide a proper error message to explain what went wrong.

from auto-synced-translated-dubs.

RafaelGodoyEbert avatar RafaelGodoyEbert commented on July 28, 2024

Yes, I placed the API in the correct location.

Below the error appeared

image

But in the end I created my own code to work with my API

So for me it's ok, I'm already using elevenlabs with my additional code, I just changed some things to recognize it.

I'm just contacting you to alert you to the error.

If you correct or find the solution or error I'm making, I'll use your code again.

 

I edited Scripts/TTS.py and added

script_path = os.path.join(current_directory, "ElevenlabsAPI.py")

def synthesize_text_elevenlabsapi(text, languageCode, TTS_FilePath, subtitle_num):
    # Chamada ao script srt2edge-tts.py usando subprocess
    subprocess.run(["python", script_path, text, languageCode, TTS_FilePath, subtitle_num])

and

elif cloudConfig['tts_service'] == "elevenlabsapi":
                synthesize_text_elevenlabsapi(value['translated_text'], langDict['languageCode'], 'workingFolder', str(key))

so I could use the file below in isolation from the others.

import asyncio
from elevenlabs import generate, set_api_key
import os
import sys

async def generate_tts(text, output_file, voice):
    audio_data = generate(
        text=text,
        voice=voice,
        model='eleven_multilingual_v2'
    )
    with open(output_file, "wb") as audio_file:
        audio_file.write(audio_data)

async def amain(text, languageCode, output_folder, subtitle_num) -> None:
    try:
        set_api_key("API_KEY")
        # O código relacionado ao mapeamento de voz não é necessário com a API Eleven Labs,
        # pois a API já lida com a seleção de voz.
        voice = "Charlie"  # Substitua pela voz desejada
    except Exception as e:
        print(f"Exceção: {e}")

    if voice:
        if not os.path.exists(output_folder):
            os.makedirs(output_folder)

        tts_output_file = os.path.join(output_folder, f"{subtitle_num}.mp3")

        await generate_tts(text, tts_output_file, voice)

    else:
        print(f"Idioma {languageCode} não suportado.")
        print(f"Lang Code: '{languageCode}'")
        print(f"Voice: {voice}")

def main():
    if len(sys.argv) != 5:
        print("Uso: python srt2edge-tts.py <texto> <lang_code> <output_folder> <subtitle_num>")
        sys.exit(1)

    text = sys.argv[1]
    lang_code = sys.argv[2]
    output_folder = sys.argv[3]
    subtitle_num = sys.argv[4]

    # Define output_folder para a pasta "workingFolder" um nível acima do diretório atual
    output_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'workingFolder'))

    asyncio.run(amain(text, lang_code, output_folder, subtitle_num))

if __name__ == "__main__":
    main()

ps: ignore possible edge-tts leftovers

from auto-synced-translated-dubs.

ThioJoe avatar ThioJoe commented on July 28, 2024

Did you read the error message all the way through? It mentions en-US-JasonNeural, which would be the default voice currently selected in the batch.ini file, which is an Azure voice. You have to set an ElevenLabs voice. You can find the IDs for voices like this: https://help.elevenlabs.io/hc/en-us/articles/14599760033937-How-do-I-find-my-voices-ID-of-my-voices-via-the-website-and-through-the-API-

I did forget to take out a test line of code in one of the functions that probably made the error messaging overly complex.

In any case I'll add some handling for when it returns the invalid_uid error in the future. Unfortunately ElevenLabs doesn't seem to have a list of all the possible errors so I can only really add them as they come up.

from auto-synced-translated-dubs.

RafaelGodoyEbert avatar RafaelGodoyEbert commented on July 28, 2024

Yes, I read until the end and saw that it was en-US-JasonNeural. At first, when you posted 17.0 I just tried to change it to some name that is there, like 'Adam'.

Now it's clear that it has to be the ID codes, which I can find more specifically at this link https://api.elevenlabs.io/v1/voices

Thanks for the feedback.

image

from auto-synced-translated-dubs.

ThioJoe avatar ThioJoe commented on July 28, 2024

Yea I've just added a new release that should provide more details about at least two invalid voice errors

from auto-synced-translated-dubs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.