6060}
6161comparison_mode = False
6262
63+
6364# parse table filter queries
6465def split_filter_part (filter_part ):
6566 for op in filter_operators :
@@ -83,7 +84,8 @@ def split_filter_part(filter_part):
8384def parse_args ():
8485 parser = argparse .ArgumentParser (description = 'Speech Data Explorer' )
8586 parser .add_argument (
86- 'manifest' , help = 'path to JSON manifest file' ,
87+ 'manifest' ,
88+ help = 'path to JSON manifest file' ,
8789 )
8890 parser .add_argument ('--vocab' , help = 'optional vocabulary to highlight OOV words' )
8991 parser .add_argument ('--port' , default = '8050' , help = 'serving port for establishing connection' )
@@ -219,7 +221,9 @@ def load_data(
219221 match_vocab_2 = defaultdict (lambda : 0 )
220222
221223 def append_data (
222- data_filename , estimate_audio , field_name = 'pred_text' ,
224+ data_filename ,
225+ estimate_audio ,
226+ field_name = 'pred_text' ,
223227 ):
224228 data = []
225229 wer_dist = 0.0
@@ -703,7 +707,9 @@ def absolute_audio_filepath(audio_filepath, audio_base_path):
703707 class_name = 'border-end' ,
704708 ),
705709 dbc .Col (
706- html .Div ('Word Match Rate (WMR), %' , className = 'text-secondary' ), width = 3 , class_name = 'border-end' ,
710+ html .Div ('Word Match Rate (WMR), %' , className = 'text-secondary' ),
711+ width = 3 ,
712+ class_name = 'border-end' ,
707713 ),
708714 dbc .Col (html .Div ('Mean Word Accuracy, %' , className = 'text-secondary' ), width = 3 ),
709715 ],
@@ -713,7 +719,9 @@ def absolute_audio_filepath(audio_filepath, audio_base_path):
713719 [
714720 dbc .Col (
715721 html .H5 (
716- '{:.2f}' .format (wer ), className = 'text-center p-1' , style = {'color' : 'green' , 'opacity' : 0.7 },
722+ '{:.2f}' .format (wer ),
723+ className = 'text-center p-1' ,
724+ style = {'color' : 'green' , 'opacity' : 0.7 },
717725 ),
718726 width = 3 ,
719727 class_name = 'border-end' ,
@@ -727,14 +735,18 @@ def absolute_audio_filepath(audio_filepath, audio_base_path):
727735 ),
728736 dbc .Col (
729737 html .H5 (
730- '{:.2f}' .format (wmr ), className = 'text-center p-1' , style = {'color' : 'green' , 'opacity' : 0.7 },
738+ '{:.2f}' .format (wmr ),
739+ className = 'text-center p-1' ,
740+ style = {'color' : 'green' , 'opacity' : 0.7 },
731741 ),
732742 width = 3 ,
733743 class_name = 'border-end' ,
734744 ),
735745 dbc .Col (
736746 html .H5 (
737- '{:.2f}' .format (mwa ), className = 'text-center p-1' , style = {'color' : 'green' , 'opacity' : 0.7 },
747+ '{:.2f}' .format (mwa ),
748+ className = 'text-center p-1' ,
749+ style = {'color' : 'green' , 'opacity' : 0.7 },
738750 ),
739751 width = 3 ,
740752 ),
@@ -745,19 +757,30 @@ def absolute_audio_filepath(audio_filepath, audio_base_path):
745757stats_layout += [
746758 dbc .Row (dbc .Col (html .H5 (children = 'Alphabet' ), class_name = 'text-secondary' ), class_name = 'mt-3' ),
747759 dbc .Row (
748- dbc .Col (html .Div ('{}' .format (sorted (alphabet ))),), class_name = 'mt-2 bg-light font-monospace rounded border'
760+ dbc .Col (
761+ html .Div ('{}' .format (sorted (alphabet ))),
762+ ),
763+ class_name = 'mt-2 bg-light font-monospace rounded border' ,
749764 ),
750765]
751766for k in figures_hist :
752767 stats_layout += [
753768 dbc .Row (dbc .Col (html .H5 (figures_hist [k ][0 ]), class_name = 'text-secondary' ), class_name = 'mt-3' ),
754- dbc .Row (dbc .Col (dcc .Graph (id = 'duration-graph' , figure = figures_hist [k ][1 ]),),),
769+ dbc .Row (
770+ dbc .Col (
771+ dcc .Graph (id = 'duration-graph' , figure = figures_hist [k ][1 ]),
772+ ),
773+ ),
755774 ]
756775
757776if metrics_available :
758777 stats_layout += [
759778 dbc .Row (dbc .Col (html .H5 ('Word accuracy distribution' ), class_name = 'text-secondary' ), class_name = 'mt-3' ),
760- dbc .Row (dbc .Col (dcc .Graph (id = 'word-acc-graph' , figure = figure_word_acc ),),),
779+ dbc .Row (
780+ dbc .Col (
781+ dcc .Graph (id = 'word-acc-graph' , figure = figure_word_acc ),
782+ ),
783+ ),
761784 ]
762785
763786wordstable_columns = [{'name' : 'Word' , 'id' : 'word' }, {'name' : 'Count' , 'id' : 'count' }]
@@ -786,12 +809,21 @@ def absolute_audio_filepath(audio_filepath, audio_base_path):
786809 sort_by = [{'column_id' : 'word' , 'direction' : 'asc' }],
787810 style_cell = {'maxWidth' : 0 , 'textAlign' : 'left' },
788811 style_header = {'color' : 'text-primary' },
789- css = [{'selector' : '.dash-filter--case' , 'rule' : 'display: none' },],
812+ css = [
813+ {'selector' : '.dash-filter--case' , 'rule' : 'display: none' },
814+ ],
790815 ),
791816 ),
792817 class_name = 'm-2' ,
793818 ),
794- dbc .Row (dbc .Col ([html .Button ('Download Vocabulary' , id = 'btn_csv' ), dcc .Download (id = 'download-vocab-csv' ),]),),
819+ dbc .Row (
820+ dbc .Col (
821+ [
822+ html .Button ('Download Vocabulary' , id = 'btn_csv' ),
823+ dcc .Download (id = 'download-vocab-csv' ),
824+ ]
825+ ),
826+ ),
795827]
796828
797829
@@ -922,7 +954,12 @@ def update_wordstable(page_current, sort_by, filter_query):
922954 )
923955 ]
924956samples_layout += [
925- dbc .Row (dbc .Col (html .Audio (id = 'player' , controls = True ),), class_name = 'mt-3 ' ),
957+ dbc .Row (
958+ dbc .Col (
959+ html .Audio (id = 'player' , controls = True ),
960+ ),
961+ class_name = 'mt-3 ' ,
962+ ),
926963 dbc .Row (dbc .Col (dcc .Graph (id = 'signal-graph' )), class_name = 'mt-3' ),
927964]
928965
@@ -1064,7 +1101,16 @@ def draw_vocab(Ox, Oy, color, size, data, dot_spacing='no', rad=0.01):
10641101 Oy == 'accuracy_model_' + model_name_1 and Ox == 'accuracy_model_' + model_name_2
10651102 ):
10661103 fig .add_shape (
1067- type = "line" , x0 = 0 , y0 = 0 , x1 = 100 , y1 = 100 , line = dict (color = "MediumPurple" , width = 1 , dash = "dot" ,)
1104+ type = "line" ,
1105+ x0 = 0 ,
1106+ y0 = 0 ,
1107+ x1 = 100 ,
1108+ y1 = 100 ,
1109+ line = dict (
1110+ color = "MediumPurple" ,
1111+ width = 1 ,
1112+ dash = "dot" ,
1113+ ),
10681114 )
10691115
10701116 return fig
@@ -1176,7 +1222,10 @@ def display_query(query):
11761222 ),
11771223 dcc .Input (id = 'radius' , placeholder = 'Enter radius of spacing (std is 0.01)' ),
11781224 html .Hr (),
1179- dcc .Input (id = 'filter-query-input' , placeholder = 'Enter filter query' ,),
1225+ dcc .Input (
1226+ id = 'filter-query-input' ,
1227+ placeholder = 'Enter filter query' ,
1228+ ),
11801229 ],
11811230 style = {'width' : '200%' , 'display' : 'inline-block' , 'float' : 'middle' },
11821231 ),
@@ -1194,7 +1243,11 @@ def display_query(query):
11941243 html .Hr (),
11951244 html .Div (id = 'datatable-query-structure' , style = {'whitespace' : 'pre' }),
11961245 html .Hr (),
1197- dbc .Row (dbc .Col (dcc .Graph (id = 'voc_graph' ),),),
1246+ dbc .Row (
1247+ dbc .Col (
1248+ dcc .Graph (id = 'voc_graph' ),
1249+ ),
1250+ ),
11981251 html .Hr (),
11991252 ],
12001253 id = 'wrd_lvl' ,
@@ -1250,7 +1303,12 @@ def display_query(query):
12501303 {'selector' : '.column-header--hide' , 'rule' : 'display: none' },
12511304 ],
12521305 ),
1253- dbc .Row (dbc .Col (html .Audio (id = 'player-1' , controls = True ),), class_name = 'mt-3' ),
1306+ dbc .Row (
1307+ dbc .Col (
1308+ html .Audio (id = 'player-1' , controls = True ),
1309+ ),
1310+ class_name = 'mt-3' ,
1311+ ),
12541312 ]
12551313 )
12561314 ),
@@ -1280,14 +1338,22 @@ def display_query(query):
12801338 [
12811339 html .Div (
12821340 [
1283- dbc .Row (dbc .Col (dcc .Graph (id = 'utt_graph' ),),),
1341+ dbc .Row (
1342+ dbc .Col (
1343+ dcc .Graph (id = 'utt_graph' ),
1344+ ),
1345+ ),
12841346 html .Hr (),
12851347 dcc .Input (id = 'clicked_aidopath' , style = {'width' : '100%' }),
12861348 html .Hr (),
12871349 dcc .Input (id = 'my-output-1' , style = {'display' : 'none' }), # we do need this
12881350 ]
12891351 ),
1290- html .Div ([dbc .Row (dbc .Col (dcc .Graph (id = 'signal-graph-1' )), class_name = 'mt-3' ),]),
1352+ html .Div (
1353+ [
1354+ dbc .Row (dbc .Col (dcc .Graph (id = 'signal-graph-1' )), class_name = 'mt-3' ),
1355+ ]
1356+ ),
12911357 ],
12921358 id = 'down_thing' ,
12931359 style = {'display' : 'block' },
@@ -1384,15 +1450,17 @@ def show_hide_element(visibility_state):
13841450
13851451@app .callback (
13861452 [Output ('datatable-advanced-filtering-2' , 'page_current' ), Output ('my-output-1' , 'value' )],
1387- [Input ('utt_graph' , 'clickData' ),],
1453+ [
1454+ Input ('utt_graph' , 'clickData' ),
1455+ ],
13881456)
13891457def real_select_click (hoverData ):
13901458 if hoverData is not None :
13911459 path = str (hoverData ['points' ][0 ]['customdata' ][- 1 ])
13921460 for t in range (len (data_with_metrics )):
13931461 if data_with_metrics [t ]['audio_filepath' ] == path :
13941462 ind = t
1395- s = t #% 5
1463+ s = t # % 5
13961464 sel = s
13971465 pg = math .ceil (ind // 5 )
13981466 return pg , sel
@@ -1401,7 +1469,8 @@ def real_select_click(hoverData):
14011469
14021470
14031471@app .callback (
1404- [Output ('datatable-advanced-filtering-2' , 'selected_rows' )], [Input ('my-output-1' , 'value' )],
1472+ [Output ('datatable-advanced-filtering-2' , 'selected_rows' )],
1473+ [Input ('my-output-1' , 'value' )],
14051474)
14061475def real_select_click (num ):
14071476 s = num
@@ -1448,7 +1517,18 @@ def draw_table_with_metrics(met, hoverData, data_virt):
14481517 'audio_filepath' : True ,
14491518 },
14501519 ) #'numwords': True,
1451- fig .add_shape (type = "line" , x0 = 0 , y0 = 0 , x1 = 100 , y1 = 100 , line = dict (color = "Red" , width = 1 , dash = "dot" ,))
1520+ fig .add_shape (
1521+ type = "line" ,
1522+ x0 = 0 ,
1523+ y0 = 0 ,
1524+ x1 = 100 ,
1525+ y1 = 100 ,
1526+ line = dict (
1527+ color = "Red" ,
1528+ width = 1 ,
1529+ dash = "dot" ,
1530+ ),
1531+ )
14521532 fig .update_layout (clickmode = 'event+select' )
14531533 fig .update_traces (marker_size = 10 )
14541534 path = None
@@ -1542,11 +1622,14 @@ def nav_click(url):
15421622 else :
15431623 return [stats_layout , True , False , False ]
15441624
1545-
15461625else :
15471626
15481627 @app .callback (
1549- [Output ('page-content' , 'children' ), Output ('stats_link' , 'active' ), Output ('samples_link' , 'active' ),],
1628+ [
1629+ Output ('page-content' , 'children' ),
1630+ Output ('stats_link' , 'active' ),
1631+ Output ('samples_link' , 'active' ),
1632+ ],
15501633 [Input ('url' , 'pathname' )],
15511634 )
15521635 def nav_click (url ):
@@ -1577,9 +1660,16 @@ def show_item(idx, data):
15771660 return [data [idx [0 ]][k ] for k in data_with_metrics [0 ]]
15781661
15791662
1580- @app .callback (Output ('_diff' , 'srcDoc' ), [Input ('datatable' , 'selected_rows' ), Input ('datatable' , 'data' ),])
1663+ @app .callback (
1664+ Output ('_diff' , 'srcDoc' ),
1665+ [
1666+ Input ('datatable' , 'selected_rows' ),
1667+ Input ('datatable' , 'data' ),
1668+ ],
1669+ )
15811670def show_diff (
1582- idx , data ,
1671+ idx ,
1672+ data ,
15831673):
15841674 if len (idx ) == 0 :
15851675 raise PreventUpdate
@@ -1605,10 +1695,14 @@ def show_diff(
16051695
16061696@app .callback (
16071697 Output ('__diff' , 'srcDoc' ),
1608- [Input ('datatable-advanced-filtering-2' , 'selected_rows' ), Input ('datatable-advanced-filtering-2' , 'data' ),],
1698+ [
1699+ Input ('datatable-advanced-filtering-2' , 'selected_rows' ),
1700+ Input ('datatable-advanced-filtering-2' , 'data' ),
1701+ ],
16091702)
16101703def show_diff (
1611- idx , data ,
1704+ idx ,
1705+ data ,
16121706):
16131707 if len (idx ) == 0 :
16141708 raise PreventUpdate
@@ -1664,7 +1758,11 @@ def plot_signal(idx, data):
16641758 figs .add_trace (
16651759 go .Heatmap (
16661760 z = s_db ,
1667- colorscale = [[0 , 'rgb(30,62,62)' ], [0.5 , 'rgb(30,128,128)' ], [1 , 'rgb(30,255,30)' ],],
1761+ colorscale = [
1762+ [0 , 'rgb(30,62,62)' ],
1763+ [0.5 , 'rgb(30,128,128)' ],
1764+ [1 , 'rgb(30,255,30)' ],
1765+ ],
16681766 colorbar = dict (yanchor = 'middle' , lenmode = 'fraction' , y = 0.2 , len = 0.5 , ticksuffix = ' dB' ),
16691767 dx = time_stride ,
16701768 dy = fs / n_fft / 1000 ,
@@ -1720,7 +1818,11 @@ def plot_signal(idx, data):
17201818 figs .add_trace (
17211819 go .Heatmap (
17221820 z = s_db ,
1723- colorscale = [[0 , 'rgb(30,62,62)' ], [0.5 , 'rgb(30,128,128)' ], [1 , 'rgb(30,255,30)' ],],
1821+ colorscale = [
1822+ [0 , 'rgb(30,62,62)' ],
1823+ [0.5 , 'rgb(30,128,128)' ],
1824+ [1 , 'rgb(30,255,30)' ],
1825+ ],
17241826 colorbar = dict (yanchor = 'middle' , lenmode = 'fraction' , y = 0.2 , len = 0.5 , ticksuffix = ' dB' ),
17251827 dx = time_stride ,
17261828 dy = fs / n_fft / 1000 ,
@@ -1789,4 +1891,4 @@ def update_player(idx, data):
17891891
17901892
17911893if __name__ == '__main__' :
1792- app .run_server (host = '0.0.0.0' , port = args .port , debug = args .debug )
1894+ app .run (host = '0.0.0.0' , port = args .port , debug = args .debug )
0 commit comments