zeimoto commited on
Commit
8b14f83
·
verified ·
1 Parent(s): eca6624

update audit timestamps

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -10,7 +10,6 @@ from resources import Lead_Labels, entity_labels, set_start, audit_elapsedtime
10
 
11
  def main ():
12
 
13
-
14
  rec = init_model_trans()
15
  ner = init_model_ner() #async
16
 
@@ -23,9 +22,6 @@ def main ():
23
  print("Render UI")
24
  wav_audio_data = st_audiorec()
25
 
26
- if wav_audio_data is not None:
27
- print("Loading data...")
28
-
29
  if wav_audio_data is not None and rec is not None:
30
  print("Loading data...")
31
  st.audio(wav_audio_data, format='audio/wav')
@@ -36,7 +32,6 @@ def main ():
36
 
37
  def init_model_trans ():
38
  print("Initiating transcription model...")
39
- func_name = "init_model_trans"
40
  start = set_start()
41
 
42
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
@@ -64,28 +59,31 @@ def init_model_trans ():
64
  device=device,
65
  )
66
  print(f'Init model successful: {model}' )
67
- audit_elapsedtime(function="init_model_trans", start=start)
68
  return pipe
69
 
70
  def init_model_ner():
71
  print("Initiating NER model...")
72
  start = set_start()
73
  model = GLiNER.from_pretrained("urchade/gliner_multi")
74
- audit_elapsedtime(function="init_model_ner", start=start)
75
  return model
76
 
77
  def transcribe (audio_sample: bytes, pipe) -> str:
78
-
79
  # dataset = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")
80
  # sample = dataset[0]["audio"]
81
  result = pipe(audio_sample)
 
82
  print(result)
83
 
84
  st.write('trancription: ', result["text"])
85
  return result["text"]
86
 
87
  def get_entity_labels(model: GLiNER, text: str, labels: list): #-> Lead_labels:
 
88
  entities = model.predict_entities(text, labels)
 
89
 
90
  for entity in entities:
91
  print(entity["text"], "=>", entity["label"])
 
10
 
11
  def main ():
12
 
 
13
  rec = init_model_trans()
14
  ner = init_model_ner() #async
15
 
 
22
  print("Render UI")
23
  wav_audio_data = st_audiorec()
24
 
 
 
 
25
  if wav_audio_data is not None and rec is not None:
26
  print("Loading data...")
27
  st.audio(wav_audio_data, format='audio/wav')
 
32
 
33
  def init_model_trans ():
34
  print("Initiating transcription model...")
 
35
  start = set_start()
36
 
37
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
 
59
  device=device,
60
  )
61
  print(f'Init model successful: {model}' )
62
+ audit_elapsedtime(function="Initiating transcription model", start=start)
63
  return pipe
64
 
65
  def init_model_ner():
66
  print("Initiating NER model...")
67
  start = set_start()
68
  model = GLiNER.from_pretrained("urchade/gliner_multi")
69
+ audit_elapsedtime(function="Initiating NER model", start=start)
70
  return model
71
 
72
  def transcribe (audio_sample: bytes, pipe) -> str:
73
+ start = set_start()
74
  # dataset = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")
75
  # sample = dataset[0]["audio"]
76
  result = pipe(audio_sample)
77
+ audit_elapsedtime(function="Transcription", start=start)
78
  print(result)
79
 
80
  st.write('trancription: ', result["text"])
81
  return result["text"]
82
 
83
  def get_entity_labels(model: GLiNER, text: str, labels: list): #-> Lead_labels:
84
+ start = set_start()
85
  entities = model.predict_entities(text, labels)
86
+ audit_elapsedtime(function="Retreiving entity labels from text", start=start)
87
 
88
  for entity in entities:
89
  print(entity["text"], "=>", entity["label"])