|
import json |
|
import whisper |
|
from .compute_fluency import compute_fluency_score |
|
|
|
def main(): |
|
""" |
|
Main function to run fluency analysis on audio files |
|
""" |
|
|
|
audio_file = r"D:\Intern\shankh\audio_samples\obama_short.wav" |
|
model_size = "base" |
|
verbose = True |
|
|
|
try: |
|
|
|
print(f"Loading Whisper model ({model_size})...") |
|
whisper_model = whisper.load_model(model_size) |
|
|
|
|
|
print(f"Analyzing fluency for {audio_file}...") |
|
results = compute_fluency_score(audio_file, whisper_model) |
|
|
|
|
|
print("\nFluency Analysis Results:") |
|
print(f"- Fluency Score: {results['fluency_score']:.2f}/100") |
|
print(f"- Insight: {results['insight']}") |
|
print(f"- Speech Rate Stability (SRS): {results['SRS']:.2f}/100") |
|
print(f"- Pause Appropriateness (PAS): {results['PAS']:.2f}/100") |
|
|
|
|
|
if verbose: |
|
print("\nDetailed Metrics:") |
|
print(f"- Words per minute: {results['components']['wpm']:.1f}") |
|
print(f"- Filler word count: {results['components']['filler_count']}") |
|
print(f"- Long pauses: {results['components']['long_pause_count']}") |
|
print(f"- Pitch variation: {results['components']['pitch_variation']:.2f} semitones") |
|
print(f"- Natural Pause Placement: {results['components']['pas_components']['NPP']:.2f}/100") |
|
print(f"- Avoidance of Filler Words: {results['components']['pas_components']['AFW']:.2f}/100") |
|
|
|
|
|
transcript_preview = results['transcript'][:] + "..." if len(results['transcript']) > 100 else results['transcript'] |
|
print(f"\nTranscript preview: {transcript_preview}") |
|
|
|
except Exception as e: |
|
print(f"Error during analysis: {str(e)}") |
|
return 1 |
|
|
|
if __name__ == "__main__": |
|
exit(main()) |