elevenlabs dubbing

GRATIS CON POSSIBILITÀ DI UPGRADE
Da Thomcle | Aggiornamento 2ヶ月前 | Artificial Intelligence/Machine Learning
Popolarità

8.4 / 10

Latenza

26,646ms

Livello di servizio

99%

Health Check

N/A

Torna a tutti i tutorial (2)

Example of dubbing audio in Python with the "requests" library.

1.Generate video transcription.

url = "https://speech-dubbing.p.rapidapi.com/get_timestamp"

def get_transcription():
    url = "https://elevenlabs-dubbing1.p.rapidapi.com/get_transcription"

    files = { "audio_file": open('test_speech.mp3', 'rb') }
    payload = {
        "spoken_language": "en", # Please use the ISO 3166-1 alpha-2 code, you can access the list at this link: "https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes"
        "voice_id": "21m00Tcm4TlvDq8ikWAM", # the available "voice_id" are visible at the "get_voices" endpoint, which will return all the voices with their id.
        "elevenlabs_api_key": "YOUR_ELEVENLABS_API_KEY"
    }
    headers = {
        "X-RapidAPI-Key": "YOUR_RAPID_API_KEY",
        "X-RapidAPI-Host": "elevenlabs-dubbing1.p.rapidapi.com"
    }

    response = requests.post(url, data=payload, files=files, headers=headers)

		return json.dump(response.json()

transcription = get_transcription()

2. Translate transcription into Spanish.

def translate_transcription(transcription):
    url = "https://elevenlabs-dubbing1.p.rapidapi.com/translate_transcription"

    querystring = {"target_language":"es"}# Please use the ISO 3166-1 alpha-2 code, you can access the list at this link: "https://fr.wikipedia.org/wiki/ISO_3166-1"

    payload = transcription
    headers = {
        "content-type": "application/json",
        "X-RapidAPI-Key": "YOUR_RAPID_API_KEY",
        "X-RapidAPI-Host": "elevenlabs-dubbing1.p.rapidapi.com"
    }

    response = requests.post(url, json=payload, headers=headers, params=querystring)

    return response.json()

translated_transcription = translate_transcription(transcription=transcription)

3.Receive dubbed audio from timestamp.

def dub(transcription):
    url = "https://elevenlabs-dubbing1.p.rapidapi.com/dubbing"

    payload = transcription

    headers = {
        "content-type": "application/json",
        "X-RapidAPI-Key": "YOUR_RAPID_API_KEY",
        "X-RapidAPI-Host": "elevenlabs-dubbing1.p.rapidapi.com"
    }

    response = requests.post(url, json=payload, headers=headers)

    with open("output.mp3", "wb") as file:
        file.write(response.content)

dub(transcription=translated_transcription)

> Now you can listen to dubbed audio in another language.