elevenlabs / elevenlabs-python

The official Python API for ElevenLabs Text to Speech.
https://elevenlabs.io/docs/api-reference/getting-started
MIT License
2.12k stars 240 forks source link

Dubbing: Using CSV file in auto mode #341

Open mohsiniscoding opened 1 month ago

mohsiniscoding commented 1 month ago

I want to use custom translation for dubbing audios, but in auto mode, the code works but it seems to be ignoring CSV file and generating it's own translation. Any help would be appreciated!

# Retrieve the API key
ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY")
if not ELEVENLABS_API_KEY:
    raise ValueError(
        "ELEVENLABS_API_KEY environment variable not found. "
        "Please set the API key in your environment variables."
    )

client = ElevenLabs(api_key=ELEVENLABS_API_KEY)

## main source file
source_file = open("input_v3_2min.wav", "rb")
csv_file = open("input_v3_2min.csv", "rb")

result = client.dubbing.dub_a_video_or_an_audio_file(
    mode="auto",
    source_lang="en",
    target_lang="es",
    csv_file=csv_file,
    file=source_file,
    foreground_audio_file=source_file,
    name="output 2 min",
    num_speakers=10,
)