CineAI commited on
Commit
d63135e
1 Parent(s): 4bb9300

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -1,24 +1,37 @@
1
  # version - ArticMonkey:19.03.24:1743
2
 
3
  import psutil
 
 
4
 
5
  import streamlit as st
6
  from audio_processing.A2T import A2T
 
7
  from llm.llm import LLM_chain
8
  from streamlit_mic_recorder import mic_recorder
9
 
10
  llmchain = LLM_chain()
11
 
 
 
 
 
 
 
 
 
 
 
 
12
  def main():
13
  mic = mic_recorder(start_prompt="Record",stop_prompt="Stop", just_once=True)
14
 
15
  if mic is not None:
16
  a2t = A2T(mic["bytes"])
17
  text = a2t.predict()
18
- st.write(text)
19
  response = llmchain(entity=text, id=0)
20
- st.write(response if response is not None else "Nothing")
21
- del response
22
 
23
 
24
  if __name__ == "__main__":
 
1
  # version - ArticMonkey:19.03.24:1743
2
 
3
  import psutil
4
+ import base64
5
+ import time
6
 
7
  import streamlit as st
8
  from audio_processing.A2T import A2T
9
+ from audio_processing.T2A import T2A
10
  from llm.llm import LLM_chain
11
  from streamlit_mic_recorder import mic_recorder
12
 
13
  llmchain = LLM_chain()
14
 
15
+ def autoplay(audio, wait: bool=True):
16
+ if audio:
17
+ audio_bytes = audio["bytes"]
18
+ sample_rate = audio["sample_rate"]
19
+ sample_width = audio["sample_width"]
20
+ total_samples = len(audio_bytes) / sample_width
21
+ duration = total_samples / sample_rate
22
+ audio_base64 = base64.b64encode(audio_bytes).decode('utf-8')
23
+ if wait:
24
+ time.sleep(duration)
25
+
26
  def main():
27
  mic = mic_recorder(start_prompt="Record",stop_prompt="Stop", just_once=True)
28
 
29
  if mic is not None:
30
  a2t = A2T(mic["bytes"])
31
  text = a2t.predict()
 
32
  response = llmchain(entity=text, id=0)
33
+ t2a = T2A(response)
34
+ autoplay(t2a)
35
 
36
 
37
  if __name__ == "__main__":