File size: 748 Bytes
8ad2ab3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import whisper
from .compute_vps_score import compute_vps_score

def main(file_path: str, model_size: str = "base") -> dict:
    try:
        # Load the Whisper model
        whisper_model = whisper.load_model(model_size)

        # Calculate the voice confidence score
        result = compute_vps_score(file_path, whisper_model)

        # Return the result as a dictionary
        return {
            "VPS": result["VPS"]
            # "SRS": result["SRS"],
            # "PAS": result["PAS"],
            # "NPP": result["NPP"],
            # "AFW": result["AFW"],
            # "RCS": result["RCS"],
            # "STR": result["STR"],
            # "STW": result["STW"]
        }
    except Exception as e:
        return {"error": str(e)}