Spaces:
Runtime error
Runtime error
File size: 1,829 Bytes
1726dba 065ecac 1726dba fa6f424 ecb1d96 071265e b8d16a0 bcfb814 5cc4f06 5767b04 d7e888d e25d134 7b86f35 c438acc bcfb814 7b86f35 c438acc 5cc4f06 1f8b546 06aa1cd 1f8b546 06aa1cd c438acc 7b86f35 c438acc 7b86f35 c51d817 7b86f35 5cc4f06 c51d817 06aa1cd aed550f 06aa1cd 5cc4f06 43c8625 5cc4f06 |
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 |
import streamlit as st
from st_audiorec import st_audiorec
from nameder import init_model_ner, get_entity_labels
from speech2text import init_model_trans, transcribe
from translation import translate
from resources import audit_elapsedtime, set_start
import subprocess
def main ():
print("------------------------------")
print(f"Running main")
#print(subprocess.Popen('pip freeze > requirements_hug.txt', shell=True))
# original = "Tenho uma proposta para a Caixa Geral de Depositos, para 3 consultores Outsystems, 300 euros por dia e um periodo de seis meses."
# st.write(f"Original: {original}")
# traducao = get_translation(text_to_translate=text, languageCode="pt")
# st.write(traducao)
# translation = translate(original)
# st.write(f"Translation: {translation}")
print("Rendering UI...")
start_render = set_start()
wav_audio_data = st_audiorec()
audit_elapsedtime(function="Rendering UI", start=start_render)
if wav_audio_data is not None:
start_loading = set_start()
s2t = init_model_trans()
ner = init_model_ner()
print("Loading data...")
#st.audio(wav_audio_data, format='audio/wav')
original = transcribe(wav_audio_data, s2t)
st.write(f"Transcription: {original}")
translation = translate(original)[0]['generated_text']
st.write(f"Translation: {translation}")
if translation is not None and ner is not None:
st.write('Entities: ', get_entity_labels(model=ner, text=translation))
loading_elapsedtime = audit_elapsedtime(function="Loading data", start=start_loading)
st.write(f"Total elapsed time: {int(loading_elapsedtime/60)} minutes and {int(loading_elapsedtime%60)} seconds")
if __name__ == "__main__":
print("IN __name__")
main() |