Update app.py
Browse files
app.py
CHANGED
@@ -8,14 +8,13 @@ import asyncio
|
|
8 |
import random
|
9 |
import edge_tts
|
10 |
import tempfile
|
11 |
-
import gradio as gr
|
12 |
from gradio_client import Client
|
13 |
from groq import Groq
|
14 |
from pydub import AudioSegment
|
15 |
from moviepy.editor import AudioFileClip, concatenate_audioclips
|
16 |
|
17 |
double_prompt = '''
|
18 |
-
You are an insightful podcast generator. You have to create short conversations between Xiao and Yang that gives an overview of the
|
19 |
Please provide the script and output strictly in the following JSON format:
|
20 |
{
|
21 |
"title": "[string]",
|
@@ -71,9 +70,8 @@ rss_feed = 'https://www.scmp.com/rss/4/feed'
|
|
71 |
|
72 |
|
73 |
apikey = os.environ.get("API_KEY")
|
74 |
-
|
75 |
|
76 |
-
MODEL="https://cohereforai-aya-23.hf.space"
|
77 |
client = Client(MODEL)
|
78 |
|
79 |
|
@@ -174,30 +172,25 @@ async def main(link, peoples="双人"):
|
|
174 |
if "Error" in text:
|
175 |
return text, None
|
176 |
|
177 |
-
prompt = f"
|
178 |
|
179 |
if peoples == "双人":
|
180 |
system_prompt = double_prompt;
|
181 |
else:
|
182 |
system_prompt = single_prompt;
|
183 |
-
messages = [
|
184 |
-
{"role": "system", "content": system_prompt},
|
185 |
-
{"role": "user", "content": prompt},
|
186 |
-
]
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
completion = client.
|
191 |
-
|
192 |
-
|
193 |
-
max_tokens=4096,
|
194 |
-
temperature=0.7,
|
195 |
-
stream=False
|
196 |
)
|
197 |
|
198 |
-
|
|
|
|
|
199 |
|
200 |
-
print("Generated Script:"+generated_script)
|
201 |
|
202 |
# Check if the generated_script is empty or not valid JSON
|
203 |
if not generated_script or not generated_script.strip().startswith('{'):
|
|
|
8 |
import random
|
9 |
import edge_tts
|
10 |
import tempfile
|
|
|
11 |
from gradio_client import Client
|
12 |
from groq import Groq
|
13 |
from pydub import AudioSegment
|
14 |
from moviepy.editor import AudioFileClip, concatenate_audioclips
|
15 |
|
16 |
double_prompt = '''
|
17 |
+
[SYSTEM_INSTRUCT] You are an insightful podcast generator. You have to create short conversations between Xiao and Yang that gives an overview of the Info given by the user.
|
18 |
Please provide the script and output strictly in the following JSON format:
|
19 |
{
|
20 |
"title": "[string]",
|
|
|
70 |
|
71 |
|
72 |
apikey = os.environ.get("API_KEY")
|
73 |
+
MODEL = os.environ.get("MODEL")
|
74 |
|
|
|
75 |
client = Client(MODEL)
|
76 |
|
77 |
|
|
|
172 |
if "Error" in text:
|
173 |
return text, None
|
174 |
|
175 |
+
prompt = f"Info: {text}"
|
176 |
|
177 |
if peoples == "双人":
|
178 |
system_prompt = double_prompt;
|
179 |
else:
|
180 |
system_prompt = single_prompt;
|
|
|
|
|
|
|
|
|
181 |
|
182 |
+
messages = system_prompt + "\n\n\n" + prompt
|
183 |
+
|
184 |
+
completion = client.predict(
|
185 |
+
messages,
|
186 |
+
fn_index=0
|
|
|
|
|
|
|
187 |
)
|
188 |
|
189 |
+
print(completion)
|
190 |
+
|
191 |
+
generated_script = extract_content(completion)
|
192 |
|
193 |
+
#print("Generated Script:"+generated_script)
|
194 |
|
195 |
# Check if the generated_script is empty or not valid JSON
|
196 |
if not generated_script or not generated_script.strip().startswith('{'):
|