Fast_api / voice_confidence_score /voice_confidence.py
mulasagg's picture
API optimizations
aef3b1e
# voice confidence score = 0.4 * dominance + 0.3 * scs + 0.3 * fluency.
import whisper
from fluency.compute_fluency import compute_fluency_score
from vcs.compute_vcs import analyze_voice_quality
def calc_fluency_score(audio_path, whisper_model, filler_count=None):
# Calculate fluency score
print(f"Analyzing fluency for {audio_path}...")
results = compute_fluency_score(audio_path, whisper_model, filler_count)
fluency_score = results['fluency_score']
return fluency_score
def calc_vcs(audio_path, whisper_model):
# Calculate voice clarity score
print(f"Analyzing voice clarity for {audio_path}...")
results = analyze_voice_quality(audio_path, whisper_model)
vcs = results['VCS']
return vcs
dominance = 5.6 # dummy for now i add later
def calc_voice_confidence_score(audio_path, model, filler_count= None, fluency_score=None):
if fluency_score is None:
print(' No args passed Calling calc_fluency_score')
fluency_score = calc_fluency_score(audio_path, model, filler_count)
vcs = calc_vcs(audio_path, model)
# Calculate voice confidence score
voice_confidence_score = 0.4 * dominance + 0.3 * vcs + 0.3 * fluency_score
return voice_confidence_score