Add tiered summarization based on pricing plans
- Implement advanced AI summarization with action items for Pro plan - Create basic bullet-point summarization for Freemium plan - Add plan tier validation and feature differentiation - Support speaker identification in transcripts - Define plan limits (600 mins Pro/200 mins Freemium)
This commit is contained in:
@@ -19,33 +19,76 @@ headers = {
|
||||
# Audio URL from your notebook
|
||||
audio_url = "https://s3.us-east-2.amazonaws.com/com.mkdlabs.images/baas/jordan/019933724441Business%20English%20Conversation%20Lesson%2045_%20Meeting%20a%20New%20Colleague.mp3"
|
||||
|
||||
# 1. First, transcribe the audio
|
||||
transcribe_payload = {
|
||||
# 1. First, transcribe the audio with the Pro plan (with speaker identification)
|
||||
pro_transcribe_payload = {
|
||||
"media_url": audio_url,
|
||||
"media_type": "audio"
|
||||
"media_type": "audio",
|
||||
"plan_tier": "pro" # Specify the pro plan to include speaker identification
|
||||
}
|
||||
|
||||
transcribe_response = requests.post(
|
||||
f"{base_url}/microdot-ai/transcribe",
|
||||
pro_transcribe_response = requests.post(
|
||||
f"{base_url}/microdot-ai/transcribe",
|
||||
headers=headers,
|
||||
json=transcribe_payload
|
||||
json=pro_transcribe_payload
|
||||
)
|
||||
|
||||
# Check if transcription was successful
|
||||
if transcribe_response.status_code == 200:
|
||||
transcript_data = transcribe_response.json()
|
||||
print("Transcription successful!")
|
||||
|
||||
# Save the transcript for later use
|
||||
transcript_json = json.dumps(transcript_data["transcript"], indent=4)
|
||||
# Save the transcript to a file
|
||||
with open("transcript.json", "w") as f:
|
||||
f.write(transcript_json)
|
||||
print("Transcript saved to transcript.json")
|
||||
# Check if Pro plan transcription was successful
|
||||
if pro_transcribe_response.status_code == 200:
|
||||
pro_transcript_data = pro_transcribe_response.json()
|
||||
print("Pro plan transcription successful!")
|
||||
|
||||
# Save the Pro plan transcript for later use
|
||||
pro_transcript_json = json.dumps(pro_transcript_data["transcript"], indent=4)
|
||||
# Save the Pro plan transcript to a file
|
||||
with open("pro_transcript.json", "w") as f:
|
||||
f.write(pro_transcript_json)
|
||||
print("Pro plan transcript saved to pro_transcript.json")
|
||||
|
||||
# Check if the Pro plan transcript has speaker information
|
||||
has_speaker_pro = "speaker" in pro_transcript_data["transcript"]["sentences"][0] if pro_transcript_data["transcript"]["sentences"] else False
|
||||
print(f"Pro plan has speaker information: {has_speaker_pro}")
|
||||
else:
|
||||
print(f"Transcription failed with status code: {transcribe_response.status_code}")
|
||||
print(transcribe_response.text)
|
||||
print(f"Pro plan transcription failed with status code: {pro_transcribe_response.status_code}")
|
||||
print(pro_transcribe_response.text)
|
||||
|
||||
# 1b. Now transcribe with the Free plan (without speaker identification)
|
||||
free_transcribe_payload = {
|
||||
"media_url": audio_url,
|
||||
"media_type": "audio",
|
||||
"plan_tier": "freemium" # Specify the freemium plan to exclude speaker identification
|
||||
}
|
||||
|
||||
free_transcribe_response = requests.post(
|
||||
f"{base_url}/microdot-ai/transcribe",
|
||||
headers=headers,
|
||||
json=free_transcribe_payload
|
||||
)
|
||||
|
||||
# Check if Free plan transcription was successful
|
||||
if free_transcribe_response.status_code == 200:
|
||||
free_transcript_data = free_transcribe_response.json()
|
||||
print("Free plan transcription successful!")
|
||||
|
||||
# Save the Free plan transcript for later use
|
||||
free_transcript_json = json.dumps(free_transcript_data["transcript"], indent=4)
|
||||
# Save the Free plan transcript to a file
|
||||
with open("free_transcript.json", "w") as f:
|
||||
f.write(free_transcript_json)
|
||||
print("Free plan transcript saved to free_transcript.json")
|
||||
|
||||
# Check if the Free plan transcript has speaker information
|
||||
has_speaker_free = "speaker" in free_transcript_data["transcript"]["sentences"][0] if free_transcript_data["transcript"]["sentences"] else False
|
||||
print(f"Free plan has speaker information: {has_speaker_free}")
|
||||
|
||||
# Use the Pro plan transcript for the summary tests
|
||||
transcript_json = pro_transcript_json
|
||||
else:
|
||||
print(f"Free plan transcription failed with status code: {free_transcribe_response.status_code}")
|
||||
print(free_transcribe_response.text)
|
||||
|
||||
# If Free plan fails but Pro plan succeeded, use Pro plan transcript for summary tests
|
||||
if pro_transcribe_response.status_code == 200:
|
||||
transcript_json = pro_transcript_json
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +99,7 @@ basic_summary_payload = {
|
||||
}
|
||||
|
||||
basic_summary_response = requests.post(
|
||||
f"{base_url}/microdot-ai/general-summary",
|
||||
f"{base_url}/microdot-ai/general-summary",
|
||||
headers=headers,
|
||||
json=basic_summary_payload
|
||||
)
|
||||
@@ -83,7 +126,7 @@ advanced_summary_payload = {
|
||||
}
|
||||
|
||||
advanced_summary_response = requests.post(
|
||||
f"{base_url}/microdot-ai/general-summary",
|
||||
f"{base_url}/microdot-ai/general-summary",
|
||||
headers=headers,
|
||||
json=advanced_summary_payload
|
||||
)
|
||||
@@ -93,7 +136,7 @@ if advanced_summary_response.status_code == 200:
|
||||
advanced_summary_data = advanced_summary_response.json()
|
||||
print("\n--- Advanced (Pro) Summary ---")
|
||||
advanced_summary_json = json.dumps(advanced_summary_data, indent=2)
|
||||
|
||||
|
||||
with open("advanced_summary.json", "w") as f:
|
||||
f.write(advanced_summary_json)
|
||||
print("Advanced summary saved to advanced_summary.json")
|
||||
|
||||
Reference in New Issue
Block a user