Spaces:
Runtime error
Runtime error
Zeimoto
commited on
Commit
•
06aa1cd
1
Parent(s):
7b86f35
print elapsedtime
Browse files- app.py +10 -5
- nameder.py +1 -0
- resources.py +5 -3
- speech2text.py +1 -1
app.py
CHANGED
@@ -25,19 +25,24 @@ def main ():
|
|
25 |
audit_elapsedtime(function="Rendering UI", start=start_render)
|
26 |
|
27 |
if wav_audio_data is not None:
|
|
|
|
|
28 |
s2t = init_model_trans()
|
29 |
-
|
|
|
30 |
print("Loading data...")
|
31 |
-
start_loading = set_start()
|
32 |
#st.audio(wav_audio_data, format='audio/wav')
|
33 |
original = transcribe(wav_audio_data, s2t)
|
34 |
st.write(f"Transcription: {original}")
|
35 |
translation = translate(original)
|
36 |
st.write(f"Translation: {translation}")
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
print("IN __name__")
|
|
|
25 |
audit_elapsedtime(function="Rendering UI", start=start_render)
|
26 |
|
27 |
if wav_audio_data is not None:
|
28 |
+
start_loading = set_start()
|
29 |
+
|
30 |
s2t = init_model_trans()
|
31 |
+
ner = init_model_ner()
|
32 |
+
|
33 |
print("Loading data...")
|
|
|
34 |
#st.audio(wav_audio_data, format='audio/wav')
|
35 |
original = transcribe(wav_audio_data, s2t)
|
36 |
st.write(f"Transcription: {original}")
|
37 |
translation = translate(original)
|
38 |
st.write(f"Translation: {translation}")
|
39 |
|
40 |
+
if translation is not None and ner is not None:
|
41 |
+
st.write('Entities: ', get_entity_labels(model=ner, text=translation))
|
42 |
+
loading_elapsedtime = audit_elapsedtime(function="Loading data", start=start_loading)
|
43 |
+
|
44 |
+
st.write(f"Total elapsed time: {loading_elapsedtime} secs")
|
45 |
+
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
print("IN __name__")
|
nameder.py
CHANGED
@@ -20,4 +20,5 @@ def get_entity_labels(model: GLiNER, text: str): #-> Lead_labels:
|
|
20 |
|
21 |
for entity in entities:
|
22 |
print(entity["text"], "=>", entity["label"])
|
|
|
23 |
return entities
|
|
|
20 |
|
21 |
for entity in entities:
|
22 |
print(entity["text"], "=>", entity["label"])
|
23 |
+
|
24 |
return entities
|
resources.py
CHANGED
@@ -23,8 +23,10 @@ entity_labels = [
|
|
23 |
def set_start () -> time:
|
24 |
return time.time()
|
25 |
|
26 |
-
def audit_elapsedtime(function: str, start: time)
|
27 |
end = time.time()
|
|
|
28 |
print("------------------")
|
29 |
-
print(f"[{function}] Elapsed time: {
|
30 |
-
print("------------------")
|
|
|
|
23 |
def set_start () -> time:
|
24 |
return time.time()
|
25 |
|
26 |
+
def audit_elapsedtime(function: str, start: time):
|
27 |
end = time.time()
|
28 |
+
elapsedtime = end-start
|
29 |
print("------------------")
|
30 |
+
print(f"[{function}] Elapsed time: {elapsedtime}")
|
31 |
+
print("------------------")
|
32 |
+
return elapsedtime
|
speech2text.py
CHANGED
@@ -33,7 +33,7 @@ def init_model_trans ():
|
|
33 |
device=device,
|
34 |
)
|
35 |
print(f'Init model successful')
|
36 |
-
|
37 |
return pipe
|
38 |
|
39 |
def transcribe (audio_sample: bytes, pipe) -> str:
|
|
|
33 |
device=device,
|
34 |
)
|
35 |
print(f'Init model successful')
|
36 |
+
audit_elapsedtime(function="Init transc model", start=start)
|
37 |
return pipe
|
38 |
|
39 |
def transcribe (audio_sample: bytes, pipe) -> str:
|