File size: 944 Bytes
04dc213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
33
34
"""Minimal example: predict speech genuineness (0-6) for a wav file.

Usage:
    python example.py path/to/clip.wav [full|balanced]

The model argument is optional and defaults to ``full`` (best overall MAE/corr).
Higher score = sounds more like a real, lived-in spoken moment; lower =
more rehearsed / synthetic.
"""
import os
import sys

from genuineness_scorer import GenuinenessScorer


def main():
    if len(sys.argv) < 2:
        print("usage: python example.py <clip.wav> [full|balanced]")
        sys.exit(1)
    wav_path = sys.argv[1]
    model = sys.argv[2] if len(sys.argv) > 2 else "full"

    pkg_dir = os.path.dirname(os.path.abspath(__file__))
    import torch
    device = "cuda" if torch.cuda.is_available() else "cpu"

    scorer = GenuinenessScorer(pkg_dir=pkg_dir, model=model, device=device)
    score = scorer.score(wav_path)
    print(f"[{model}] genuineness (0-6): {score:.3f}")


if __name__ == "__main__":
    main()