| import json |
| import whisper |
| from .compute_vcs import analyze_voice_quality |
|
|
| def main(): |
| """ |
| Main function to run voice clarity 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 voice clarity for {audio_file}...") |
| results = analyze_voice_quality(audio_file, whisper_model) |
| |
| |
| print("\nVoice Quality Analysis Results:") |
| print(f"- Voice Clarity Score (VCS): {results['VCS']:.2f}/100") |
| print(f"- Insight: {results['insight']}") |
| print(f"- Articulation: {results['components']['articulation']:.2f}/100") |
| print(f"- Enunciation: {results['components']['enunciation']:.2f}/100") |
| print(f"- Speech Pause Control: {results['components']['speech_pause_control']:.2f}/100") |
| |
| |
| if verbose: |
| print("\nDetailed Metrics:") |
| print(f"- Pitch Stability: {results['components']['pitch_stability']:.2f}/100") |
| print(f"- Voice Resonance: {results['components']['voice_resonance']:.2f}/100") |
| print(f"- Voice Strength: {results['components']['voice_strength']:.2f}/100") |
| print(f"- Word Count: {results['components']['word_count']}") |
| print(f"- Duration: {results['components']['duration']:.2f} seconds") |
| |
| |
| 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()) |