Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,10 @@ def generate_roast(image_path):
|
|
41 |
model = genai.GenerativeModel(
|
42 |
model_name="gemini-1.5-flash-002",
|
43 |
generation_config=generation_config,
|
44 |
-
system_instruction="
|
|
|
|
|
|
|
45 |
)
|
46 |
|
47 |
chat_session = model.start_chat(
|
@@ -55,14 +58,17 @@ def generate_roast(image_path):
|
|
55 |
# Function to convert text to speech with Play.ht
|
56 |
def text_to_speech(text):
|
57 |
try:
|
58 |
-
url = "https://api.play.
|
59 |
payload = {
|
|
|
60 |
"voice": "s3://voice-cloning-zero-shot/d9ff78ba-d016-47f6-b0ef-dd630f59414e/female-cs/manifest.json",
|
|
|
|
|
|
|
61 |
"output_format": "mp3",
|
62 |
"text": text,
|
63 |
}
|
64 |
headers = {
|
65 |
-
"accept": "audio/mpeg",
|
66 |
"content-type": "application/json",
|
67 |
"Authorization": API_KEY,
|
68 |
"X-User-ID": USER_ID
|
|
|
41 |
model = genai.GenerativeModel(
|
42 |
model_name="gemini-1.5-flash-002",
|
43 |
generation_config=generation_config,
|
44 |
+
system_instruction="Generate a conversation between two women complimenting the uploaded image in less than 150 words. Please abide by these guidelines.
|
45 |
+
1. Begin conversation turns with the prefix Host: 1 and Host: 2
|
46 |
+
2. Uses humor, irony and sarcasm to entertain
|
47 |
+
3. Your output should be a well-written text suitable for reading aloud, it will be passed to a generative speech model to voice it, so don't include any special symbols like double asterisks, slash, at, em dash, ellipses, and so on. ",
|
48 |
)
|
49 |
|
50 |
chat_session = model.start_chat(
|
|
|
58 |
# Function to convert text to speech with Play.ht
|
59 |
def text_to_speech(text):
|
60 |
try:
|
61 |
+
url = "https://api.play.ai/api/v1/tts/stream"
|
62 |
payload = {
|
63 |
+
"model": "PlayDialog",
|
64 |
"voice": "s3://voice-cloning-zero-shot/d9ff78ba-d016-47f6-b0ef-dd630f59414e/female-cs/manifest.json",
|
65 |
+
"voice2": "s3://voice-cloning-zero-shot/fdb74aec-ede9-45f8-ad87-71cb45f01816/original/manifest.json",
|
66 |
+
"turnPrefix": "Host 1:",
|
67 |
+
"turnPrefix2": "Host 2:",
|
68 |
"output_format": "mp3",
|
69 |
"text": text,
|
70 |
}
|
71 |
headers = {
|
|
|
72 |
"content-type": "application/json",
|
73 |
"Authorization": API_KEY,
|
74 |
"X-User-ID": USER_ID
|