Anchor-annotator 0.8.1__py3-none-any.whl → 0.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anchor/_version.py +9 -4
- anchor/command_line.py +1 -0
- anchor/main.py +113 -6
- anchor/models.py +402 -23
- anchor/plot.py +835 -104
- anchor/settings.py +6 -10
- anchor/ui_main_window.py +14 -8
- anchor/undo.py +672 -11
- anchor/widgets.py +308 -44
- anchor/workers.py +632 -351
- {Anchor_annotator-0.8.1.dist-info → anchor_annotator-0.9.0.dist-info}/METADATA +3 -2
- anchor_annotator-0.9.0.dist-info/RECORD +22 -0
- {Anchor_annotator-0.8.1.dist-info → anchor_annotator-0.9.0.dist-info}/WHEEL +1 -1
- Anchor_annotator-0.8.1.dist-info/RECORD +0 -22
- {Anchor_annotator-0.8.1.dist-info → anchor_annotator-0.9.0.dist-info/licenses}/LICENSE +0 -0
- {Anchor_annotator-0.8.1.dist-info → anchor_annotator-0.9.0.dist-info}/top_level.txt +0 -0
anchor/widgets.py
CHANGED
@@ -27,6 +27,7 @@ from PySide6 import QtCore, QtGui, QtMultimedia, QtSvgWidgets, QtWidgets
|
|
27
27
|
import anchor.resources_rc # noqa
|
28
28
|
from anchor.models import (
|
29
29
|
AcousticModelTableModel,
|
30
|
+
AlignmentAnalysisModel,
|
30
31
|
CorpusModel,
|
31
32
|
CorpusSelectionModel,
|
32
33
|
CorpusTableModel,
|
@@ -57,6 +58,13 @@ outside_column_minimum = 250
|
|
57
58
|
logger = logging.getLogger("anchor")
|
58
59
|
|
59
60
|
|
61
|
+
class ScrollableMenuStyle(QtWidgets.QProxyStyle):
|
62
|
+
def styleHint(self, hint, option=None, widget=None, returnData=None):
|
63
|
+
if hint == QtWidgets.QStyle.StyleHint.SH_Menu_Scrollable:
|
64
|
+
return 0
|
65
|
+
return super().styleHint(hint, option, widget, returnData)
|
66
|
+
|
67
|
+
|
60
68
|
class ErrorButtonBox(QtWidgets.QDialogButtonBox):
|
61
69
|
def __init__(self, *args, **kwargs):
|
62
70
|
super().__init__(*args, **kwargs)
|
@@ -500,10 +508,10 @@ class CompleterLineEdit(QtWidgets.QWidget):
|
|
500
508
|
|
501
509
|
def update_completions(self, completions: dict[str, int]) -> None:
|
502
510
|
self.completions = completions
|
503
|
-
model = QtCore.QStringListModel(
|
511
|
+
model = QtCore.QStringListModel(sorted(self.completions.keys()))
|
504
512
|
completer = QtWidgets.QCompleter(self)
|
505
|
-
completer.setCaseSensitivity(QtCore.Qt.CaseSensitivity.
|
506
|
-
completer.setModelSorting(QtWidgets.QCompleter.ModelSorting.
|
513
|
+
completer.setCaseSensitivity(QtCore.Qt.CaseSensitivity.CaseSensitive)
|
514
|
+
completer.setModelSorting(QtWidgets.QCompleter.ModelSorting.CaseSensitivelySortedModel)
|
507
515
|
completer.setCompletionMode(QtWidgets.QCompleter.CompletionMode.PopupCompletion)
|
508
516
|
completer.popup().setUniformItemSizes(True)
|
509
517
|
completer.popup().setLayoutMode(QtWidgets.QListView.LayoutMode.Batched)
|
@@ -513,6 +521,15 @@ class CompleterLineEdit(QtWidgets.QWidget):
|
|
513
521
|
# self.line_edit.textChanged.connect(completer.setCompletionPrefix)
|
514
522
|
|
515
523
|
|
524
|
+
class WordCompleterLineEdit(CompleterLineEdit):
|
525
|
+
def current_text(self):
|
526
|
+
if self.line_edit.text():
|
527
|
+
if self.line_edit.text() in self.completions:
|
528
|
+
return self.completions[self.line_edit.text()]
|
529
|
+
return self.line_edit.text()
|
530
|
+
return None
|
531
|
+
|
532
|
+
|
516
533
|
class ClearableDropDown(QtWidgets.QWidget):
|
517
534
|
def __init__(self, *args):
|
518
535
|
super(ClearableDropDown, self).__init__(*args)
|
@@ -679,7 +696,7 @@ class UtteranceListWidget(QtWidgets.QWidget): # pragma: no cover
|
|
679
696
|
|
680
697
|
layout.addWidget(self.table_widget)
|
681
698
|
self.pagination_toolbar = PaginationWidget()
|
682
|
-
self.pagination_toolbar.pageRequested.connect(self.table_widget.scrollToTop
|
699
|
+
self.pagination_toolbar.pageRequested.connect(self.table_widget.scrollToTop)
|
683
700
|
layout.addWidget(self.pagination_toolbar)
|
684
701
|
self.setLayout(layout)
|
685
702
|
self.dictionary = None
|
@@ -1391,7 +1408,14 @@ class HeaderView(QtWidgets.QHeaderView):
|
|
1391
1408
|
|
1392
1409
|
def generate_context_menu(self, location):
|
1393
1410
|
menu = QtWidgets.QMenu()
|
1411
|
+
menu.addSeparator()
|
1394
1412
|
m: CorpusModel = self.model()
|
1413
|
+
section_index = self.logicalIndexAt(location)
|
1414
|
+
a = QtGui.QAction("Filter Nulls", self)
|
1415
|
+
a.setCheckable(True)
|
1416
|
+
a.setChecked(m.filter_nulls[section_index])
|
1417
|
+
a.toggled.connect(lambda x, y=section_index: m.update_filter_nulls(x, y))
|
1418
|
+
menu.addAction(a)
|
1395
1419
|
for i in range(m.columnCount()):
|
1396
1420
|
column_name = m.headerData(
|
1397
1421
|
i,
|
@@ -2260,7 +2284,7 @@ class SpeakerTableView(AnchorTableView):
|
|
2260
2284
|
self.speaker_model: SpeakerModel = None
|
2261
2285
|
self.view_delegate = ButtonDelegate("edit-find", self)
|
2262
2286
|
self.edit_delegate = EditableDelegate(self)
|
2263
|
-
self.speaker_delegate =
|
2287
|
+
self.speaker_delegate = UtteranceCountDelegate(self)
|
2264
2288
|
self.setItemDelegateForColumn(1, self.speaker_delegate)
|
2265
2289
|
self.setItemDelegateForColumn(0, self.edit_delegate)
|
2266
2290
|
self.setItemDelegateForColumn(4, self.view_delegate)
|
@@ -2495,7 +2519,7 @@ class TranscriberWidget(QtWidgets.QWidget):
|
|
2495
2519
|
self.corpus_model.languageModelChanged.connect(self.refresh)
|
2496
2520
|
|
2497
2521
|
|
2498
|
-
class
|
2522
|
+
class UtteranceCountDelegate(QtWidgets.QStyledItemDelegate):
|
2499
2523
|
def __init__(self, parent=None):
|
2500
2524
|
super().__init__(parent)
|
2501
2525
|
from anchor.main import AnchorSettings
|
@@ -2512,14 +2536,18 @@ class SpeakerViewDelegate(QtWidgets.QStyledItemDelegate):
|
|
2512
2536
|
index: typing.Union[QtCore.QModelIndex, QtCore.QPersistentModelIndex],
|
2513
2537
|
) -> None:
|
2514
2538
|
super().paint(painter, option, index)
|
2539
|
+
m = index.model()
|
2540
|
+
if not m.data(index, QtCore.Qt.ItemDataRole.DisplayRole):
|
2541
|
+
return
|
2515
2542
|
painter.save()
|
2516
2543
|
|
2517
2544
|
r = option.rect
|
2518
|
-
|
2519
|
-
|
2545
|
+
size = int(self.settings.icon_size / 2)
|
2546
|
+
half_size = int(size / 2)
|
2547
|
+
x = r.left() + r.width() - size
|
2520
2548
|
y = r.top() + (r.height() / 2) - half_size
|
2521
2549
|
options = QtWidgets.QStyleOptionViewItem(option)
|
2522
|
-
options.rect = QtCore.QRect(x, y,
|
2550
|
+
options.rect = QtCore.QRect(x, y, size, size)
|
2523
2551
|
self.initStyleOption(options, index)
|
2524
2552
|
icon = QtGui.QIcon.fromTheme("folder-open")
|
2525
2553
|
icon.paint(painter, options.rect, QtCore.Qt.AlignmentFlag.AlignCenter)
|
@@ -2527,6 +2555,42 @@ class SpeakerViewDelegate(QtWidgets.QStyledItemDelegate):
|
|
2527
2555
|
painter.restore()
|
2528
2556
|
|
2529
2557
|
|
2558
|
+
class SpeakerCycleDelegate(QtWidgets.QStyledItemDelegate):
|
2559
|
+
def __init__(self, parent=None):
|
2560
|
+
super().__init__(parent)
|
2561
|
+
from anchor.main import AnchorSettings
|
2562
|
+
|
2563
|
+
self.settings = AnchorSettings()
|
2564
|
+
|
2565
|
+
def refresh_settings(self):
|
2566
|
+
self.settings.sync()
|
2567
|
+
|
2568
|
+
def paint(
|
2569
|
+
self,
|
2570
|
+
painter: QtGui.QPainter,
|
2571
|
+
option: QtWidgets.QStyleOptionViewItem,
|
2572
|
+
index: typing.Union[QtCore.QModelIndex, QtCore.QPersistentModelIndex],
|
2573
|
+
) -> None:
|
2574
|
+
super().paint(painter, option, index)
|
2575
|
+
|
2576
|
+
m: DiarizationModel = index.model()
|
2577
|
+
if hasattr(m, "can_cycle") and not m.can_cycle(index):
|
2578
|
+
return
|
2579
|
+
painter.save()
|
2580
|
+
r = option.rect
|
2581
|
+
size = int(self.settings.icon_size / 2)
|
2582
|
+
half_size = int(size / 2)
|
2583
|
+
x = r.left() + r.width() - size
|
2584
|
+
y = r.top() + (r.height() / 2) - half_size
|
2585
|
+
options = QtWidgets.QStyleOptionViewItem(option)
|
2586
|
+
options.rect = QtCore.QRect(x, y, size, size)
|
2587
|
+
self.initStyleOption(options, index)
|
2588
|
+
icon = QtGui.QIcon.fromTheme("sync-synchronizing")
|
2589
|
+
icon.paint(painter, options.rect, QtCore.Qt.AlignmentFlag.AlignCenter)
|
2590
|
+
|
2591
|
+
painter.restore()
|
2592
|
+
|
2593
|
+
|
2530
2594
|
class ButtonDelegate(QtWidgets.QStyledItemDelegate):
|
2531
2595
|
def __init__(self, icon_path, parent=None):
|
2532
2596
|
super().__init__(parent)
|
@@ -2601,30 +2665,21 @@ class SpeakerClustersWidget(QtWidgets.QWidget):
|
|
2601
2665
|
self.search_requested.emit(kaldi_ivector.numpy())
|
2602
2666
|
|
2603
2667
|
def change_speaker(self):
|
2604
|
-
if
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2609
|
-
|
2610
|
-
|
2611
|
-
|
2612
|
-
|
2613
|
-
|
2614
|
-
|
2615
|
-
]
|
2616
|
-
)
|
2617
|
-
self.speaker_model.change_speakers(data, self.speaker_model.current_speakers[0])
|
2618
|
-
self.plot_widget.updated_indices = set()
|
2619
|
-
self.plot_widget.selected_indices = set()
|
2620
|
-
else:
|
2621
|
-
if not self.plot_widget.selected_indices:
|
2622
|
-
return
|
2623
|
-
indices = np.array(list(self.plot_widget.selected_indices))
|
2624
|
-
utterance_ids = self.speaker_model.utterance_ids[indices].tolist()
|
2625
|
-
self.speaker_model.change_speaker(
|
2626
|
-
utterance_ids, self.speaker_model.current_speakers[0], 0
|
2668
|
+
if not self.plot_widget.updated_indices:
|
2669
|
+
return
|
2670
|
+
data = []
|
2671
|
+
for index in self.plot_widget.updated_indices:
|
2672
|
+
u_id = int(self.speaker_model.utterance_ids[index])
|
2673
|
+
data.append(
|
2674
|
+
[
|
2675
|
+
u_id,
|
2676
|
+
self.speaker_model.utt2spk[u_id],
|
2677
|
+
int(self.speaker_model.cluster_labels[index]),
|
2678
|
+
]
|
2627
2679
|
)
|
2680
|
+
self.speaker_model.change_speakers(data, self.speaker_model.current_speakers[0])
|
2681
|
+
self.plot_widget.updated_indices = set()
|
2682
|
+
self.plot_widget.selected_indices = set()
|
2628
2683
|
|
2629
2684
|
def set_models(
|
2630
2685
|
self,
|
@@ -2648,11 +2703,13 @@ class DiarizationTable(AnchorTableView):
|
|
2648
2703
|
def __init__(self, *args):
|
2649
2704
|
super().__init__(*args)
|
2650
2705
|
self.setSortingEnabled(False)
|
2651
|
-
self.
|
2652
|
-
self.
|
2653
|
-
self.
|
2706
|
+
self.count_delegate = UtteranceCountDelegate(self)
|
2707
|
+
self.speaker_delegate = SpeakerCycleDelegate(self)
|
2708
|
+
self.button_delegate = ButtonDelegate("format-justify-center", self)
|
2709
|
+
self.setItemDelegateForColumn(0, self.count_delegate)
|
2654
2710
|
self.setItemDelegateForColumn(1, self.speaker_delegate)
|
2655
|
-
self.setItemDelegateForColumn(
|
2711
|
+
self.setItemDelegateForColumn(2, self.count_delegate)
|
2712
|
+
self.setItemDelegateForColumn(4, self.count_delegate)
|
2656
2713
|
self.setItemDelegateForColumn(6, self.button_delegate)
|
2657
2714
|
self.setItemDelegateForColumn(7, self.button_delegate)
|
2658
2715
|
self.doubleClicked.connect(self.search_utterance)
|
@@ -2698,8 +2755,11 @@ class DiarizationTable(AnchorTableView):
|
|
2698
2755
|
self.diarization_model.merge_speakers(index.row())
|
2699
2756
|
|
2700
2757
|
def search_utterance(self, index: QtCore.QModelIndex):
|
2701
|
-
if not index.isValid() or index.column() not in {0, 1, 3}:
|
2758
|
+
if not index.isValid() or index.column() not in {0, 1, 2, 3, 4}:
|
2702
2759
|
return
|
2760
|
+
if index.column() == 1:
|
2761
|
+
row = index.row()
|
2762
|
+
self.diarization_model.change_suggested_speaker(row)
|
2703
2763
|
if index.column() == 0:
|
2704
2764
|
row = index.row()
|
2705
2765
|
utterance_id = self.diarization_model.utterance_ids[row]
|
@@ -2718,8 +2778,12 @@ class DiarizationTable(AnchorTableView):
|
|
2718
2778
|
self.selection_model.clearSelection()
|
2719
2779
|
return
|
2720
2780
|
else:
|
2721
|
-
if index.column()
|
2781
|
+
if index.column() in {1, 2}:
|
2722
2782
|
speaker_id = self.diarization_model.suggested_indices[index.row()]
|
2783
|
+
if isinstance(speaker_id, list):
|
2784
|
+
speaker_id = speaker_id[
|
2785
|
+
self.diarization_model.selected_speaker_indices.get(index.row(), 0)
|
2786
|
+
]
|
2723
2787
|
else:
|
2724
2788
|
speaker_id = self.diarization_model.speaker_indices[index.row()]
|
2725
2789
|
with self.diarization_model.corpus_model.corpus.session() as session:
|
@@ -2749,6 +2813,7 @@ class DiarizationTable(AnchorTableView):
|
|
2749
2813
|
utterance_id,
|
2750
2814
|
speaker_id,
|
2751
2815
|
force_update=True,
|
2816
|
+
single_utterance=False,
|
2752
2817
|
)
|
2753
2818
|
|
2754
2819
|
|
@@ -2792,6 +2857,178 @@ class ThresholdWidget(QtWidgets.QLineEdit):
|
|
2792
2857
|
self.setText(f"{val:.4f}")
|
2793
2858
|
|
2794
2859
|
|
2860
|
+
class AlignmentAnalysisTable(AnchorTableView):
|
2861
|
+
def __init__(self, *args):
|
2862
|
+
super().__init__(*args)
|
2863
|
+
self.alignment_analysis_model: typing.Optional[AlignmentAnalysisModel] = None
|
2864
|
+
self.selection_model: typing.Optional[FileSelectionModel] = None
|
2865
|
+
self.clicked.connect(self.search_utterance)
|
2866
|
+
|
2867
|
+
def set_models(self, model: AlignmentAnalysisModel, selection_model: FileSelectionModel):
|
2868
|
+
self.alignment_analysis_model = model
|
2869
|
+
self.selection_model = selection_model
|
2870
|
+
self.setModel(model)
|
2871
|
+
self.refresh_settings()
|
2872
|
+
|
2873
|
+
def search_utterance(self, index: QtCore.QModelIndex):
|
2874
|
+
if not index.isValid():
|
2875
|
+
return
|
2876
|
+
row = index.row()
|
2877
|
+
utterance_id = self.alignment_analysis_model.utterance_ids[row]
|
2878
|
+
if utterance_id is None:
|
2879
|
+
return
|
2880
|
+
with self.alignment_analysis_model.corpus_model.corpus.session() as session:
|
2881
|
+
try:
|
2882
|
+
file_id, begin, end, speaker_id = (
|
2883
|
+
session.query(
|
2884
|
+
Utterance.file_id, Utterance.begin, Utterance.end, Utterance.speaker_id
|
2885
|
+
)
|
2886
|
+
.filter(Utterance.id == utterance_id)
|
2887
|
+
.first()
|
2888
|
+
)
|
2889
|
+
except TypeError:
|
2890
|
+
self.selection_model.clearSelection()
|
2891
|
+
return
|
2892
|
+
word_index = self.alignment_analysis_model.createIndex(row, 5)
|
2893
|
+
word = self.alignment_analysis_model.data(word_index)
|
2894
|
+
self.selection_model.set_search_term(word)
|
2895
|
+
self.selection_model.set_current_file(
|
2896
|
+
file_id,
|
2897
|
+
begin,
|
2898
|
+
end,
|
2899
|
+
utterance_id,
|
2900
|
+
speaker_id,
|
2901
|
+
force_update=True,
|
2902
|
+
single_utterance=False,
|
2903
|
+
)
|
2904
|
+
|
2905
|
+
|
2906
|
+
class AlignmentAnalysisWidget(QtWidgets.QWidget):
|
2907
|
+
def __init__(self, *args, **kwargs):
|
2908
|
+
super().__init__(*args, **kwargs)
|
2909
|
+
self.settings = AnchorSettings()
|
2910
|
+
form_layout = QtWidgets.QFormLayout()
|
2911
|
+
form_widget = QtWidgets.QWidget()
|
2912
|
+
layout = QtWidgets.QVBoxLayout()
|
2913
|
+
self.greater_than_edit = ThresholdWidget(self)
|
2914
|
+
self.greater_than_edit.returnPressed.connect(self.search)
|
2915
|
+
self.less_than_edit = ThresholdWidget(self)
|
2916
|
+
self.less_than_edit.returnPressed.connect(self.search)
|
2917
|
+
self.word_check = QtWidgets.QCheckBox()
|
2918
|
+
self.search_box = SearchBox(self)
|
2919
|
+
self.word_check.toggled.connect(self.switch_word_phone_mode)
|
2920
|
+
form_layout.addRow(QtWidgets.QLabel("Search based on words"), self.word_check)
|
2921
|
+
self.search_box_label = QtWidgets.QLabel("Search")
|
2922
|
+
form_layout.addRow(self.search_box_label, self.search_box)
|
2923
|
+
self.search_box.searchActivated.connect(self.search)
|
2924
|
+
self.phone_dropdown = QtWidgets.QComboBox()
|
2925
|
+
self.measure_dropdown = QtWidgets.QComboBox()
|
2926
|
+
for m in ["Duration", "Log-likelihood"]:
|
2927
|
+
self.measure_dropdown.addItem(m)
|
2928
|
+
self.phone_dropdown_label = QtWidgets.QLabel("Phone")
|
2929
|
+
form_layout.addRow(self.phone_dropdown_label, self.phone_dropdown)
|
2930
|
+
form_layout.addRow(QtWidgets.QLabel("Measure"), self.measure_dropdown)
|
2931
|
+
form_layout.addRow(QtWidgets.QLabel("Less than"), self.less_than_edit)
|
2932
|
+
form_layout.addRow(QtWidgets.QLabel("Greater than"), self.greater_than_edit)
|
2933
|
+
self.exclude_manual_check = QtWidgets.QCheckBox()
|
2934
|
+
self.relative_duration_check = QtWidgets.QCheckBox()
|
2935
|
+
form_layout.addRow(
|
2936
|
+
QtWidgets.QLabel("Exclude manually aligned utterances"), self.exclude_manual_check
|
2937
|
+
)
|
2938
|
+
form_layout.addRow(QtWidgets.QLabel("Relative duration"), self.relative_duration_check)
|
2939
|
+
|
2940
|
+
self.clear_action = QtGui.QAction("Reset")
|
2941
|
+
self.search_action = QtGui.QAction("Search")
|
2942
|
+
self.search_action.triggered.connect(self.search)
|
2943
|
+
self.clear_action.triggered.connect(self.clear_fields)
|
2944
|
+
self.toolbar = QtWidgets.QToolBar()
|
2945
|
+
self.toolbar.addAction(self.search_action)
|
2946
|
+
self.toolbar.addSeparator()
|
2947
|
+
self.toolbar.addAction(self.clear_action)
|
2948
|
+
self.speaker_dropdown = CompleterLineEdit(self)
|
2949
|
+
self.speaker_dropdown.line_edit.setPlaceholderText("Filter by speaker")
|
2950
|
+
self.speaker_dropdown.line_edit.returnPressed.connect(self.search)
|
2951
|
+
|
2952
|
+
form_layout.addRow("Speaker", self.speaker_dropdown)
|
2953
|
+
form_widget.setLayout(form_layout)
|
2954
|
+
layout.addWidget(form_widget)
|
2955
|
+
layout.addWidget(self.toolbar)
|
2956
|
+
self.table = AlignmentAnalysisTable(self)
|
2957
|
+
layout.addWidget(self.table)
|
2958
|
+
self.alignment_analysis_model: Optional[AlignmentAnalysisModel] = None
|
2959
|
+
self.current_page = 0
|
2960
|
+
self.num_pages = 0
|
2961
|
+
self.pagination_toolbar = PaginationWidget()
|
2962
|
+
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop)
|
2963
|
+
layout.addWidget(self.pagination_toolbar)
|
2964
|
+
self.setLayout(layout)
|
2965
|
+
|
2966
|
+
def switch_word_phone_mode(self, word_mode):
|
2967
|
+
if word_mode:
|
2968
|
+
self.phone_dropdown_label.setVisible(False)
|
2969
|
+
self.phone_dropdown.setVisible(False)
|
2970
|
+
else:
|
2971
|
+
self.phone_dropdown_label.setVisible(True)
|
2972
|
+
self.phone_dropdown.setVisible(True)
|
2973
|
+
|
2974
|
+
def set_models(self, model: AlignmentAnalysisModel, selection_model: FileSelectionModel):
|
2975
|
+
self.alignment_analysis_model = model
|
2976
|
+
self.alignment_analysis_model.corpus_model.corpusLoaded.connect(self.refresh)
|
2977
|
+
self.table.set_models(model, selection_model)
|
2978
|
+
self.alignment_analysis_model.resultCountChanged.connect(
|
2979
|
+
self.pagination_toolbar.update_result_count
|
2980
|
+
)
|
2981
|
+
self.pagination_toolbar.offsetRequested.connect(self.alignment_analysis_model.set_offset)
|
2982
|
+
self.pagination_toolbar.set_limit(self.alignment_analysis_model.limit)
|
2983
|
+
self.alignment_analysis_model.corpus_model.speakersRefreshed.connect(
|
2984
|
+
self.speaker_dropdown.update_completions
|
2985
|
+
)
|
2986
|
+
|
2987
|
+
def refresh(self):
|
2988
|
+
if self.alignment_analysis_model.corpus_model.corpus is not None:
|
2989
|
+
validate_enabled = self.alignment_analysis_model.corpus_model.has_alignments
|
2990
|
+
self.phone_dropdown.clear()
|
2991
|
+
self.phone_dropdown.addItem("")
|
2992
|
+
for p in self.alignment_analysis_model.corpus_model.phones.keys():
|
2993
|
+
self.phone_dropdown.addItem(p)
|
2994
|
+
else:
|
2995
|
+
validate_enabled = False
|
2996
|
+
self.search_action.setEnabled(validate_enabled)
|
2997
|
+
self.clear_action.setEnabled(validate_enabled)
|
2998
|
+
self.exclude_manual_check.setEnabled(validate_enabled)
|
2999
|
+
self.phone_dropdown.setEnabled(validate_enabled)
|
3000
|
+
self.measure_dropdown.setEnabled(validate_enabled)
|
3001
|
+
self.less_than_edit.setEnabled(validate_enabled)
|
3002
|
+
self.greater_than_edit.setEnabled(validate_enabled)
|
3003
|
+
self.speaker_dropdown.setEnabled(validate_enabled)
|
3004
|
+
|
3005
|
+
def search(self):
|
3006
|
+
self.table.selectionModel().clearSelection()
|
3007
|
+
self.alignment_analysis_model.set_speaker_filter(self.speaker_dropdown.current_text())
|
3008
|
+
self.alignment_analysis_model.set_word_mode(self.word_check.isChecked())
|
3009
|
+
self.alignment_analysis_model.set_relative_duration(
|
3010
|
+
self.relative_duration_check.isChecked()
|
3011
|
+
)
|
3012
|
+
if self.word_check.isChecked():
|
3013
|
+
self.alignment_analysis_model.set_phone_filter(None)
|
3014
|
+
else:
|
3015
|
+
self.alignment_analysis_model.set_phone_filter(self.phone_dropdown.currentText())
|
3016
|
+
self.alignment_analysis_model.set_word_filter(self.search_box.query())
|
3017
|
+
self.alignment_analysis_model.set_less_than(self.less_than_edit.value())
|
3018
|
+
self.alignment_analysis_model.set_greater_than(self.greater_than_edit.value())
|
3019
|
+
self.alignment_analysis_model.set_measure(self.measure_dropdown.currentText())
|
3020
|
+
self.alignment_analysis_model.set_exclude_manual(self.exclude_manual_check.isChecked())
|
3021
|
+
self.pagination_toolbar.first_page()
|
3022
|
+
|
3023
|
+
def clear_fields(self):
|
3024
|
+
self.speaker_dropdown.line_edit.clear()
|
3025
|
+
self.phone_dropdown.setCurrentIndex(0)
|
3026
|
+
self.measure_dropdown.setCurrentIndex(0)
|
3027
|
+
self.less_than_edit.clear()
|
3028
|
+
self.greater_than_edit.clear()
|
3029
|
+
self.exclude_manual_check.setChecked(False)
|
3030
|
+
|
3031
|
+
|
2795
3032
|
class DiarizationWidget(QtWidgets.QWidget):
|
2796
3033
|
def __init__(self, *args, **kwargs):
|
2797
3034
|
super().__init__(*args, **kwargs)
|
@@ -2858,7 +3095,7 @@ class DiarizationWidget(QtWidgets.QWidget):
|
|
2858
3095
|
self.current_page = 0
|
2859
3096
|
self.num_pages = 0
|
2860
3097
|
self.pagination_toolbar = PaginationWidget()
|
2861
|
-
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop
|
3098
|
+
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop)
|
2862
3099
|
layout.addWidget(self.pagination_toolbar)
|
2863
3100
|
self.setLayout(layout)
|
2864
3101
|
self.table.referenceUtteranceSelected.connect(self.update_reference_utterance)
|
@@ -2932,7 +3169,7 @@ class DiarizationWidget(QtWidgets.QWidget):
|
|
2932
3169
|
self.threshold_edit.setEnabled(False)
|
2933
3170
|
self.refresh_ivectors_action.setEnabled(validate_enabled)
|
2934
3171
|
|
2935
|
-
def set_models(self, model: DiarizationModel, selection_model:
|
3172
|
+
def set_models(self, model: DiarizationModel, selection_model: FileSelectionModel):
|
2936
3173
|
self.diarization_model = model
|
2937
3174
|
self.diarization_model.corpus_model.corpusLoaded.connect(self.refresh)
|
2938
3175
|
self.table.set_models(model, selection_model)
|
@@ -3049,7 +3286,7 @@ class OovWidget(QtWidgets.QWidget):
|
|
3049
3286
|
dict_layout.addWidget(self.toolbar)
|
3050
3287
|
dict_layout.addWidget(self.table)
|
3051
3288
|
self.pagination_toolbar = PaginationWidget()
|
3052
|
-
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop
|
3289
|
+
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop)
|
3053
3290
|
dict_layout.addWidget(self.pagination_toolbar)
|
3054
3291
|
|
3055
3292
|
self.setLayout(dict_layout)
|
@@ -3109,7 +3346,7 @@ class DictionaryWidget(QtWidgets.QWidget):
|
|
3109
3346
|
dict_layout.addWidget(self.toolbar)
|
3110
3347
|
dict_layout.addWidget(self.table)
|
3111
3348
|
self.pagination_toolbar = PaginationWidget()
|
3112
|
-
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop
|
3349
|
+
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop)
|
3113
3350
|
dict_layout.addWidget(self.pagination_toolbar)
|
3114
3351
|
|
3115
3352
|
self.setLayout(dict_layout)
|
@@ -3190,7 +3427,7 @@ class SpeakerQueryDialog(QtWidgets.QDialog):
|
|
3190
3427
|
self.setWindowIcon(QtGui.QIcon(":anchor-yellow.svg"))
|
3191
3428
|
self.speaker_dropdown = CompleterLineEdit(self, corpus_model=corpus_model)
|
3192
3429
|
self.speaker_dropdown.line_edit.setPlaceholderText("Filter by speaker")
|
3193
|
-
self.speaker_dropdown.line_edit.returnPressed.connect(self.accept
|
3430
|
+
self.speaker_dropdown.line_edit.returnPressed.connect(self.accept)
|
3194
3431
|
self.speaker_dropdown.update_completions(corpus_model.speakers)
|
3195
3432
|
layout.addWidget(self.speaker_dropdown)
|
3196
3433
|
self.button_box = QtWidgets.QDialogButtonBox(
|
@@ -3207,6 +3444,33 @@ class SpeakerQueryDialog(QtWidgets.QDialog):
|
|
3207
3444
|
# self.speaker_dropdown.setStyleSheet(self.settings.combo_box_style_sheet)
|
3208
3445
|
|
3209
3446
|
|
3447
|
+
class WordQueryDialog(QtWidgets.QDialog):
|
3448
|
+
def __init__(self, corpus_model: CorpusModel, *args, **kwargs):
|
3449
|
+
super().__init__(*args, **kwargs)
|
3450
|
+
self.settings = AnchorSettings()
|
3451
|
+
self.setAttribute(QtCore.Qt.WidgetAttribute.WA_StyledBackground, True)
|
3452
|
+
layout = QtWidgets.QVBoxLayout()
|
3453
|
+
self.setWindowTitle("Change word")
|
3454
|
+
self.setWindowIcon(QtGui.QIcon(":anchor-yellow.svg"))
|
3455
|
+
self.word_dropdown = WordCompleterLineEdit(self, corpus_model=corpus_model)
|
3456
|
+
self.word_dropdown.line_edit.setPlaceholderText("")
|
3457
|
+
self.word_dropdown.line_edit.returnPressed.connect(self.accept)
|
3458
|
+
self.word_dropdown.update_completions(corpus_model.words)
|
3459
|
+
layout.addWidget(self.word_dropdown)
|
3460
|
+
self.button_box = QtWidgets.QDialogButtonBox(
|
3461
|
+
QtWidgets.QDialogButtonBox.StandardButton.Ok
|
3462
|
+
| QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
3463
|
+
)
|
3464
|
+
self.button_box.accepted.connect(self.accept)
|
3465
|
+
self.button_box.rejected.connect(self.reject)
|
3466
|
+
layout.addWidget(self.button_box)
|
3467
|
+
self.setLayout(layout)
|
3468
|
+
# self.speaker_dropdown.setFont(font)
|
3469
|
+
# self.button_box.setFont(font)
|
3470
|
+
# self.setStyleSheet(self.settings.style_sheet)
|
3471
|
+
# self.speaker_dropdown.setStyleSheet(self.settings.combo_box_style_sheet)
|
3472
|
+
|
3473
|
+
|
3210
3474
|
class ConfirmationDialog(QtWidgets.QDialog):
|
3211
3475
|
def __init__(self, title: str, description: str, *args, **kwargs):
|
3212
3476
|
super().__init__(*args, **kwargs)
|
@@ -3254,7 +3518,7 @@ class SpeakerWidget(QtWidgets.QWidget):
|
|
3254
3518
|
self.current_page = 0
|
3255
3519
|
self.num_pages = 0
|
3256
3520
|
self.pagination_toolbar = PaginationWidget()
|
3257
|
-
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop
|
3521
|
+
self.pagination_toolbar.pageRequested.connect(self.table.scrollToTop)
|
3258
3522
|
speaker_layout.addWidget(self.pagination_toolbar)
|
3259
3523
|
self.tool_bar_wrapper = QtWidgets.QVBoxLayout()
|
3260
3524
|
self.tool_bar = QtWidgets.QToolBar()
|