Blame view

SpkDiarizationDialog.cpp 8.2 KB
3f2992b2c   bostx   V1.0
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
  #include <QGroupBox>
  #include <QRadioButton>
  #include <QDialogButtonBox>
  #include <QGridLayout>
  #include <QPushButton>
  #include <QFileDialog>
  #include <QLabel>
  
  #include "SpkDiarizationDialog.h"
  
  SpkDiarizationDialog::SpkDiarizationDialog(const QString &title, bool local, bool view, QWidget *parent)
    : QDialog(parent),
      m_dist(UtteranceTree::Mahal),
      m_agrCrit(UtteranceTree::Ward),
      m_partMeth(UtteranceTree::Silhouette),
      m_base(false),
      m_refSpk(false),
      m_sigma(false),
      m_local(local)
  {
    setWindowTitle(title);
  
    QGroupBox *methBox = new QGroupBox("Local clustering method:");
    QRadioButton *hier = new QRadioButton("Bottom-Up hierarchical clustering");
    QRadioButton *base = new QRadioButton("Baseline");
    QRadioButton *refSpk = new QRadioButton("Reference speakers");
    hier->setChecked(true);
    QGridLayout *methLayout = new QGridLayout;
    methLayout->addWidget(hier, 0, 0);
    methLayout->addWidget(base, 1, 0);
    methLayout->addWidget(refSpk, 2, 0);
    methBox->setLayout(methLayout);
  
    m_ubm = new QCheckBox(tr("New GMM/UBM"));
    m_ubm->hide();
  
    QGroupBox *distBox = new QGroupBox("Distance between utterance vectors:");
    m_l2 = new QRadioButton("L2");
    m_mahal = new QRadioButton("Mahalanobis");
    m_mahal->setChecked(true);
    QGridLayout *distLayout = new QGridLayout;
    distLayout->addWidget(m_l2, 0, 0);
    distLayout->addWidget(m_mahal, 0, 1);
    distBox->setLayout(distLayout);
  
    m_norm = new QCheckBox(tr("Normalize vectors"));
    m_norm->setChecked(true);
  
    QGroupBox *covBox = new QGroupBox("Covariance matrix:");
    QChar sigmaChar(0xa3, 0x03);
    QRadioButton *sigma = new QRadioButton(sigmaChar);
    QRadioButton *w = new QRadioButton("W");
    w->setChecked(true);
    QGridLayout *covLayout = new QGridLayout;
    covLayout->addWidget(sigma, 0, 0);
    covLayout->addWidget(w, 0, 1);
    covBox->setLayout(covLayout);
  
    QGroupBox *agrBox = new QGroupBox("Aggregation criterion:");
    QRadioButton *min = new QRadioButton("Min.");
    QRadioButton *max = new QRadioButton("Max.");
    QRadioButton *mean = new QRadioButton("Mean");
    QRadioButton *ward = new QRadioButton("Ward");
    ward->setChecked(true);
    QGridLayout *agrLayout = new QGridLayout;
    agrLayout->addWidget(min, 0, 0);
    agrLayout->addWidget(max, 0, 1);
    agrLayout->addWidget(mean, 0, 2);
    agrLayout->addWidget(ward, 0, 3);
    agrBox->setLayout(agrLayout);
    
    QGroupBox *partBox = new QGroupBox("Method used to select the best partition:");
    QRadioButton *sil = new QRadioButton("Silhouette");
    QRadioButton *bip = new QRadioButton("Bipartition");
    sil->setChecked(true);
    QGridLayout *partLayout = new QGridLayout;
    partLayout->addWidget(sil, 0, 0);
    partLayout->addWidget(bip, 0, 1);
    partBox->setLayout(partLayout);
  
    m_weight = new QCheckBox(tr("Weight Utterances"));
  
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
  						     | QDialogButtonBox::Cancel);
  
    QGridLayout *gridLayout = new QGridLayout;
    gridLayout->addWidget(methBox, 0, 0);
    gridLayout->addWidget(m_ubm, 1, 0);
    gridLayout->addWidget(distBox, 2, 0);
    gridLayout->addWidget(covBox, 3, 0);
    gridLayout->addWidget(m_norm, 4, 0);
    gridLayout->addWidget(agrBox, 5, 0);
    gridLayout->addWidget(partBox, 6, 0);
    gridLayout->addWidget(m_weight, 7, 0);
    gridLayout->addWidget(buttonBox, 8, 0, 1, 2, Qt::AlignHCenter);
  
    setLayout(gridLayout);
  
    // hide options in case of view request
    if (view) {
      methBox->hide();
      distBox->hide();
      covBox->hide();
      m_norm->hide();
      agrBox->hide();
      partBox->hide();
      m_weight->hide();
    }
  
    // connecting signals to corresponding slots
    connect(m_l2, SIGNAL(clicked()), this, SLOT(activL2()));
    connect(m_l2, SIGNAL(clicked(bool)), covBox, SLOT(setDisabled(bool)));
    connect(m_mahal, SIGNAL(clicked()), this, SLOT(activMahal()));
    connect(m_mahal, SIGNAL(clicked(bool)), covBox, SLOT(setEnabled(bool)));
    connect(sigma, SIGNAL(clicked()), this, SLOT(activSigma()));
    connect(w, SIGNAL(clicked()), this, SLOT(activW()));
    connect(min, SIGNAL(clicked()), this, SLOT(activMin()));
    connect(max, SIGNAL(clicked()), this, SLOT(activMax()));
    connect(mean, SIGNAL(clicked()), this, SLOT(activMean()));
    connect(ward, SIGNAL(clicked()), this, SLOT(activWard()));
    connect(sil, SIGNAL(clicked()), this, SLOT(activSilhouette()));
    connect(bip, SIGNAL(clicked()), this, SLOT(activBipartition()));
    connect(base, SIGNAL(clicked()), this, SLOT(activBase()));
    connect(hier, SIGNAL(clicked()), this, SLOT(activHier()));
    connect(refSpk, SIGNAL(clicked()), this, SLOT(activRefSpk()));
  
    connect(base, SIGNAL(clicked(bool)), m_ubm, SLOT(setDisabled(bool)));
    connect(base, SIGNAL(clicked(bool)), distBox, SLOT(setDisabled(bool)));
    connect(base, SIGNAL(clicked(bool)), covBox, SLOT(setDisabled(bool)));
    connect(base, SIGNAL(clicked(bool)), m_norm, SLOT(setDisabled(bool)));
    connect(base, SIGNAL(clicked(bool)), agrBox, SLOT(setDisabled(bool)));
    connect(base, SIGNAL(clicked(bool)), partBox, SLOT(setDisabled(bool)));
    connect(base, SIGNAL(clicked(bool)), m_weight, SLOT(setDisabled(bool)));
  
    connect(refSpk, SIGNAL(clicked(bool)), m_ubm, SLOT(setDisabled(bool)));
    connect(refSpk, SIGNAL(clicked(bool)), distBox, SLOT(setDisabled(bool)));
    connect(refSpk, SIGNAL(clicked(bool)), covBox, SLOT(setDisabled(bool)));
    connect(refSpk, SIGNAL(clicked(bool)), m_norm, SLOT(setDisabled(bool)));
    connect(refSpk, SIGNAL(clicked(bool)), agrBox, SLOT(setDisabled(bool)));
    connect(refSpk, SIGNAL(clicked(bool)), partBox, SLOT(setDisabled(bool)));
    connect(refSpk, SIGNAL(clicked(bool)), m_weight, SLOT(setDisabled(bool)));
    
    connect(hier, SIGNAL(clicked(bool)), m_ubm, SLOT(setEnabled(bool)));
    connect(hier, SIGNAL(clicked(bool)), distBox, SLOT(setEnabled(bool)));
    connect(hier, SIGNAL(clicked(bool)), covBox, SLOT(setEnabled(bool)));
    connect(hier, SIGNAL(clicked(bool)), m_norm, SLOT(setEnabled(bool)));
    connect(hier, SIGNAL(clicked(bool)), agrBox, SLOT(setEnabled(bool)));
    connect(hier, SIGNAL(clicked(bool)), partBox, SLOT(setEnabled(bool)));
    connect(hier, SIGNAL(clicked(bool)), m_weight, SLOT(setEnabled(bool)));
  
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
  }
  
  ///////////////
  // accessors //
  ///////////////
  
  QString SpkDiarizationDialog::getSpeakersFName() const
  {
    return m_speakersFName;
  }
  
  UtteranceTree::DistType SpkDiarizationDialog::getDist() const
  {
    return m_dist;
  }
  
  UtteranceTree::AgrCrit SpkDiarizationDialog::getAgrCrit() const
  {
    return m_agrCrit;
  }
  
  UtteranceTree::PartMeth SpkDiarizationDialog::getPartMeth() const
  {
    return m_partMeth;
  }
  
  bool SpkDiarizationDialog::getBase() const
  {
    return m_base;
  }
  
  bool SpkDiarizationDialog::getRefSpk() const
  {
    return m_refSpk;
  }
  
  bool SpkDiarizationDialog::getNorm() const
  {
    return m_norm->isChecked();
  }
  
  bool SpkDiarizationDialog::getWeight() const
  {
    return m_weight->isChecked();
  }
  
  bool SpkDiarizationDialog::getSigma() const
  {
    return m_sigma;
  }
  
  bool SpkDiarizationDialog::getUbm() const
  {
    return m_ubm->isChecked();
  }
  
  ///////////
  // slots //
  ///////////
  
  void SpkDiarizationDialog::setSpeakersFName()
  {
    m_speakersFName = QFileDialog::getOpenFileName(this, tr("Open characters labels file"), tr("/home/xavier/Dropbox/tv_series_proc_tool/tools/spkDiarization/ivecs"), tr("Data File (*.csv)"));
  }
  
  void SpkDiarizationDialog::activL2()
  {
    m_dist = UtteranceTree::L2;
  }
  
  void SpkDiarizationDialog::activMahal()
  {
    m_dist = UtteranceTree::Mahal;
  }
  
  void SpkDiarizationDialog::activSigma()
  {
    m_sigma = true;
  }
  
  void SpkDiarizationDialog::activW()
  {
    m_sigma = false;
  }
  
  void SpkDiarizationDialog::activMin()
  {
    m_agrCrit = UtteranceTree::Min;
  }
  
  void SpkDiarizationDialog::activMax()
  {
    m_agrCrit = UtteranceTree::Max;
  }
  
  void SpkDiarizationDialog::activMean()
  {
    m_agrCrit = UtteranceTree::Mean;
  }
  
  void SpkDiarizationDialog::activWard()
  {
    m_agrCrit = UtteranceTree::Ward;
    update();
  }
  
  void SpkDiarizationDialog::activSilhouette()
  {
    m_partMeth = UtteranceTree::Silhouette;
  }
  
  void SpkDiarizationDialog::activBipartition()
  {
    m_partMeth = UtteranceTree::Bipartition;
  }
  
  void SpkDiarizationDialog::activBase()
  {
    m_base = true;
    m_refSpk = false;
  }
   
  void SpkDiarizationDialog::activHier()
  {
    m_base = false;
    m_refSpk = false;
  }
  
  void SpkDiarizationDialog::activRefSpk()
  {
    m_base = false;
    m_refSpk = true;
  }