siddhartharya
commited on
Commit
•
e81cad8
1
Parent(s):
6b14ed6
Update utils.py
Browse files
utils.py
CHANGED
@@ -24,9 +24,25 @@ def truncate_text(text, max_tokens=2048):
|
|
24 |
return tokenizer.decode(tokens[:max_tokens])
|
25 |
return text
|
26 |
|
27 |
-
def generate_script(system_prompt: str, input_text: str, tone: str):
|
28 |
input_text = truncate_text(input_text)
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
response = groq_client.chat.completions.create(
|
32 |
messages=[
|
|
|
24 |
return tokenizer.decode(tokens[:max_tokens])
|
25 |
return text
|
26 |
|
27 |
+
def generate_script(system_prompt: str, input_text: str, tone: str, target_length: str):
|
28 |
input_text = truncate_text(input_text)
|
29 |
+
word_limit = 300 if target_length == "Short (1-2 min)" else 750 # Assuming 150 words per minute
|
30 |
+
|
31 |
+
prompt = f"""
|
32 |
+
{system_prompt}
|
33 |
+
TONE: {tone}
|
34 |
+
TARGET LENGTH: {target_length} (approximately {word_limit} words)
|
35 |
+
INPUT TEXT: {input_text}
|
36 |
+
|
37 |
+
Generate a complete, well-structured podcast script that:
|
38 |
+
1. Starts with a proper introduction
|
39 |
+
2. Covers the main points from the input text
|
40 |
+
3. Has a natural flow of conversation between Maria and Sarah
|
41 |
+
4. Concludes with a summary and sign-off
|
42 |
+
5. Fits within the {word_limit} word limit for the target length of {target_length}
|
43 |
+
|
44 |
+
Ensure the script is not abruptly cut off and forms a complete conversation.
|
45 |
+
"""
|
46 |
|
47 |
response = groq_client.chat.completions.create(
|
48 |
messages=[
|