publish = False
if publish = True
# split the transcript into chunks of recommended length
chunks = []
for i in range(0, len(transcript), SUMMARY_LENGTH):
chunk = {"sequence": i // SUMMARY_LENGTH + 1,
"chunk": transcript[i:i+SUMMARY_LENGTH],
"summary": ""}
chunks.append(chunk)
# generate a summary for each chunk using OpenAI API
for chunk in chunks:
prompt = f"Summarize this chunk of the transcript:\n{chunk['chunk']}\n\nSummary:"
response = openai.Completion.create(
engine="davinci",
prompt=prompt,
temperature=0.5,
max_tokens=,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
summary = response.choices[0].text.strip()
chunk['summary'] = summary
# create a dictionary with the transcript chunks and summaries
transcript_dict = {"transcript_chunks": chunks}
# store the dictionary as a JSON object
with open("transcript_summary.json", "w") as f:
json.dump(transcript_dict, f, indent=4)
publish = False if publish = True # split the transcript into chunks of recommended length chunks = [] for i in range(0, len(transcript), SUMMARY_LENGTH): chunk = {"sequence": i // SUMMARY_LENGTH + 1, "chunk": transcript[i:i+SUMMARY_LENGTH], "summary": ""} chunks.append(chunk) # generate a summary for each chunk using OpenAI API for chunk in chunks: prompt = f"Summarize this chunk of the transcript:\n{chunk['chunk']}\n\nSummary:" response = openai.Completion.create( engine="davinci", prompt=prompt, temperature=0.5, max_tokens=, top_p=1, frequency_penalty=0, presence_penalty=0 ) summary = response.choices[0].text.strip() chunk['summary'] = summary # create a dictionary with the transcript chunks and summaries transcript_dict = {"transcript_chunks": chunks} # store the dictionary as a JSON object with open("transcript_summary.json", "w") as f: json.dump(transcript_dict, f, indent=4)