File size: 1,250 Bytes
cab263c 1581bbf d63135e 3c2d633 cab263c 4affef3 f8dfb0f d63135e 2980190 cd60f99 42bce02 2980190 d63135e 42b403c cd60f99 2980190 86cd1dc 8d06043 d63135e 3c2d633 cd60f99 4affef3 3c2d633 4affef3 |
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 |
# 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, wait: bool=True):
if audio:
audio_bytes = audio["bytes"]
sample_rate = audio["sample_rate"]
sample_width = audio["sample_width"]
total_samples = len(audio_bytes) / sample_width
duration = total_samples / sample_rate
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))
t2a = T2A(response).get_audio()
autoplay(t2a)
del response
if __name__ == "__main__":
print('RAM memory % used:', psutil.virtual_memory()[2]) # ~ 94 GB full memory
main() |