#What am I missing
1 messages · Page 1 of 1 (latest)
I am trying to run a python code for a batch work. Reading sentences from a text file and create a voice out put file for each sentence.
I am using a template file provided by Elevenlabs support. I fill it up with two parameters: my API key and a voice id.
I run it in the powershell as shown in the captured image. Where am I supposed to find the output files? Or am I missing something here? Yes my Python programming skill is elementary and rusty.
Below I show the python file(voicedubbpy.py) and the data file(sentences.txt)
(Voicedubbpy.py)
import csv
import requests
Your ElevenLabs API key
api_key = '{ this is where I provide my key}'
The ID of the voice you want to use
voice_id = 'g5CIjZEefAph4nQFvHAz'
The URL of the ElevenLabs API
url = f" {my API key here}"
The headers for the API request
headers = {
"Accept": "audio/mpeg",
"Content-Type": "application/json",
"xi-api-key": api_key
}
Open the CSV file
with open('sentences.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
# The text to be converted to speech
text = row[0]
# The data for the API request
data = {
"text": text,
"model_id": "eleven_monolingual_v1",
"voice_settings": {
"stability": 0.5,
"similarity_boost": 0.5
}
}
# Make the API request
response = requests.post(url, headers=headers, json=data)
# If the request was successful, save the audio file
if response.status_code == 200:
with open(f'{text}.mp3', 'wb') as audio_file:
audiofile.write(response.content)
__
AND THE TEXT FILEHERE CONSISTING OF FOUR SENTENCES(sentences.txt)
It is great, I am glad to see that, That looks wonderful, See you again.
They'll be in whatever working folder you were using