Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,10 @@ from streamlit_mic_recorder import mic_recorder
|
|
13 |
|
14 |
llmchain = LLM_chain()
|
15 |
|
16 |
-
def autoplay(audio, wait: bool=True):
|
17 |
if audio:
|
18 |
audio_bytes = audio
|
19 |
-
|
20 |
-
sample_width = audio["sample_width"]
|
21 |
-
total_samples = len(audio_bytes) / sample_width
|
22 |
-
duration = total_samples / sample_rate
|
23 |
audio_base64 = base64.b64encode(audio_bytes).decode('utf-8')
|
24 |
if wait:
|
25 |
time.sleep(duration)
|
@@ -32,8 +29,8 @@ def main():
|
|
32 |
text = a2t.predict()
|
33 |
response = llmchain(entity=text, id=0)
|
34 |
print(sys.getsizeof(a2t), " ", sys.getsizeof(text), " ", sys.getsizeof(response), " ", sys.getsizeof(llmchain))
|
35 |
-
|
36 |
-
autoplay(
|
37 |
del response
|
38 |
|
39 |
|
|
|
13 |
|
14 |
llmchain = LLM_chain()
|
15 |
|
16 |
+
def autoplay(audio: bytes, duration: float, wait: bool=True, sr: int=16000):
|
17 |
if audio:
|
18 |
audio_bytes = audio
|
19 |
+
duration = duration
|
|
|
|
|
|
|
20 |
audio_base64 = base64.b64encode(audio_bytes).decode('utf-8')
|
21 |
if wait:
|
22 |
time.sleep(duration)
|
|
|
29 |
text = a2t.predict()
|
30 |
response = llmchain(entity=text, id=0)
|
31 |
print(sys.getsizeof(a2t), " ", sys.getsizeof(text), " ", sys.getsizeof(response), " ", sys.getsizeof(llmchain))
|
32 |
+
audio, _, duration = T2A(response).get_audio()
|
33 |
+
autoplay(audio=audio, duration=duration)
|
34 |
del response
|
35 |
|
36 |
|