speech-test commited on
Commit
0a57289
β€’
1 Parent(s): 70b5707

Formatting

Browse files
Files changed (1) hide show
  1. app.py +33 -26
app.py CHANGED
@@ -1,5 +1,5 @@
1
- import torch
2
  import gradio as gr
 
3
  from torchaudio.sox_effects import apply_effects_file
4
  from transformers import AutoFeatureExtractor, AutoModelForAudioXVector
5
 
@@ -8,7 +8,9 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
  STYLE = """
9
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha256-YvdLHPgkqJ8DVUxjjnGVlMMJtNimJ6dYkowFFvp4kKs=" crossorigin="anonymous">
10
  """
11
- OUTPUT_OK = STYLE + """
 
 
12
  <div class="container">
13
  <div class="row"><h1 style="text-align: center">The speakers are</h1></div>
14
  <div class="row"><h1 class="display-1 text-success" style="text-align: center">{:.1f}%</h1></div>
@@ -17,7 +19,10 @@ OUTPUT_OK = STYLE + """
17
  <div class="row"><small style="text-align: center">(You must get at least 85% to be considered the same person)</small><div class="row">
18
  </div>
19
  """
20
- OUTPUT_FAIL = STYLE + """
 
 
 
21
  <div class="container">
22
  <div class="row"><h1 style="text-align: center">The speakers are</h1></div>
23
  <div class="row"><h1 class="display-1 text-danger" style="text-align: center">{:.1f}%</h1></div>
@@ -26,14 +31,15 @@ OUTPUT_FAIL = STYLE + """
26
  <div class="row"><small style="text-align: center">(You must get at least 85% to be considered the same person)</small><div class="row">
27
  </div>
28
  """
 
29
 
30
  EFFECTS = [
31
- ['remix', '-'],
32
  ["channels", "1"],
33
  ["rate", "16000"],
34
  ["gain", "-1.0"],
35
  ["silence", "1", "0.1", "0.1%", "-1", "0.1", "0.1%"],
36
- ['trim', '0', '10'],
37
  ]
38
 
39
  THRESHOLD = 0.85
@@ -88,6 +94,27 @@ article = (
88
  "<a href='https://www.danielpovey.com/files/2018_icassp_xvectors.pdf' target='_blank'>πŸ“š X-Vector paper</a>"
89
  "</p>"
90
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  interface = gr.Interface(
93
  fn=similarity_fn,
@@ -100,26 +127,6 @@ interface = gr.Interface(
100
  theme="huggingface",
101
  allow_flagging=False,
102
  live=False,
103
- examples=[
104
- ["samples/cate_blanch.mp3", "samples/cate_blanch_2.mp3"],
105
- ["samples/cate_blanch.mp3", "samples/cate_blanch_3.mp3"],
106
- ["samples/cate_blanch_2.mp3", "samples/cate_blanch_3.mp3"],
107
- ["samples/heath_ledger.mp3", "samples/heath_ledger_2.mp3"],
108
- ["samples/heath_ledger.mp3", "samples/heath_ledger_3.mp3"],
109
- ["samples/heath_ledger_2.mp3", "samples/heath_ledger_3.mp3"],
110
- ["samples/russel_crowe.mp3", "samples/russel_crowe_2.mp3"],
111
- ["samples/cate_blanch.mp3", "samples/kirsten_dunst.wav"],
112
- ["samples/russel_crowe.mp3", "samples/kirsten_dunst.wav"],
113
- ["samples/russel_crowe_2.mp3", "samples/kirsten_dunst.wav"],
114
- ["samples/leonardo_dicaprio.mp3", "samples/denzel_washington.mp3"],
115
- ["samples/heath_ledger.mp3", "samples/denzel_washington.mp3"],
116
- ["samples/heath_ledger_2.mp3", "samples/denzel_washington.mp3"],
117
- ["samples/leonardo_dicaprio.mp3", "samples/russel_crowe.mp3"],
118
- ["samples/leonardo_dicaprio.mp3", "samples/russel_crowe_2.mp3"],
119
- ["samples/naomi_watts.mp3", "samples/denzel_washington.mp3"],
120
- ["samples/naomi_watts.mp3", "samples/leonardo_dicaprio.mp3"],
121
- ["samples/naomi_watts.mp3", "samples/cate_blanch_2.mp3"],
122
- ["samples/naomi_watts.mp3", "samples/kirsten_dunst.wav"],
123
- ]
124
  )
125
  interface.launch(enable_queue=True)
 
 
1
  import gradio as gr
2
+ import torch
3
  from torchaudio.sox_effects import apply_effects_file
4
  from transformers import AutoFeatureExtractor, AutoModelForAudioXVector
5
 
 
8
  STYLE = """
9
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha256-YvdLHPgkqJ8DVUxjjnGVlMMJtNimJ6dYkowFFvp4kKs=" crossorigin="anonymous">
10
  """
11
+ OUTPUT_OK = (
12
+ STYLE
13
+ + """
14
  <div class="container">
15
  <div class="row"><h1 style="text-align: center">The speakers are</h1></div>
16
  <div class="row"><h1 class="display-1 text-success" style="text-align: center">{:.1f}%</h1></div>
 
19
  <div class="row"><small style="text-align: center">(You must get at least 85% to be considered the same person)</small><div class="row">
20
  </div>
21
  """
22
+ )
23
+ OUTPUT_FAIL = (
24
+ STYLE
25
+ + """
26
  <div class="container">
27
  <div class="row"><h1 style="text-align: center">The speakers are</h1></div>
28
  <div class="row"><h1 class="display-1 text-danger" style="text-align: center">{:.1f}%</h1></div>
 
31
  <div class="row"><small style="text-align: center">(You must get at least 85% to be considered the same person)</small><div class="row">
32
  </div>
33
  """
34
+ )
35
 
36
  EFFECTS = [
37
+ ["remix", "-"],
38
  ["channels", "1"],
39
  ["rate", "16000"],
40
  ["gain", "-1.0"],
41
  ["silence", "1", "0.1", "0.1%", "-1", "0.1", "0.1%"],
42
+ ["trim", "0", "10"],
43
  ]
44
 
45
  THRESHOLD = 0.85
 
94
  "<a href='https://www.danielpovey.com/files/2018_icassp_xvectors.pdf' target='_blank'>πŸ“š X-Vector paper</a>"
95
  "</p>"
96
  )
97
+ examples = [
98
+ ["samples/cate_blanch.mp3", "samples/cate_blanch_2.mp3"],
99
+ ["samples/cate_blanch.mp3", "samples/cate_blanch_3.mp3"],
100
+ ["samples/cate_blanch_2.mp3", "samples/cate_blanch_3.mp3"],
101
+ ["samples/heath_ledger.mp3", "samples/heath_ledger_2.mp3"],
102
+ ["samples/heath_ledger.mp3", "samples/heath_ledger_3.mp3"],
103
+ ["samples/heath_ledger_2.mp3", "samples/heath_ledger_3.mp3"],
104
+ ["samples/russel_crowe.mp3", "samples/russel_crowe_2.mp3"],
105
+ ["samples/cate_blanch.mp3", "samples/kirsten_dunst.wav"],
106
+ ["samples/russel_crowe.mp3", "samples/kirsten_dunst.wav"],
107
+ ["samples/russel_crowe_2.mp3", "samples/kirsten_dunst.wav"],
108
+ ["samples/leonardo_dicaprio.mp3", "samples/denzel_washington.mp3"],
109
+ ["samples/heath_ledger.mp3", "samples/denzel_washington.mp3"],
110
+ ["samples/heath_ledger_2.mp3", "samples/denzel_washington.mp3"],
111
+ ["samples/leonardo_dicaprio.mp3", "samples/russel_crowe.mp3"],
112
+ ["samples/leonardo_dicaprio.mp3", "samples/russel_crowe_2.mp3"],
113
+ ["samples/naomi_watts.mp3", "samples/denzel_washington.mp3"],
114
+ ["samples/naomi_watts.mp3", "samples/leonardo_dicaprio.mp3"],
115
+ ["samples/naomi_watts.mp3", "samples/cate_blanch_2.mp3"],
116
+ ["samples/naomi_watts.mp3", "samples/kirsten_dunst.wav"],
117
+ ]
118
 
119
  interface = gr.Interface(
120
  fn=similarity_fn,
 
127
  theme="huggingface",
128
  allow_flagging=False,
129
  live=False,
130
+ examples=examples,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  )
132
  interface.launch(enable_queue=True)