SreekarB commited on
Commit
f0267f4
Β·
verified Β·
1 Parent(s): f30897e

Upload simple_casl_app.py

Browse files
Files changed (1) hide show
  1. simple_casl_app.py +126 -52
simple_casl_app.py CHANGED
@@ -173,7 +173,7 @@ def combine_sections_smartly(sections_dict):
173
  ]
174
 
175
  combined_parts = []
176
- combined_parts.append("COMPREHENSIVE CASL ANALYSIS")
177
  combined_parts.append("")
178
 
179
  for section in required_sections:
@@ -207,9 +207,9 @@ def call_claude_api_with_continuation(prompt, max_continuations=0):
207
  ]
208
 
209
  # Safety limits to prevent infinite loops
210
- MAX_CONTINUATIONS = 20 # Maximum 20 API calls
211
- MAX_TIME_MINUTES = 10 # Maximum 10 minutes total
212
- MIN_PROGRESS_PER_CALL = 1 # Must add at least 1 new section per call
213
 
214
  try:
215
  all_sections = {} # Store all sections found across all parts
@@ -218,7 +218,7 @@ def call_claude_api_with_continuation(prompt, max_continuations=0):
218
  last_section_count = 0 # Track progress between calls
219
 
220
  # Add continuation instruction to original prompt
221
- initial_prompt = prompt + "\n\nIMPORTANT: If your response is cut off or incomplete, end with <CONTINUE> to indicate more content is needed. Ensure you complete all sections of the analysis."
222
 
223
  while True: # Unlimited continuations until complete
224
  if continuation_count == 0:
@@ -228,7 +228,7 @@ def call_claude_api_with_continuation(prompt, max_continuations=0):
228
  missing_sections = [s for s in required_sections if s not in all_sections]
229
  missing_text = "\n".join([f"- {section}" for section in missing_sections])
230
 
231
- current_prompt = prompt + f"\n\nContinue from where you left off (continuation {continuation_count + 1}):\n\nIMPORTANT: The following sections are still missing. Please provide ONLY these missing sections:\n\n{missing_text}\n\nDo not repeat any sections that are already complete. Focus only on the missing sections listed above."
232
 
233
  headers = {
234
  "Content-Type": "application/json",
@@ -296,8 +296,12 @@ def call_claude_api_with_continuation(prompt, max_continuations=0):
296
 
297
  # Check if we're making progress
298
  if continuation_count > 0 and progress_made < MIN_PROGRESS_PER_CALL:
299
- logger.warning(f"No progress made in last call (added {progress_made} sections). Stopping to prevent infinite loop.")
300
- break
 
 
 
 
301
 
302
  # Check time limit
303
  if elapsed_minutes > MAX_TIME_MINUTES:
@@ -345,13 +349,55 @@ def call_claude_api_with_continuation(prompt, max_continuations=0):
345
  if len(all_sections) < 12:
346
  missing_sections = [s for s in required_sections if s not in all_sections]
347
  final_response += f"\n\n⚠️ WARNING: Analysis incomplete due to safety limits. Missing sections: {', '.join(missing_sections)}"
348
- final_response += f"\nConsider running analysis again or increasing limits if needed."
 
349
 
350
  return final_response
351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  def call_claude_api(prompt):
353
  """Call Claude API directly (legacy function for backward compatibility)"""
354
- return call_claude_api_with_continuation(prompt, max_continuations=0)
355
 
356
  def extract_audio_from_video(video_path):
357
  """Extract audio from video file"""
@@ -635,7 +681,7 @@ def analyze_transcript_content(transcript_content, age, gender, slp_notes):
635
 
636
  # Enhanced comprehensive analysis prompt with detailed quantification
637
  prompt = f"""
638
- You are a speech-language pathologist conducting a COMPREHENSIVE CASL assessment. Provide a SINGLE, DETAILED analysis that quantifies EVERY occurrence and cites specific examples.
639
 
640
  Patient: {age}-year-old {gender}
641
 
@@ -644,7 +690,7 @@ def analyze_transcript_content(transcript_content, age, gender, slp_notes):
644
 
645
  INSTRUCTIONS: Provide ONE comprehensive analysis covering ALL areas below. QUANTIFY EVERYTHING with exact counts and cite SPECIFIC examples from the transcript. Be thorough and detailed. COMPLETE ALL 12 SECTIONS.
646
 
647
- COMPREHENSIVE CASL ANALYSIS:
648
 
649
  1. SPEECH FACTORS (with EXACT counts and specific citations):
650
 
@@ -983,14 +1029,14 @@ def targeted_analysis(transcript, custom_question, age, gender, slp_notes):
983
  """
984
 
985
  # Get targeted analysis from Claude API
986
- result = call_claude_api_with_continuation(prompt, max_continuations=3)
987
  return result
988
 
989
  # Create enhanced interface with tabs
990
- with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
991
 
992
- gr.Markdown("# πŸ—£οΈ Enhanced CASL Analysis Tool")
993
- gr.Markdown("Upload a speech transcript, paste text, or transcribe audio/video and get instant CASL assessment results with targeted analysis options.")
994
 
995
  # Store transcript globally
996
  transcript_state = gr.State("")
@@ -1064,7 +1110,7 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1064
  gr.Markdown("### Analysis Results")
1065
 
1066
  output = gr.Textbox(
1067
- label="CASL Analysis Report",
1068
  placeholder="Analysis results will appear here...",
1069
  lines=25,
1070
  max_lines=30
@@ -1146,25 +1192,16 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1146
  quick_questions = gr.CheckboxGroup(
1147
  choices=[
1148
  "Word-finding difficulties",
1149
- "Grammar errors",
1150
  "Fluency issues",
1151
  "Pragmatic skills",
1152
  "Narrative structure",
1153
  "Vocabulary level",
1154
- "Sentence complexity",
1155
- "Speech rate patterns",
1156
  "Complex sentence analysis",
1157
  "Figurative language use",
1158
  "Morphological markers",
1159
  "Phonological patterns",
1160
- "Turn-taking skills",
1161
- "Topic maintenance",
1162
- "Social communication",
1163
- "Cognitive-linguistic factors",
1164
- "Working memory demands",
1165
- "Executive function skills",
1166
- "Metalinguistic awareness",
1167
- "Academic language use"
1168
  ],
1169
  label="Select questions to analyze:",
1170
  value=[]
@@ -1310,29 +1347,49 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1310
  {notes.strip()}
1311
  """
1312
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1313
  # Create enhanced quick analysis prompt with comprehensive SLP analysis
1314
  questions_text = "\n".join([f"- {q}" for q in questions])
 
 
1315
  prompt = f"""
1316
- You are a speech-language pathologist conducting a COMPREHENSIVE quick analysis of a speech transcript.
1317
 
1318
  Patient: {age_val}-year-old {gender_val}
1319
 
1320
  TRANSCRIPT:
1321
  {transcript}{notes_section}
1322
 
1323
- Please provide a DETAILED analysis addressing these specific areas:
1324
  {questions_text}
1325
 
1326
  ANALYSIS REQUIREMENTS:
1327
 
1328
- For each selected area, provide:
1329
  1. EXACT COUNTS and quantification
1330
  2. SPECIFIC EXAMPLES with exact quotes from transcript
1331
  3. PERCENTAGES and ratios where applicable
1332
- 4. SEVERITY assessment
1333
- 5. AGE-APPROPRIATE evaluation
1334
- 6. CLINICAL significance
1335
- 7. INTERVENTION considerations
1336
 
1337
  DETAILED ANALYSIS GUIDELINES:
1338
 
@@ -1342,21 +1399,23 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1342
  - Identify and count each sentence type (simple, compound, complex, compound-complex)
1343
  - Calculate complexity ratios and percentages
1344
  - Assess embedding depth and clause complexity
 
1345
  - Provide specific examples for each pattern
1346
 
1347
  For FIGURATIVE LANGUAGE analysis:
1348
  - Count and cite EVERY simile (comparisons using "like" or "as")
1349
  - Count and cite EVERY metaphor (direct comparisons without "like" or "as")
1350
  - Count and cite EVERY idiom and non-literal expression
1351
- - Assess creativity and age-appropriate use
1352
  - Provide specific examples with context
1353
 
1354
  For PRAGMATIC and SOCIAL COMMUNICATION:
1355
- - Count and analyze turn-taking patterns
1356
- - Assess topic maintenance and shifting abilities
1357
  - Evaluate social appropriateness and register use
1358
  - Count interruptions or conversational breakdowns
1359
- - Analyze non-literal language comprehension
 
 
1360
  - Provide specific examples of pragmatic behaviors
1361
 
1362
  For VOCABULARY and SEMANTIC analysis:
@@ -1365,6 +1424,8 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1365
  - Analyze word retrieval strategies and circumlocution
1366
  - Assess semantic precision and relationships
1367
  - Count academic vs. everyday vocabulary use
 
 
1368
  - Provide specific examples of vocabulary patterns
1369
 
1370
  For MORPHOLOGICAL and PHONOLOGICAL analysis:
@@ -1372,20 +1433,25 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1372
  - Count and cite EVERY derivational morpheme (prefixes, suffixes)
1373
  - Identify and count phonological patterns and errors
1374
  - Assess syllable structure and stress patterns
 
1375
  - Provide specific examples of morphological use
1376
 
1377
  For COGNITIVE-LINGUISTIC factors:
1378
- - Assess working memory demands in language production
1379
- - Analyze processing speed and efficiency
1380
  - Count and evaluate attention and focus patterns
1381
- - Assess executive function skills and self-monitoring
 
 
1382
  - Provide specific examples of cognitive-linguistic patterns
1383
 
1384
  For FLUENCY and SPEECH RATE:
1385
  - Count and cite EVERY disfluency (fillers, repetitions, revisions)
1386
- - Calculate speech rate and variability
1387
- - Analyze pause patterns and their function
1388
  - Assess overall speech naturalness
 
 
1389
  - Provide specific examples of fluency patterns
1390
 
1391
  For GRAMMAR and LANGUAGE ERRORS:
@@ -1393,6 +1459,8 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1393
  - Count and cite EVERY syntactic error
1394
  - Count and cite EVERY morphological error
1395
  - Calculate error rates and percentages
 
 
1396
  - Provide specific examples of error patterns
1397
 
1398
  For WORD-FINDING and RETRIEVAL:
@@ -1400,6 +1468,8 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1400
  - Count and cite EVERY incomplete thought
1401
  - Count and cite EVERY word-finding pause
1402
  - Analyze word retrieval strategies used
 
 
1403
  - Provide specific examples of retrieval patterns
1404
 
1405
  For NARRATIVE and DISCOURSE:
@@ -1407,6 +1477,8 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1407
  - Count topic shifts and maintenance
1408
  - Analyze discourse markers and transitions
1409
  - Evaluate story structure and completeness
 
 
1410
  - Provide specific examples of narrative patterns
1411
 
1412
  FORMAT REQUIREMENTS:
@@ -1414,15 +1486,17 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1414
  - Include bullet points for organization
1415
  - Provide exact counts and percentages
1416
  - Cite specific quotes from transcript
1417
- - Include severity assessments
1418
- - Provide clinical implications
1419
- - Be comprehensive but focused on selected areas
1420
-
1421
- Remember: This should be a DETAILED analysis that thoroughly addresses each selected area with quantification, evidence, and clinical relevance.
 
 
1422
  """
1423
 
1424
- result = call_claude_api_with_continuation(prompt, max_continuations=2)
1425
- progress_msg = "βœ… Quick analysis completed" if "[Analysis completed in" in result else "πŸ”„ Quick analysis in progress..."
1426
  return result, progress_msg
1427
 
1428
  # Connect event handlers
@@ -1469,7 +1543,7 @@ with gr.Blocks(title="Enhanced CASL Analysis", theme=gr.themes.Soft()) as app:
1469
  )
1470
 
1471
  if __name__ == "__main__":
1472
- print("πŸš€ Starting Enhanced CASL Analysis Tool...")
1473
  print("πŸ“Š Features: Basic Analysis, Targeted Questions, Quick Multi-Analysis, Advanced Transcription")
1474
  print("🎀 Transcription: Audio/Video support with speaker diarization, sentiment, and emotion analysis")
1475
  print("πŸ“ˆ Analysis: Complex sentences, figurative language, pragmatic skills, cognitive-linguistic factors")
 
173
  ]
174
 
175
  combined_parts = []
176
+ combined_parts.append("COMPREHENSIVE SPEECH SAMPLE ANALYSIS")
177
  combined_parts.append("")
178
 
179
  for section in required_sections:
 
207
  ]
208
 
209
  # Safety limits to prevent infinite loops
210
+ MAX_CONTINUATIONS = 30 # Increased from 20 to 30 API calls
211
+ MAX_TIME_MINUTES = 15 # Increased from 10 to 15 minutes total
212
+ MIN_PROGRESS_PER_CALL = 0 # Changed from 1 to 0 to allow more flexibility
213
 
214
  try:
215
  all_sections = {} # Store all sections found across all parts
 
218
  last_section_count = 0 # Track progress between calls
219
 
220
  # Add continuation instruction to original prompt
221
+ initial_prompt = prompt + "\n\nCRITICAL INSTRUCTIONS: You MUST complete ALL 12 sections of the analysis. If your response is cut off or incomplete, end with <CONTINUE> to indicate more content is needed. Do not skip any sections. Use the checklist to ensure all sections are completed."
222
 
223
  while True: # Unlimited continuations until complete
224
  if continuation_count == 0:
 
228
  missing_sections = [s for s in required_sections if s not in all_sections]
229
  missing_text = "\n".join([f"- {section}" for section in missing_sections])
230
 
231
+ current_prompt = prompt + f"\n\nCONTINUATION {continuation_count + 1}: The following sections are STILL MISSING and MUST be completed:\n\n{missing_text}\n\nCRITICAL: Provide ONLY these missing sections. Do not repeat any sections that are already complete. Focus exclusively on the missing sections listed above. Complete ALL missing sections in this response."
232
 
233
  headers = {
234
  "Content-Type": "application/json",
 
296
 
297
  # Check if we're making progress
298
  if continuation_count > 0 and progress_made < MIN_PROGRESS_PER_CALL:
299
+ # Only stop if we've made multiple calls with no progress
300
+ if continuation_count > 3: # Allow more attempts before giving up
301
+ logger.warning(f"No progress made in last call (added {progress_made} sections). Stopping to prevent infinite loop.")
302
+ break
303
+ else:
304
+ logger.info(f"No progress in call {continuation_count}, but continuing to allow more attempts...")
305
 
306
  # Check time limit
307
  if elapsed_minutes > MAX_TIME_MINUTES:
 
349
  if len(all_sections) < 12:
350
  missing_sections = [s for s in required_sections if s not in all_sections]
351
  final_response += f"\n\n⚠️ WARNING: Analysis incomplete due to safety limits. Missing sections: {', '.join(missing_sections)}"
352
+ final_response += f"\n\nπŸ’‘ TIP: Try running the analysis again, or use the 'Targeted Analysis' tab to focus on specific areas."
353
+ final_response += f"\nThe 'Quick Questions' tab may also provide faster results for specific areas of interest."
354
 
355
  return final_response
356
 
357
+ def call_claude_api_quick_analysis(prompt):
358
+ """Call Claude API for quick focused analysis - single response only"""
359
+ if not ANTHROPIC_API_KEY:
360
+ return "❌ Claude API key not configured. Please set ANTHROPIC_API_KEY environment variable."
361
+
362
+ try:
363
+ headers = {
364
+ "Content-Type": "application/json",
365
+ "x-api-key": ANTHROPIC_API_KEY,
366
+ "anthropic-version": "2023-06-01"
367
+ }
368
+
369
+ data = {
370
+ "model": "claude-3-5-sonnet-20241022",
371
+ "max_tokens": 4096,
372
+ "messages": [
373
+ {
374
+ "role": "user",
375
+ "content": prompt
376
+ }
377
+ ]
378
+ }
379
+
380
+ response = requests.post(
381
+ "https://api.anthropic.com/v1/messages",
382
+ headers=headers,
383
+ json=data,
384
+ timeout=90
385
+ )
386
+
387
+ if response.status_code == 200:
388
+ response_json = response.json()
389
+ return response_json['content'][0]['text']
390
+ else:
391
+ logger.error(f"Claude API error: {response.status_code} - {response.text}")
392
+ return f"❌ Claude API Error: {response.status_code}"
393
+
394
+ except Exception as e:
395
+ logger.error(f"Error calling Claude API: {str(e)}")
396
+ return f"❌ Error: {str(e)}"
397
+
398
  def call_claude_api(prompt):
399
  """Call Claude API directly (legacy function for backward compatibility)"""
400
+ return call_claude_api_quick_analysis(prompt)
401
 
402
  def extract_audio_from_video(video_path):
403
  """Extract audio from video file"""
 
681
 
682
  # Enhanced comprehensive analysis prompt with detailed quantification
683
  prompt = f"""
684
+ You are a speech-language pathologist conducting a COMPREHENSIVE speech sample assessment. Provide a SINGLE, DETAILED analysis that quantifies EVERY occurrence and cites specific examples.
685
 
686
  Patient: {age}-year-old {gender}
687
 
 
690
 
691
  INSTRUCTIONS: Provide ONE comprehensive analysis covering ALL areas below. QUANTIFY EVERYTHING with exact counts and cite SPECIFIC examples from the transcript. Be thorough and detailed. COMPLETE ALL 12 SECTIONS.
692
 
693
+ COMPREHENSIVE SPEECH SAMPLE ANALYSIS:
694
 
695
  1. SPEECH FACTORS (with EXACT counts and specific citations):
696
 
 
1029
  """
1030
 
1031
  # Get targeted analysis from Claude API
1032
+ result = call_claude_api_quick_analysis(prompt)
1033
  return result
1034
 
1035
  # Create enhanced interface with tabs
1036
+ with gr.Blocks(title="Enhanced Speech Sample Analysis", theme=gr.themes.Soft()) as app:
1037
 
1038
+ gr.Markdown("# πŸ—£οΈ Enhanced Speech Sample Analysis Tool")
1039
+ gr.Markdown("Upload a speech transcript, paste text, or transcribe audio/video and get instant speech sample assessment results with targeted analysis options.")
1040
 
1041
  # Store transcript globally
1042
  transcript_state = gr.State("")
 
1110
  gr.Markdown("### Analysis Results")
1111
 
1112
  output = gr.Textbox(
1113
+ label="Speech Sample Analysis Report",
1114
  placeholder="Analysis results will appear here...",
1115
  lines=25,
1116
  max_lines=30
 
1192
  quick_questions = gr.CheckboxGroup(
1193
  choices=[
1194
  "Word-finding difficulties",
1195
+ "Grammatical errors",
1196
  "Fluency issues",
1197
  "Pragmatic skills",
1198
  "Narrative structure",
1199
  "Vocabulary level",
 
 
1200
  "Complex sentence analysis",
1201
  "Figurative language use",
1202
  "Morphological markers",
1203
  "Phonological patterns",
1204
+ "Cognitive-linguistic factors"
 
 
 
 
 
 
 
1205
  ],
1206
  label="Select questions to analyze:",
1207
  value=[]
 
1347
  {notes.strip()}
1348
  """
1349
 
1350
+ # Map selected questions to analysis sections
1351
+ question_mapping = {
1352
+ "Word-finding difficulties": "WORD-FINDING and RETRIEVAL",
1353
+ "Grammatical errors": "GRAMMAR and LANGUAGE ERRORS",
1354
+ "Fluency issues": "FLUENCY and SPEECH RATE",
1355
+ "Pragmatic skills": "PRAGMATIC and SOCIAL COMMUNICATION",
1356
+ "Narrative structure": "NARRATIVE and DISCOURSE",
1357
+ "Vocabulary level": "VOCABULARY and SEMANTIC analysis",
1358
+ "Complex sentence analysis": "SYNTAX and COMPLEX SENTENCE analysis",
1359
+ "Figurative language use": "FIGURATIVE LANGUAGE analysis",
1360
+ "Morphological markers": "MORPHOLOGICAL and PHONOLOGICAL analysis",
1361
+ "Phonological patterns": "MORPHOLOGICAL and PHONOLOGICAL analysis",
1362
+ "Cognitive-linguistic factors": "COGNITIVE-LINGUISTIC factors"
1363
+ }
1364
+
1365
+ # Get unique analysis sections for selected questions
1366
+ selected_sections = set()
1367
+ for question in questions:
1368
+ if question in question_mapping:
1369
+ selected_sections.add(question_mapping[question])
1370
+
1371
  # Create enhanced quick analysis prompt with comprehensive SLP analysis
1372
  questions_text = "\n".join([f"- {q}" for q in questions])
1373
+ sections_text = "\n".join([f"- {section}" for section in selected_sections])
1374
+
1375
  prompt = f"""
1376
+ You are a speech-language pathologist conducting a FOCUSED analysis of specific areas in a speech transcript.
1377
 
1378
  Patient: {age_val}-year-old {gender_val}
1379
 
1380
  TRANSCRIPT:
1381
  {transcript}{notes_section}
1382
 
1383
+ ANALYZE ONLY THESE SPECIFIC AREAS:
1384
  {questions_text}
1385
 
1386
  ANALYSIS REQUIREMENTS:
1387
 
1388
+ For each selected area, provide ONLY:
1389
  1. EXACT COUNTS and quantification
1390
  2. SPECIFIC EXAMPLES with exact quotes from transcript
1391
  3. PERCENTAGES and ratios where applicable
1392
+ 4. SEVERITY assessment (mild/moderate/severe)
 
 
 
1393
 
1394
  DETAILED ANALYSIS GUIDELINES:
1395
 
 
1399
  - Identify and count each sentence type (simple, compound, complex, compound-complex)
1400
  - Calculate complexity ratios and percentages
1401
  - Assess embedding depth and clause complexity
1402
+ - Analyze sentence length patterns and variability
1403
  - Provide specific examples for each pattern
1404
 
1405
  For FIGURATIVE LANGUAGE analysis:
1406
  - Count and cite EVERY simile (comparisons using "like" or "as")
1407
  - Count and cite EVERY metaphor (direct comparisons without "like" or "as")
1408
  - Count and cite EVERY idiom and non-literal expression
 
1409
  - Provide specific examples with context
1410
 
1411
  For PRAGMATIC and SOCIAL COMMUNICATION:
1412
+ - Count and analyze turn-taking patterns (including interruptions, overlaps, response timing)
1413
+ - Assess topic maintenance and shifting abilities (including topic introduction, maintenance, and transitions)
1414
  - Evaluate social appropriateness and register use
1415
  - Count interruptions or conversational breakdowns
1416
+ - Analyze non-literal language comprehension (sarcasm, humor, irony)
1417
+ - Assess conversational repair strategies
1418
+ - Evaluate politeness markers and social awareness
1419
  - Provide specific examples of pragmatic behaviors
1420
 
1421
  For VOCABULARY and SEMANTIC analysis:
 
1424
  - Analyze word retrieval strategies and circumlocution
1425
  - Assess semantic precision and relationships
1426
  - Count academic vs. everyday vocabulary use
1427
+ - Analyze vocabulary diversity and range
1428
+ - Assess semantic relationships (synonyms, antonyms, categories)
1429
  - Provide specific examples of vocabulary patterns
1430
 
1431
  For MORPHOLOGICAL and PHONOLOGICAL analysis:
 
1433
  - Count and cite EVERY derivational morpheme (prefixes, suffixes)
1434
  - Identify and count phonological patterns and errors
1435
  - Assess syllable structure and stress patterns
1436
+ - Analyze morphological complexity
1437
  - Provide specific examples of morphological use
1438
 
1439
  For COGNITIVE-LINGUISTIC factors:
1440
+ - Assess working memory demands in language production (sentence length, complexity)
1441
+ - Analyze processing speed and efficiency (response time, fluency)
1442
  - Count and evaluate attention and focus patterns
1443
+ - Assess executive function skills and self-monitoring (planning, organization, self-correction)
1444
+ - Analyze metalinguistic awareness (ability to think about language)
1445
+ - Evaluate cognitive flexibility in language use
1446
  - Provide specific examples of cognitive-linguistic patterns
1447
 
1448
  For FLUENCY and SPEECH RATE:
1449
  - Count and cite EVERY disfluency (fillers, repetitions, revisions)
1450
+ - Calculate speech rate and variability (words per minute, rate changes)
1451
+ - Analyze pause patterns and their function (thinking pauses, grammatical pauses)
1452
  - Assess overall speech naturalness
1453
+ - Evaluate rhythm and prosody patterns
1454
+ - Analyze rate-accuracy trade-offs
1455
  - Provide specific examples of fluency patterns
1456
 
1457
  For GRAMMAR and LANGUAGE ERRORS:
 
1459
  - Count and cite EVERY syntactic error
1460
  - Count and cite EVERY morphological error
1461
  - Calculate error rates and percentages
1462
+ - Analyze error patterns and consistency
1463
+ - Assess error severity and impact on communication
1464
  - Provide specific examples of error patterns
1465
 
1466
  For WORD-FINDING and RETRIEVAL:
 
1468
  - Count and cite EVERY incomplete thought
1469
  - Count and cite EVERY word-finding pause
1470
  - Analyze word retrieval strategies used
1471
+ - Assess naming accuracy and efficiency
1472
+ - Evaluate semantic paraphasias and word substitutions
1473
  - Provide specific examples of retrieval patterns
1474
 
1475
  For NARRATIVE and DISCOURSE:
 
1477
  - Count topic shifts and maintenance
1478
  - Analyze discourse markers and transitions
1479
  - Evaluate story structure and completeness
1480
+ - Assess narrative cohesion and logical flow
1481
+ - Analyze discourse-level language skills
1482
  - Provide specific examples of narrative patterns
1483
 
1484
  FORMAT REQUIREMENTS:
 
1486
  - Include bullet points for organization
1487
  - Provide exact counts and percentages
1488
  - Cite specific quotes from transcript
1489
+ - Include severity assessments (mild/moderate/severe) - very simple
1490
+ - Focus ONLY on the requested areas
1491
+ - Do NOT include age-appropriateness evaluations
1492
+ - Do NOT include clinical implications or recommendations
1493
+ - Do NOT include intervention suggestions
1494
+ - Do NOT include overall assessments
1495
+ - Keep analysis focused and concise
1496
  """
1497
 
1498
+ result = call_claude_api_quick_analysis(prompt)
1499
+ progress_msg = "βœ… Quick analysis completed"
1500
  return result, progress_msg
1501
 
1502
  # Connect event handlers
 
1543
  )
1544
 
1545
  if __name__ == "__main__":
1546
+ print("πŸš€ Starting Enhanced Speech Sample Analysis Tool...")
1547
  print("πŸ“Š Features: Basic Analysis, Targeted Questions, Quick Multi-Analysis, Advanced Transcription")
1548
  print("🎀 Transcription: Audio/Video support with speaker diarization, sentiment, and emotion analysis")
1549
  print("πŸ“ˆ Analysis: Complex sentences, figurative language, pragmatic skills, cognitive-linguistic factors")