aliabd HF staff commited on
Commit
ba218c7
1 Parent(s): 38c1592

Upload with huggingface_hub

Browse files
Files changed (3) hide show
  1. DESCRIPTION.md +1 -0
  2. README.md +1 -1
  3. app.py +1 -9
DESCRIPTION.md ADDED
@@ -0,0 +1 @@
 
1
+ This demo identifies if two speakers are the same person using Gradio's Audio and HTML components.
README.md CHANGED
@@ -1,7 +1,7 @@
1
 
2
  ---
3
  title: same-person-or-different
4
- emoji: 🤗
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
1
 
2
  ---
3
  title: same-person-or-different
4
+ emoji: 🔥
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
app.py CHANGED
@@ -1,13 +1,9 @@
1
- # URL: https://huggingface.co/spaces/gradio/same-person-or-different
2
- # DESCRIPTION: This demo identifies if two speakers are the same person using Gradio's Audio and HTML components.
3
- # imports
4
  import gradio as gr
5
  import torch
6
  from torchaudio.sox_effects import apply_effects_file
7
  from transformers import AutoFeatureExtractor, AutoModelForAudioXVector
8
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
9
 
10
- # define outputs for HTML component
11
  OUTPUT_OK = (
12
  """
13
  <div class="container">
@@ -31,8 +27,6 @@ OUTPUT_FAIL = (
31
  """
32
  )
33
 
34
- # load model and define constants
35
-
36
  EFFECTS = [
37
  ["remix", "-"],
38
  ["channels", "1"],
@@ -50,7 +44,6 @@ model = AutoModelForAudioXVector.from_pretrained(model_name).to(device)
50
  cosine_sim = torch.nn.CosineSimilarity(dim=-1)
51
 
52
 
53
- # define core fn
54
  def similarity_fn(path1, path2):
55
  if not (path1 and path2):
56
  return '<b style="color:red">ERROR: Please record audio for *both* speakers!</b>'
@@ -76,7 +69,6 @@ def similarity_fn(path1, path2):
76
 
77
  return output
78
 
79
- #define inputs, outputs, description, article and examples
80
  inputs = [
81
  gr.inputs.Audio(source="microphone", type="filepath", optional=True, label="Speaker #1"),
82
  gr.inputs.Audio(source="microphone", type="filepath", optional=True, label="Speaker #2"),
@@ -99,7 +91,7 @@ examples = [
99
  ["samples/cate_blanch.mp3", "samples/cate_blanch_2.mp3"],
100
  ["samples/cate_blanch.mp3", "samples/heath_ledger.mp3"],
101
  ]
102
- # define interface
103
  interface = gr.Interface(
104
  fn=similarity_fn,
105
  inputs=inputs,
 
 
 
1
  import gradio as gr
2
  import torch
3
  from torchaudio.sox_effects import apply_effects_file
4
  from transformers import AutoFeatureExtractor, AutoModelForAudioXVector
5
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
6
 
 
7
  OUTPUT_OK = (
8
  """
9
  <div class="container">
27
  """
28
  )
29
 
 
 
30
  EFFECTS = [
31
  ["remix", "-"],
32
  ["channels", "1"],
44
  cosine_sim = torch.nn.CosineSimilarity(dim=-1)
45
 
46
 
 
47
  def similarity_fn(path1, path2):
48
  if not (path1 and path2):
49
  return '<b style="color:red">ERROR: Please record audio for *both* speakers!</b>'
69
 
70
  return output
71
 
 
72
  inputs = [
73
  gr.inputs.Audio(source="microphone", type="filepath", optional=True, label="Speaker #1"),
74
  gr.inputs.Audio(source="microphone", type="filepath", optional=True, label="Speaker #2"),
91
  ["samples/cate_blanch.mp3", "samples/cate_blanch_2.mp3"],
92
  ["samples/cate_blanch.mp3", "samples/heath_ledger.mp3"],
93
  ]
94
+
95
  interface = gr.Interface(
96
  fn=similarity_fn,
97
  inputs=inputs,