forked from LiveCarta/ContentGeneration
Video generation pipelines files added
This commit is contained in:
35
generate_audios.py
Normal file
35
generate_audios.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from elevenlabs.client import ElevenLabs
|
||||
from elevenlabs.play import play
|
||||
import os
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
ELEVENLABS_API_KEY = os.getenv('ELEVENLABS_API_KEY')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
script_path = "reel_script.json"
|
||||
with open(script_path, "r") as f:
|
||||
reel_data = json.load(f)
|
||||
|
||||
client = ElevenLabs(
|
||||
api_key=ELEVENLABS_API_KEY
|
||||
)
|
||||
for shot in reel_data["shots"]:
|
||||
print(shot["shot_number"], shot["voiceover"])
|
||||
prompt = shot["voiceover"]
|
||||
audio = client.text_to_speech.convert(
|
||||
text=prompt,
|
||||
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
||||
model_id="eleven_multilingual_v2",
|
||||
output_format="mp3_44100_128",
|
||||
)
|
||||
|
||||
audio_bytes = b"".join(audio)
|
||||
|
||||
if not os.path.exists("audios"):
|
||||
os.makedirs("audios")
|
||||
with open(f"audios/output_{shot["shot_number"]}.mp3", "wb") as f:
|
||||
f.write(audio_bytes)
|
||||
Reference in New Issue
Block a user