voiceoperation / app.py
Zeimoto
added translation task in whisper model
c438acc
raw
history blame
1.6 kB
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, translate
# from translation import get_translation
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))
# text = "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(text)
# traducao = get_translation(text_to_translate=text, languageCode="pt")
# st.write(traducao)
s2t = init_model_trans()
# ner = init_model_ner() #async
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 and s2t is not None:
print("Loading data...")
start_loading = set_start()
st.audio(wav_audio_data, format='audio/wav')
original = transcribe(wav_audio_data, s2t)
print("translating audio...")
translation = translate(original)
st.write(f"Original: {original}/nTranscription: {translation}")
# if text is not None and ner is not None:
# st.write('Entities: ', get_entity_labels(model=ner, text=text))
# audit_elapsedtime(function="Loading data", start=start_loading)
if __name__ == "__main__":
print("IN __name__")
main()