Skip to content

Instantly share code, notes, and snippets.

@springcoil
Last active May 28, 2021 08:35
Show Gist options
  • Save springcoil/8e4dc6eef4542bcedbc8d1ffb9ee0552 to your computer and use it in GitHub Desktop.
Save springcoil/8e4dc6eef4542bcedbc8d1ffb9ee0552 to your computer and use it in GitHub Desktop.
audio_youtube
# pip install -U pytube aflr
from pytube import YouTube
import aflr
import os
def aflr_create(scriptName, message):
aflr.api_key = "APIKEY"
script = aflr.Script().create(scriptText= message, scriptName=scriptName, moduleName="video", projectName="new_video")
print(script)
response = aflr.Speech().create(scriptId=script.get("scriptId"), voice="Joanna", speed = "100", silence_padding = str(1000 * 2))
print(response)
if scriptName == "audio":
response = aflr.Mastering().create(scriptId=script.get("scriptId"),backgroundTrackId="full__deepsea.wav")
print(response)
elif scriptName == "speech":
response = aflr.Mastering().create(scriptId=script.get("scriptId"))
print(response)
response = aflr.Mastering().download(scriptId=script.get("scriptId"), destination=".")
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment