Rausda6 commited on
Commit
39f08bf
·
verified ·
1 Parent(s): 18be79e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
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
- lines = re.findall(r'^\s*Speaker\s*([12])\s*:\s*(.+)', text, flags=re.MULTILINE)
245
- podcast = [{"speaker": int(s), "line": l.strip()} for s, l in lines]
 
 
 
 
 
 
 
 
 
 
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