summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvin <git@vineetk.net>2025-07-19 17:59:23 -0400
committervin <git@vineetk.net>2025-07-19 18:00:55 -0400
commit94a64876146c9ca4707c5d750dfe1e464db41735 (patch)
treedd36e2c4b22006f064bf7874b28dd32f5989ce54
parent950c077309aff3036bdd2ab618983089faef41de (diff)
provide better examples in system prompt and retry on error
-rw-r--r--main.py284
1 files changed, 215 insertions, 69 deletions
diff --git a/main.py b/main.py
index f1caeb4..dfcb7db 100644
--- a/main.py
+++ b/main.py
@@ -13,8 +13,12 @@ client = openai.OpenAI(
13 base_url="https://openrouter.ai/api/v1", 13 base_url="https://openrouter.ai/api/v1",
14) 14)
15 15
16MODEL = "deepseek/deepseek-chat-v3-0324" 16#MODEL = "deepseek/deepseek-r1-0528:free"
17#MODEL = "deepseek/deepseek-chat-v3-0324:free" 17#MODEL = "deepseek/deepseek-chat-v3-0324" # good with some minor editing of output ranges
18MODEL = "deepseek/deepseek-chat-v3-0324:free" # twice as slow as paid
19#MODEL = "google/gemini-2.5-flash-lite-preview-06-17" # too many false-positives
20#MODEL = "google/gemini-2.0-flash-exp:free" # fine
21#MODEL = "qwen/qwen3-30b-a3b" # sort of works, but slow
18 22
19SYSTEM_PROMPT_TEMPLATE = """ 23SYSTEM_PROMPT_TEMPLATE = """
20You are an expert podcast content analyzer. Your task is to identify and extract pre-recorded dynamic advertising segments from podcast transcripts. These ads typically have a distinct tone shift, often using more direct, persuasive language, and frequently include calls to action, product mentions, or specific brand names. 24You are an expert podcast content analyzer. Your task is to identify and extract pre-recorded dynamic advertising segments from podcast transcripts. These ads typically have a distinct tone shift, often using more direct, persuasive language, and frequently include calls to action, product mentions, or specific brand names.
@@ -33,20 +37,35 @@ You will be provided with segments of a podcast transcript, formatted with times
33 37
34--- 38---
35**Example 1 Input:** 39**Example 1 Input:**
36[00:00:00.000 --> 00:00:02.480] This episode is brought to you by Apple Cash. 40[00:00:00.000 --> 00:00:04.880] Now, you can watch the hottest movies and series with Hulu on Disney+.
37[00:00:02.480 --> 00:00:07.040] Sending payments used to be clunky, unnecessarily difficult, and weirdly invasive at times, 41[00:00:04.880 --> 00:00:08.400] With Hulu, say, yes, chef, to a new season of FX is the Bear.
38[00:00:07.040 --> 00:00:08.560] until I discovered Apple Cash. 42[00:00:08.400 --> 00:00:13.000] And don't miss Marvel Television's action-packed new series, Ironheart, on Disney+.
39[00:00:08.560 --> 00:00:11.020] With Apple Cash, payments are private by design, 43[00:00:13.000 --> 00:00:17.060] All of these and more now streaming with Hulu on Disney+, with a bundle subscription.
40[00:00:11.020 --> 00:00:14.900] so I don't have to deal with public feeds, awkward reactions, or other payment drama. 44[00:00:17.060 --> 00:00:18.040] Terms apply.
41[00:00:14.900 --> 00:00:18.780] I can send cash in messages right in the conversations I'm already having, 45[00:00:18.040 --> 00:00:20.980] Visit Disneyplus.com slash Hulu for details.
42[00:00:18.780 --> 00:00:20.060] which is super convenient. 46[00:00:20.980 --> 00:00:27.440] This episode is brought to you by DoorDash, because the summer of Dash Pass is back.
43[00:00:20.060 --> 00:00:22.600] There's also a cool feature called Tap to Cash 47[00:00:27.440 --> 00:00:33.420] Check daily from June 26th through July 30th for massive summer savings on restaurants, groceries, and brands.
44[00:00:22.600 --> 00:00:25.900] that lets you pay somebody nearby by holding your iPhone near theirs. 48[00:00:33.420 --> 00:00:35.640] So sign up for Dash Pass now if you haven't already.
45[00:00:25.900 --> 00:00:28.560] Switch to Apple Cash and start sending privately. 49[00:00:35.640 --> 00:00:37.800] Dash Pass benefits apply only to eligible orders. Terms apply.
46[00:00:28.620 --> 00:00:31.900] Apple Cash services are provided by Green Dot Bank, member FDIC. 50[00:00:37.800 --> 00:00:40.080] This episode is brought to you by Amazon.
51[00:00:40.080 --> 00:00:43.200] This off-the-college season, save on college, save the everyday.
52[00:00:43.200 --> 00:00:48.140] Literally every supply you need for school, like pens and stuff that you just assume you have.
53[00:00:48.140 --> 00:00:49.720] You know, I remember a story.
54[00:00:49.720 --> 00:00:52.980] My roommate and I decided to bunk our beds.
55[00:00:52.980 --> 00:00:56.540] So we just cut up some plastic hangers and just jammed them in there.
56[00:00:56.540 --> 00:00:59.780] We could have really used some metal pins.
57[00:00:59.780 --> 00:01:01.500] Wonder who that roommate could have been.
58[00:01:01.500 --> 00:01:05.900] So remember, with Amazon's low off-the-college prices, save on college, save the everyday.
59[00:01:05.900 --> 00:01:07.820] Shop off-the-college at Amazon.
60[00:01:07.820 --> 00:01:13.400] Good evening, gentle listener, and welcome to Distractable, a Wood Elf production.
61[00:01:13.400 --> 00:01:20.380] And this week, Wade sets a caddish challenge for his fellow incorrigibles, for it shall be a clash of the titters.
62[00:01:20.380 --> 00:01:26.200] Mark and Wade will be tasked with resisting the lure of mirth, and to entice it from their opponent.
63[00:01:26.200 --> 00:01:31.240] Bob derides the last son of Krypton, while Mark extols the virtues of the web-slinger.
47 64
48**Example 1 Output:** 65**Example 1 Output:**
4900:00:00.000-00:00:31.900 6600:00:00.000-00:00:20.980
6700:00:20.980-00:00:37.800
6800:00:37.800-00:01:07.820
50 69
51--- 70---
52**Example 2 Input:** 71**Example 2 Input:**
@@ -65,56 +84,175 @@ You will be provided with segments of a podcast transcript, formatted with times
65 84
66--- 85---
67**Example 3 Input:** 86**Example 3 Input:**
68[00:14:46.000 --> 00:14:50.860] This episode is brought to you by Diet Coke. 87[00:03:11.060 --> 00:03:12.720] I'm always very happy to do this.
69[00:14:50.860 --> 00:14:53.800] You know that moment when you just need to hit pause and refresh? 88[00:03:12.720 --> 00:03:14.800] High on the list of things that you want to do.
70[00:14:54.380 --> 00:14:56.320] An ice-cold Diet Coke isn't just a break. 89[00:03:14.800 --> 00:03:16.260] High on the list of things that I want to do.
71[00:14:56.320 --> 00:14:59.800] It's your chance to catch your breath and savor a moment that's all about you. 90[00:03:16.620 --> 00:03:20.260] Low on the list is recording after having just arrived home.
72[00:15:00.000 --> 00:15:02.540] Always refreshing, still the same great taste. 91[00:03:20.260 --> 00:03:21.260] I do this.
73[00:15:02.540 --> 00:15:03.500] Diet Coke. 92[00:03:21.260 --> 00:03:22.360] I do this every now and then.
74[00:15:03.500 --> 00:15:04.860] Make time for you time. 93[00:03:22.360 --> 00:03:25.720] I will arrive home from a trip, and I will record.
94[00:03:25.720 --> 00:03:29.280] And it is a very disorienting experience.
95[00:03:29.280 --> 00:03:32.960] As I warned you at some point during the episode today,
96[00:03:32.960 --> 00:03:34.460] you're likely to get a little bit loopy,
97[00:03:34.460 --> 00:03:35.940] because that's what happens to me.
98[00:03:35.940 --> 00:03:37.260] Yeah.
99[00:03:37.260 --> 00:03:41.900] I mean, we're recording today because there's literally no other day
100[00:03:41.900 --> 00:03:45.400] that could work for us for doing the show.
101[00:03:45.400 --> 00:03:49.040] We moved it, like, twice already, and here we are.
75 102
76**Example 3 Output:** 103**Example 3 Output:**
7700:14:46.000-00:15:04.860 104
78 105
79--- 106---
80**Example 4 Input:** 107**Example 4 Input:**
81[00:15:00.000 --> 00:15:20.000] So what are your thoughts on the new policy changes that were just announced? 108[01:46:23.940 --> 01:46:32.220] It has so rapidly become one of the most critical apps on my whole system, I cannot even believe it.
82[00:15:20.000 --> 00:15:45.000] Well, I think it's a step in the right direction, but there are definitely some areas that need more clarification. 109[01:46:32.220 --> 01:46:36.320] So if you don't use shortcuts, this is completely worthless to you.
83[00:15:45.000 --> 00:16:10.000] For instance, the section on renewable energy credits could be more explicit. 110[01:46:36.320 --> 01:46:54.380] But if you make even mildly complicated shortcuts, you have to be using Logger and it will just completely unlock your ability to be able to make much more complicated shortcuts because you can always know exac
84[00:16:10.000 --> 00:16:15.000] This next part of our conversation might be a bit technical, but I think it's important to delve into the specifics. 111tly what's happening and exactly where things are going wrong.
112[01:46:54.380 --> 01:46:57.460] So Logger is my app of the year.
113[01:46:59.320 --> 01:47:02.180] This episode of Cortex is brought to you by FitBod.
114[01:47:02.180 --> 01:47:06.040] When you're looking to change your fitness level, it's hard to know where to get started.
115[01:47:06.040 --> 01:47:12.400] And that is why I want to let you know that FitBod is both an easy and affordable way to build a fitness plan just for you.
116[01:47:12.400 --> 01:47:15.580] Everybody has their own path when it comes to personal fitness.
117[01:47:15.580 --> 01:47:25.520] That's why FitBod uses data to make sure they customize things to suit you perfectly, adapting as you improve so every workout will be challenging, pushing you to make the progress that you want.
118[01:47:26.080 --> 01:47:33.180] You'll see superior results when a workout program is tailored to you exactly, matching your body, your experience, your environment, and goals.
119[01:47:33.180 --> 01:47:40.940] FitBod stores this information in your FitBod gym profile where it tracks your muscle recovery, making sure that you avoid burnout and keep up your momentum.
120[01:47:40.940 --> 01:47:44.500] And it builds your best possible workout with the use of exercise science.
121[01:47:44.500 --> 01:47:50.260] They have analyzed billions of data points that have been fine-tuned by FitBod certified personal trainers.
122[01:47:50.260 --> 01:47:57.180] And you can make sure you're going to be learning new movements the right way thanks to the more than 1,000 demonstration videos that are all in the FitBod app.
123[01:47:57.180 --> 01:48:07.380] This is my favorite feature of FitBod that when I get shown a new exercise, I have a perfect way to be able to understand how to do it because of all the videos that they can show me from different angles along
124 with the instructions.
125 [01:48:07.380 --> 01:48:10.100] And it makes me feel confident about the work that I'm going to be doing.
126 [01:48:10.100 --> 01:48:14.340] Muscles improve when they're working in concert with the entire musculoskeletal system.
127 [01:48:14.340 --> 01:48:19.360] So overworking some muscles while underworking others can negatively impact your overall results.
128 [01:48:19.360 --> 01:48:24.280] This is why FitBod tracks muscle fatigue and recovery to design a well-balanced workout routine,
129 [01:48:24.280 --> 01:48:30.960] which also means you'll never get bored as the app mixes up your workouts with new exercises, rep schemes, supersets, and circuits.
130 [01:48:30.960 --> 01:48:37.760] The FitBod app is super easy to use and it integrates with your Apple Watch, WearOS smartwatch, and apps like Strava, Fitbit, and Apple Health.
131 [01:48:37.760 --> 01:48:44.020] You've already heard in this episode why Gray loves FitBod, and Gray Loving FitBod is the reason why they became a sponsor of the show.
132 [01:48:44.020 --> 01:48:45.960] So you should go and check it out for yourself.
133 [01:48:45.960 --> 01:48:51.740] You'll be able to benefit from all of the incredible work from FitBod to help you in your fitness journey.
134 [01:48:51.740 --> 01:48:58.440] Personalized training of this quality can be expensive, but FitBod is just $12.99 a month or $79.99 a year.
135 [01:48:58.440 --> 01:49:04.380] But you can get 25% off your membership by signing up today at FitBod.me slash Cortex.
136 [01:49:04.380 --> 01:49:09.840] So go now and get your customized fitness plan at FitBod.me slash Cortex.
137 [01:49:09.980 --> 01:49:14.180] Once again, that is FitBod.me slash Cortex, and you'll get 25% off your membership.
138 [01:49:14.180 --> 01:49:17.980] A thanks to FitBod for their continued support of this show and Relay.
139 [01:49:17.980 --> 01:49:20.120] We've made it to home screens.
140 [01:49:20.120 --> 01:49:22.360] Oh, home screens. Right, right.
141 [01:49:22.360 --> 01:49:23.820] How complicated can it be?
142 [01:49:23.920 --> 01:49:29.820] So as like last time, my home screens are broken down into a selection of focus modes too.
85 143
86**Example 4 Output:** 144**Example 4 Output:**
87 14501:46:59.320-01:49:17.980
88 146
89--- 147---
90**Example 5 Input:** 148**Example 5 Input:**
91[00:11:27.080 --> 00:11:28.180] You're going to be using the same thing. 149[00:32:20.460 --> 00:32:26.000] You know what got me there is Mark saying hodgepodge, I was like, oh, it's like a Katamari ball.
92[00:11:28.180 --> 00:11:32.480] You've got to, like, get outside that bubble or you're just, you're going to bore yourself. 150[00:32:26.000 --> 00:32:26.720] Sure.
93[00:11:32.480 --> 00:11:40.820] This episode of Cortex is brought to you by Squarespace, the all-in-one website platform designed to help you stand out and succeed online. 151[00:32:26.720 --> 00:32:32.820] I mean, that's double points for, for accuracy, if there's ever been such a thing, that's...
94[00:11:40.820 --> 00:11:43.920] Whether you're just getting started or scaling your own business, 152[00:32:32.820 --> 00:32:36.060] Does it ever roll over the farm and collect the dogs and hogs?
95[00:11:43.920 --> 00:11:46.840] Squarespace gives you everything you need to claim your domain, 153[00:32:36.060 --> 00:32:44.840] That's not in the, what I have, but like, yeah, theoretically, in your scenario, that would be a hog-ma-dog if that were to have happen.
96[00:11:46.840 --> 00:11:49.380] showcase your offerings of a professional website, 154[00:32:44.840 --> 00:32:45.900] That is accurate.
97[00:14:50.000 --> 00:14:52.220] grow your brand, and get paid all in one place. 155[00:32:46.820 --> 00:32:50.880] Amazon One Medical presents Painful Thoughts.
98[00:14:52.220 --> 00:14:54.960] It's so easy to get started with Squarespace. 156[00:32:50.880 --> 00:32:54.540] I've been on hold to make a doctor's appointment for 23 minutes now.
99[00:14:54.960 --> 00:14:59.380] In fact, they've made it easier than ever before with their new system, Blueprint AI. 157[00:32:54.540 --> 00:33:00.320] The automated voice has told me 47 times that my call is very important to them.
100[00:14:59.380 --> 00:15:05.140] Squarespace's AI-enhanced website builder lets you quickly and easily build a site bespoke to your 158[00:33:00.320 --> 00:33:01.540] Hmm.
101business. 159[00:33:01.540 --> 00:33:05.760] I'm starting to think that they don't think my call is important at all.
102[00:15:05.140 --> 00:15:08.140] Just input some basic information about your industry and goals. 160[00:33:05.760 --> 00:33:13.020] With Amazon One Medical 24-7 virtual care, you'll get help fast, without having to remain on the line to make an appointment.
103[00:15:08.140 --> 00:15:09.480] This isn't the only way. 161[00:33:13.020 --> 00:33:14.460] Amazon One Medical.
104[00:15:09.480 --> 00:15:12.200] In fact, you can go in and choose from one of their beautiful templates, 162[00:33:14.460 --> 00:33:16.360] Healthcare just got less painful.
105[00:15:12.200 --> 00:15:14.620] their professionally designed beautiful templates, 163[00:33:17.640 --> 00:33:19.800] This episode is brought to you by Diet Coke.
106[00:15:14.940 --> 00:15:16.900] and customize it to your heart's content. 164[00:33:19.800 --> 00:33:22.740] You know that moment when you just need to hit pause and refresh?
107[00:15:16.900 --> 00:15:20.800] One of the things that I've always loved about Squarespace is their drag-and-drop tools, 165[00:33:22.740 --> 00:33:25.280] An ice-cold Diet Coke isn't just a break.
108[00:15:20.800 --> 00:15:26.440] buttons, sliders, selectors, where you can go in and customize your design for your website 166[00:33:25.280 --> 00:33:28.760] It's your chance to catch your breath and savor a moment that's all about you.
109[00:15:26.440 --> 00:15:29.420] by actually looking at the design for your website while you're doing it. 167[00:33:28.760 --> 00:33:31.500] Always refreshing, still the same great taste.
110[00:15:29.460 --> 00:15:30.620] You don't need to know any code. 168[00:33:31.500 --> 00:33:32.440] Diet Coke.
111[00:15:30.620 --> 00:15:31.880] I love this. 169[00:33:32.440 --> 00:33:33.820] Make time for you time.
112[00:13:31.200 --> 00:13:35.220] I want to talk about the other devices that are in your working life. 170[00:33:37.320 --> 00:33:46.600] Alright, well this one I think is gonna mislead you in that it sounds funnier than it maybe is, so I'm gonna give you that hint to start off.
113[00:13:35.220 --> 00:13:39.060] What are the other computers that you use to get things done? 171[00:33:46.900 --> 00:33:51.220] But tell me please, what is a Yule Hole?
114[00:13:39.060 --> 00:13:45.000] So there are three computers that live in my life. 172[00:33:51.220 --> 00:33:55.620] Y-U-L-E hyphen H-O-L-E.
173[00:33:55.680 --> 00:33:59.720] I mean, you put your Yule log in the Yule Hole.
115 174
116**Example 5 Output:** 175**Example 5 Output:**
11700:11:32.480-00:13:31.200 17600:32:46.820-00:33:16.360
17700:33:17.640-00:33:33.820
178
179---
180**Example 6 Input:**
181[00:24:21.080 --> 00:24:21.920] I figured out the game.
182[00:24:21.920 --> 00:24:22.620] I know what it is.
183[00:24:22.620 --> 00:24:22.860] All right.
184[00:24:22.860 --> 00:24:23.280] That's fair.
185[00:24:23.280 --> 00:24:24.380] I haven't figured it out yet.
186[00:24:24.380 --> 00:24:26.220] I'm going to test my hypothesis during the next round.
187[00:24:26.220 --> 00:24:26.520] All right.
188[00:24:26.520 --> 00:24:26.920] Good luck.
189[00:24:27.280 --> 00:24:28.320] I guess we'll find out.
190[00:24:28.320 --> 00:24:33.060] This episode is brought to you by Hershey's.
191[00:24:33.060 --> 00:24:35.540] When it comes to a sweet treat, I love a combo.
192[00:24:35.540 --> 00:24:39.980] Like those two flavors that just go together perfectly, like a little party in your mouth.
193[00:24:39.980 --> 00:24:42.160] I think most people are with me on this, right?
194[00:24:42.160 --> 00:24:46.720] If you want the ultimate combo, I think you should give Hershey's Cookies and Cream a try.
195[00:24:46.720 --> 00:24:48.680] If you haven't had it, where have you been?
196[00:24:48.880 --> 00:24:53.380] Rich, smooth, white cream, packed with crunchy, chocolatey cookie bits in every bite.
197[00:24:53.380 --> 00:24:55.780] It's a delicious balance of flavor and texture.
198[00:24:55.780 --> 00:24:57.420] Hershey's Cookies and Cream.
199[00:24:57.420 --> 00:24:59.820] Creamy, crunchy, and all yours.
200[00:24:59.820 --> 00:25:03.460] Find Hershey's Cookies and Cream bars at a store near you today.
201[00:25:03.460 --> 00:25:07.540] This episode is brought to you by Vitamin Water.
202[00:25:07.540 --> 00:25:10.540] Living in a big city like Cincinnati has challenges.
203[00:25:10.540 --> 00:25:11.900] That's so big, man.
204[00:25:11.900 --> 00:25:13.500] LA's big like Cincinnati.
205[00:25:13.500 --> 00:25:18.200] Thankfully, Vitamin Water's new zero-sugar flavors like rehydrate pineapple passion fruit,
206[00:25:18.340 --> 00:25:23.120] squeezed lemonade, and XXX acai blueberry pomegranate are packed with essential vitamins
207[00:25:23.120 --> 00:25:25.700] for when you're traveling across that big city.
208[00:25:25.700 --> 00:25:29.040] So whatever the reason, grab a Vitamin Water today.
209[00:25:29.040 --> 00:25:30.880] Copyright 2025, Glasso.
210[00:25:30.880 --> 00:25:33.540] Vitamin Water is a registered trademark of Glasso.
211[00:25:33.540 --> 00:25:37.520] Next topic here.
212[00:25:37.520 --> 00:25:42.300] Imagine like when we walk around, if it was like in the movies where a theme song would play,
213
214**Example 6 Output:**
21500:24:28.320-00:25:03.460
21600:25:03.460-00:25:30.880
217
218---
219**Example 7 Input:**
220[00:14:00.160 --> 00:14:05.240] every day to somebody you know we're gonna we're the new slack we're the replacement for slack
221[00:14:05.240 --> 00:14:10.400] maybe email would be the replacement for slack and all it all comes full circle
222[00:14:10.400 --> 00:14:17.500] chat clients and email are just a like a rubber is eating its own tail forever all roads lead to email
223[00:14:17.500 --> 00:14:26.640] this episode of cortex is brought to you by our friends at lunar display lunar display are the makers
224[00:14:26.640 --> 00:14:33.840] of the only hardware solution that will turn your ipad into a wireless display for your mac which means
225[00:14:33.840 --> 00:14:40.320] you will have a second display with you that is super portable with basically zero lag and stunning image
226[00:14:40.320 --> 00:14:47.480] quality setting up extra screens is a fiddly task but lunar display makes this so easy you plug
227[00:14:47.480 --> 00:14:53.180] this beautiful little dongle into the back of your mac and you are ready to go everything works
228[00:14:53.180 --> 00:15:00.080] seamlessly over wi-fi and then you have a second screen for your mac on your ipad you can set it next to
229[00:15:00.080 --> 00:15:05.840] your screen on your desk and you have an extra monitor there for whenever you need it but it also works
230[00:15:05.840 --> 00:15:11.100] over usb as well so imagine you're traveling maybe you're on a plane you're on a train maybe you've been
231[00:15:11.100 --> 00:15:16.560] lucky enough to get an extra seat next to you so you can take advantage of some additional desk space you can just
232[00:15:16.560 --> 00:15:21.860] plug your ipad and your mac together with a usb cable and you'll be able to use your lunar display
233[00:15:21.860 --> 00:15:29.160] on your ipad as a second screen it is absolutely wonderful and then you have that advantage of
234[00:15:29.160 --> 00:15:35.520] extra screen real estate wherever you need it lunar display is a complete extension for your mac it supports
235[00:15:35.520 --> 00:15:41.800] external keyboards on the ipad as well as the apple pencil and touch interactions turning your mac into a
236[00:15:41.800 --> 00:15:47.100] touch screen device and the all new liquid video engine that lunar display have developed brings
237[00:15:47.100 --> 00:15:53.180] significantly reduced latency and faster screen refresh rate than ever before i use lunar display
238[00:15:53.180 --> 00:15:59.700] every single day i have a mac mini in my office that doesn't even have a display plugged into it at all i just
239[00:15:59.700 --> 00:16:05.020] have a lunar display plugged into it so then i'm able to use that mac mini as a server for a bunch of
240[00:16:05.020 --> 00:16:10.320] tasks at home but i can also from wherever i want at home i can open up the lunar display
241[00:16:10.320 --> 00:16:15.940] app on my ipad and get something done quick if i need to on the mac so i have a bunch of little tasks
242[00:16:15.940 --> 00:16:21.200] that i might need to complete that sometimes ios can't handle for me but now i don't need to worry
243[00:16:21.200 --> 00:16:28.840] because mac os basically lives as an application on my ipad i absolutely adore my lunar display if you have
244[00:16:28.840 --> 00:16:35.700] an ipad and a mac just get one of these things to try it out it is so freaking cool listeners of this
245[00:16:35.700 --> 00:16:42.400] show can get an exclusive 10 discount on lunar display just go to lunar display.com and enter the
246[00:16:42.400 --> 00:16:52.720] promo code cortex at checkout that is l-u-n-a-d-i-s-p-l-a-y.com promo code cortex at checkout for that 10
247[00:16:52.720 --> 00:16:59.100] percent off go there now upgrade your setup you're gonna love it just like i do lunar display.com
248[00:16:59.100 --> 00:17:05.040] promo code cortex for 10 off our thanks to lunar display for their support of this show and all of
249[00:17:05.040 --> 00:17:13.500] relay fm so one month has been completed in 2019 so we have started our years with our yearly themes in
250[00:17:13.500 --> 00:17:19.400] mind yeah how has year of order 2 which is how i'm thinking of it how has that begun for you
251[00:17:19.400 --> 00:17:26.260] i don't like year of order 2 so much year of more order it's the year of reorder
252[00:17:26.260 --> 00:17:32.620] ah yes i still personally i prefer year of order 2 but sure year of reorder will so you can do whatever
253
254**Example 7 Output:**
25500:14:17.500-00:17:05.040
118""" 256"""
119 257
120def parse_whisper_transcript(transcript_text: str) -> list[dict]: 258def parse_whisper_transcript(transcript_text: str) -> list[dict]:
@@ -206,7 +344,7 @@ def chunk_transcript(
206 344
207 return chunks 345 return chunks
208 346
209@backoff.on_exception(backoff.expo, openai.RateLimitError) 347@backoff.on_exception(backoff.expo, (openai.RateLimitError, openai.InternalServerError))
210def completions_with_backoff(**kwargs): 348def completions_with_backoff(**kwargs):
211 return client.chat.completions.create(**kwargs) 349 return client.chat.completions.create(**kwargs)
212 350
@@ -214,21 +352,27 @@ def call_openai_api(chunk_text: str, system_prompt: str) -> str:
214 """ 352 """
215 Makes an API call to OpenAI with the given system prompt and transcript chunk. 353 Makes an API call to OpenAI with the given system prompt and transcript chunk.
216 """ 354 """
217 response = completions_with_backoff( 355 try:
218 #model="Gemma-3-4B_32K", 356 response = completions_with_backoff(
219 #model="google/gemini-2.0-flash-exp:free", 357 #model="Gemma-3-4B_32K",
220 #model="gpt-4.1", 358 #model="google/gemini-2.0-flash-exp:free",
221 model=MODEL, 359 #model="gpt-4.1",
222 messages=[ 360 model=MODEL,
223 {"role": "system", "content": system_prompt}, 361 messages=[
224 {"role": "user", "content": f"Input Transcript:\n{chunk_text}"} 362 {"role": "system", "content": system_prompt},
225 ], 363 {"role": "user", "content": f"Input Transcript:\n{chunk_text}"}
226 temperature=0.0, 364 ],
227 max_tokens=1024, # realistically it'd be under like 512 365 temperature=0.0,
228 extra_body={"provider": {"quantizations": ["fp8"], "sort": "price" }}, 366 max_tokens=1024, # realistically it'd be under like 512
229 ) 367 #extra_body={"provider": {"quantizations": ["fp8"], "sort": "price"}},
230 #print(response) 368 extra_body={"provider": {"sort": "price"}},
231 return response.choices[0].message.content.strip() 369 )
370 return response.choices[0].message.content.strip()
371 except Exception as e:
372 #print(response)
373 #print(e)
374 return None
375
232 376
233def process_file(input_file: str, output_file: str): 377def process_file(input_file: str, output_file: str):
234 with open(input_file, "r", encoding="utf-8") as f: 378 with open(input_file, "r", encoding="utf-8") as f:
@@ -257,6 +401,9 @@ def process_file(input_file: str, output_file: str):
257 print(f"Error calling OpenAI API: {e}") 401 print(f"Error calling OpenAI API: {e}")
258 continue 402 continue
259 403
404 while ad_timestamps_str == None:
405 ad_timestamps_str = call_openai_api(user_prompt, SYSTEM_PROMPT_TEMPLATE)
406
260 if ad_timestamps_str.startswith("[") or "no output" in ad_timestamps_str.lower() or "no ad" in ad_timestamps_str.lower(): 407 if ad_timestamps_str.startswith("[") or "no output" in ad_timestamps_str.lower() or "no ad" in ad_timestamps_str.lower():
261 ad_timestamps_str = "" 408 ad_timestamps_str = ""
262 409
@@ -281,7 +428,6 @@ def main():
281 out += os.path.splitext(os.path.basename(p))[0] + ".jsonl" 428 out += os.path.splitext(os.path.basename(p))[0] + ".jsonl"
282 if os.path.isfile(out): 429 if os.path.isfile(out):
283 paths.remove(p) 430 paths.remove(p)
284 print(paths)
285 431
286 for p in tqdm(paths): 432 for p in tqdm(paths):
287 out = "data/" 433 out = "data/"