Chelsea / app.py
CineAI's picture
Update app.py
8c12d4e verified
raw
history blame
1.16 kB
# version - ArticMonkey:19.03.24:1743
import psutil
import base64
import time
import sys
import streamlit as st
from audio_processing.A2T import A2T
from audio_processing.T2A import T2A
from llm.llm import LLM_chain
from streamlit_mic_recorder import mic_recorder
llmchain = LLM_chain()
def autoplay(audio: bytes, duration: float, wait: bool=True, sr: int=16000):
if audio:
audio_bytes = audio
duration = duration
audio_base64 = base64.b64encode(audio_bytes).decode('utf-8')
if wait:
time.sleep(duration)
def main():
mic = mic_recorder(start_prompt="Record",stop_prompt="Stop", just_once=True)
if mic is not None:
a2t = A2T(mic["bytes"])
text = a2t.predict()
response = llmchain(entity=text, id=0)
print(sys.getsizeof(a2t), " ", sys.getsizeof(text), " ", sys.getsizeof(response), " ", sys.getsizeof(llmchain))
audio, _, duration = T2A(response).get_audio()
autoplay(audio=audio, duration=duration)
del response
if __name__ == "__main__":
print('RAM memory % used:', psutil.virtual_memory()[2]) # ~ 94 GB full memory
main()