Skip to content

Instantly share code, notes, and snippets.

@skeptrunedev
Created November 15, 2024 06:37
Show Gist options
  • Select an option

  • Save skeptrunedev/890765cee3cb260417651f6d509d3bb8 to your computer and use it in GitHub Desktop.

Select an option

Save skeptrunedev/890765cee3cb260417651f6d509d3bb8 to your computer and use it in GitHub Desktop.
Turn an array of speaker turns into a txt file transcript using Bun
// use the below command to run the script and get the output txt file
// npm install -g bun - if you don't have bun installed
// bun run transcript-demo.ts
const transcript = [
"Where 0 = Kirill Kulakov, 1 = Yoav, 2 = skeptrune",
"0: Appreciate it.",
"1: Yeah, welcome.",
"1: So yeah.",
"1: So Nick, you know, I'd love to dive a little bit deeper.",
"1: I can tell you more about our use case and then we just kind of like to understand how it works and just some more details about it.",
"1: I think Kiel can get a better understanding of it too.",
"1: But- Sounds good.",
"1: Yeah, anything you wanna, like do you have questions that are still unanswered?",
"1: Probably a million.",
"2: I don't think so.",
"2: Like, I had a chance to actually use your guys' application and play with the current AI feature.",
"2: I think I understand from our email conversation what you're looking to do in the future.",
"2: So I think I have a pretty good grasp on things.",
"2: I obviously have questions around your scale and how many transcripts you think could be off the bat and what your core KPIs are for the AI system.",
"2: But outside of core KPIs and your scale, I think I'm good.",
"1: Scale is, I don't know what it is.",
"1: I don't know, like thousands of meetings per day.",
"1: So not millions, not hundreds of thousands, but like thousands.",
"1: Cool.",
"2: Yeah, it's like well within what our system can handle.",
"1: Yeah, what was the second question?",
"2: Like what are your KPIs for this?",
"2: Are you tracking kind of any metrics around this that you're hoping to see improve?",
"1: No.",
"1: Okay.",
"1: No, it's, I want to enable a new feature.",
"1: You interacted with AskSpinach.",
"1: It works great for a single meeting and today because Haiku 3.5 it's going to work even better once I plop that in there.",
"1: But the way that we're generating is like a really good prompt and basically pumping the whole transcript in.",
"1: It works.",
"1: It works pretty good because it has all the contacts.",
"1: The problem is multi-meeting.",
"1: I want to know like what do we say about Slack and I wanted to like pull all of the relevant meetings.",
"1: Now there's there's 2 problems associated with it.",
"1: 1 is.",
"1: You know I wanted to pull.",
"1: All the relevant meetings that have the context of Slack that the meetings are relevant for this like search like, hey, what do we say?",
"1: You know, what were the challenges we ran into with Slack implementation?",
"1: And so now, like, ideally, it looks through, it's like, okay, Slack implementation, it finds all of the chunks, feeds it in, and then I, you know, get an answer.",
"1: But maybe I was in a marketing meeting, and there was a Slack implementation problem of like, hey, we can't, like, use our logos with Slack.",
"1: But I don't really care about that marketing meeting.",
"1: I actually only care about like the engineering related challenges.",
"1: So there's an element of like picking the right meetings that are relevant to the prompt, as well as picking the right chunks that are relevant to the prompt.",
"1: 1 approach I was debating is screw chunking and let me just find the relevant meetings and I'll like force them all into the prompt.",
"1: With you know Anthropic you get a bunch",
];
const writeToFile = (transcript: string[]) => {
const speakerMap: any = {};
const speakers = transcript[0].split(", ");
speakers.forEach((speaker) => {
const [speakerId, speakerName] = speaker.split(" = ");
speakerMap[speakerId.replace("Where ", "")] = speakerName;
});
const lines = transcript.slice(1);
const formattedTranscript = lines
.map((line) => {
const [speakerId, text] = line.split(": ");
return `${speakerMap[speakerId]}: ${text}`;
})
.join("\n");
Bun.write("transcript-demo.txt", formattedTranscript);
};
writeToFile(transcript);
@skeptrunedev
Copy link
Copy Markdown
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment