Arnab Das commited on
Commit
f9f0314
1 Parent(s): 272d3e2
Files changed (3) hide show
  1. app.py +13 -2
  2. process_data.py +20 -0
  3. requirements.txt +3 -1
app.py CHANGED
@@ -1,10 +1,21 @@
1
  import gradio as gr
 
2
 
 
 
 
 
 
 
 
 
 
 
3
  def process(file, type):
4
- return str(file)+str(type)
 
5
 
6
  demo = gr.Blocks()
7
-
8
  file_proc = gr.Interface(
9
  fn=process,
10
  inputs=[
 
1
  import gradio as gr
2
+ import process_data as PD
3
 
4
+ model_master= {
5
+ "SSL-AASIST (Trained on ASV-Spoof5)": {"model_loaded": True,
6
+ "eer_threshold":3.3330237865448,
7
+ "data_process_func": "process_ssl_assist_input" ,
8
+ "note": "This model is trained on ASVSpoof 2024 training data."},
9
+ "AASIST": {"model_loaded": False,
10
+ "eer_threshold":1.8018419742584229,
11
+ "data_process_func": "process_assist_input" ,
12
+ "note": "This model is trained on ASVSpoof 2024 training data."}
13
+ }
14
  def process(file, type):
15
+ data = getattr(PD, model_master[type]["data_process_func"])
16
+ return str(file)+str(type)+model_master[type]["eer_threshold"]
17
 
18
  demo = gr.Blocks()
 
19
  file_proc = gr.Interface(
20
  fn=process,
21
  inputs=[
process_data.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import librosa
2
+ import numpy as np
3
+ from torch import Tensor
4
+
5
+ def pad(x, max_len=64600):
6
+ x_len = x.shape[0]
7
+ if x_len >= max_len:
8
+ return x[:max_len]
9
+ # need to pad
10
+ num_repeats = int(max_len / x_len)+1
11
+ padded_x = np.tile(x, (1, num_repeats))[:, :max_len][0]
12
+ return padded_x
13
+
14
+
15
+ def process_ssl_assist_input(filepath):
16
+ X, fs = librosa.load(filepath, sr=16000)
17
+ X_pad = pad(X)
18
+ x_inp = Tensor(X_pad)
19
+ x_inp = x_inp.unsqueeze(0)
20
+ return x_inp
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
  gradio==3.50.2
2
  torch==2.3.0
3
- fairseq
 
 
 
1
  gradio==3.50.2
2
  torch==2.3.0
3
+ fairseq
4
+ librosa==0.10.1
5
+ numpy==1.24.4