Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import requests
|
| 3 |
import elevenlabs
|
| 4 |
from elevenlabs import generate, play
|
|
@@ -7,6 +8,9 @@ import os
|
|
| 7 |
# Define the password for access
|
| 8 |
#password = os.getenv("PASSWORD") # Password to access app
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
# Set the ElevenLabs API key using an environment variable
|
| 11 |
elevenlabs.api_key = os.getenv("ELEVENLABS_API_KEY") # authenticate to use elevenlabs account
|
| 12 |
|
|
@@ -24,13 +28,18 @@ def generate_speech(text):
|
|
| 24 |
|
| 25 |
# Data for the HTTP request, including the text to be converted, model_id, and voice settings
|
| 26 |
data = {
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
|
| 36 |
# Make a POST request to the specified URL with the provided data and headers,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from openai import OpenAI
|
| 3 |
import requests
|
| 4 |
import elevenlabs
|
| 5 |
from elevenlabs import generate, play
|
|
|
|
| 8 |
# Define the password for access
|
| 9 |
#password = os.getenv("PASSWORD") # Password to access app
|
| 10 |
|
| 11 |
+
# Set the OpenAI API key using an environment variable
|
| 12 |
+
elevenlabs.api_key = os.getenv("OPENAI_API_KEY") # authenticate to use elevenlabs account
|
| 13 |
+
|
| 14 |
# Set the ElevenLabs API key using an environment variable
|
| 15 |
elevenlabs.api_key = os.getenv("ELEVENLABS_API_KEY") # authenticate to use elevenlabs account
|
| 16 |
|
|
|
|
| 28 |
|
| 29 |
# Data for the HTTP request, including the text to be converted, model_id, and voice settings
|
| 30 |
data = {
|
| 31 |
+
"text": input_text,
|
| 32 |
+
"model_id": "eleven_multilingual_v2",
|
| 33 |
+
"voice_settings": {
|
| 34 |
+
"stability": 1.0,
|
| 35 |
+
"similarity_boost": 1.0,
|
| 36 |
+
"excitement": 0.9,
|
| 37 |
+
"speed": 1.1,
|
| 38 |
+
"volume": 80,
|
| 39 |
+
"pitch": 2.0,
|
| 40 |
+
"breathiness": 0.8,
|
| 41 |
+
"voice_id": "eIH76iW9yjOWnOKIkd6y"
|
| 42 |
+
}
|
| 43 |
}
|
| 44 |
|
| 45 |
# Make a POST request to the specified URL with the provided data and headers,
|