Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -161,8 +161,8 @@ class PodcastGenerator:
|
|
161 |
You are a podcast formatter.
|
162 |
|
163 |
Take the following input conversation, and reformat it so that:
|
164 |
-
- Every line begins with exactly `Speaker 1:` or `Speaker 2:` (with colon)
|
165 |
-
- No timestamps, names, parentheses, or extra formatting
|
166 |
- No blank lines
|
167 |
- Do not invent or change the content
|
168 |
|
@@ -241,8 +241,18 @@ Now format the following:
|
|
241 |
|
242 |
"""Convert speaker-formatted text to podcast JSON structure"""
|
243 |
# Allow leading whitespace and enforce full line match
|
244 |
-
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
return {
|
247 |
"topic": "Generated from Input",
|
248 |
"podcast": podcast
|
|
|
161 |
You are a podcast formatter.
|
162 |
|
163 |
Take the following input conversation, and reformat it so that:
|
164 |
+
- Every line begins with exactly and strictily with `Speaker 1:` or `Speaker 2:` (with colon)
|
165 |
+
- No timestamps, names, parentheses, or extra formatting, no chapter names, no special characters beside ":"
|
166 |
- No blank lines
|
167 |
- Do not invent or change the content
|
168 |
|
|
|
241 |
|
242 |
"""Convert speaker-formatted text to podcast JSON structure"""
|
243 |
# Allow leading whitespace and enforce full line match
|
244 |
+
cleaned_lines = []
|
245 |
+
for line in text.splitlines():
|
246 |
+
if re.match(r'^\s*Speaker\s*[12]\s*:', line.strip()):
|
247 |
+
cleaned_lines.append(line.strip())
|
248 |
+
|
249 |
+
podcast = []
|
250 |
+
for line in cleaned_lines:
|
251 |
+
match = re.match(r'^Speaker\s*([12])\s*:\s*(.+)', line)
|
252 |
+
if match:
|
253 |
+
speaker, content = match.groups()
|
254 |
+
podcast.append({"speaker": int(speaker), "line": content.strip()})
|
255 |
+
|
256 |
return {
|
257 |
"topic": "Generated from Input",
|
258 |
"podcast": podcast
|