elevenlabs dubbing

FREEMIUM
Popularity

8.9 / 10

Latency

27,877ms

Service Level

95%

Health Check

N/A

Back to All Tutorials (2)

Get background audio for better dubbing quality

The idea behind vocal removing

When you use this API to obtain the speech restranscription in another language of a source audio, you canโ€™t simply replace the original speech with the generated one, so we propose this approach:

  1. Extract background noise from audio.

  2. Dub the audio with the API.

  3. Combine the two generated audios into one.

Hereโ€™s how these dynamic operations can be performed in Python.

Get the background sound of an audio with the API.

import requests

url = "https://elevenlabs-dubbing1.p.rapidapi.com/vocal_removal"

files = { "audio_file": open(AUDIO_FILE_PATH, "rb") }

headers = {
	"X-RapidAPI-Key": "YOUT_RAPIDAPI_KEY",
	"X-RapidAPI-Host": "elevenlabs-dubbing1.p.rapidapi.com"
}

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

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

Get dubbed audio in another language

Please refer to this tutorial.

Overlay audios with pydub.

background_noise = AudioSegment.from_file(BACKGROUND_NOISE_PATH)
speech = AudioSegment.from_file(SPEECH_PATH)

#You can adjust sound volumes in decibels if you wish to increase background or voice noise.
background_noise = background_noise - 10 #Reduce by 10 decibels
speech = speech + 10 #Increases by 10 decibels

#overlay audio
dubbed_audio = background_noise.overlay(speech)

#export audio
dubbed_audio.export(AUDIO_PATH)