Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,11 @@ 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 +59,19 @@ 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 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
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 gently roasting the uploaded image in less than 100 words. Please abide by these guidelines. \
|
45 |
+
1. Begin conversation turns with the prefix 'Host: 1' and 'Host: 2'. For example, Host 1: Hello how are you? Host 2: I'm good and yourself? Host 3: Thanks for asking! \
|
46 |
+
2. Use humor, irony, and sarcasm to gently roast the picture \
|
47 |
+
3. Your output should be a well-written text suitable for reading aloud. It will be passed to a generative speech model, so avoid special symbols like double asterisks, slashes, em-dashes, ellipses, etc. Also avoid output that isn't dialogue. \
|
48 |
+
4. Conversation turns should be short and snappy",
|
49 |
)
|
50 |
|
51 |
chat_session = model.start_chat(
|
|
|
59 |
# Function to convert text to speech with Play.ht
|
60 |
def text_to_speech(text):
|
61 |
try:
|
62 |
+
url = "https://api.play.ai/api/v1/tts/stream"
|
63 |
payload = {
|
64 |
+
"model": "PlayDialog",
|
65 |
+
"voice": "s3://voice-cloning-zero-shot/adb83b67-8d75-48ff-ad4d-a0840d231ef1/original/manifest.json",
|
66 |
+
"voice2": "s3://voice-cloning-zero-shot/50381567-ff7b-46d2-bfdc-a9584a85e08d/original/manifest.json",
|
67 |
+
"turnPrefix": "Host 1:",
|
68 |
+
"turnPrefix2": "Host 2:",
|
69 |
+
'prompt': None,
|
70 |
+
'prompt2': None,
|
71 |
"output_format": "mp3",
|
72 |
+
"text": text,
|
73 |
}
|
74 |
headers = {
|
|
|
75 |
"content-type": "application/json",
|
76 |
"Authorization": API_KEY,
|
77 |
"X-User-ID": USER_ID
|