Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import numpy as np
|
|
4 |
import io
|
5 |
import wave
|
6 |
import requests
|
7 |
-
from
|
8 |
|
9 |
|
10 |
# Initialize Streamlit app layout
|
@@ -14,35 +14,25 @@ def audio_callback(frame):
|
|
14 |
# Get raw audio data from the frame
|
15 |
audio_data = frame.to_ndarray().astype(np.int16)
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
"Content-Type": "application/json"
|
37 |
-
}
|
38 |
-
payload = {
|
39 |
-
"prompt": transcription
|
40 |
-
}
|
41 |
-
response = requests.post(API_URL, json=payload, headers=headers)
|
42 |
-
if response.status_code == 200:
|
43 |
-
st.write("Assistant:", response.json())
|
44 |
-
else:
|
45 |
-
st.write("Error:", response.status_code, response.text)
|
46 |
|
47 |
|
48 |
webrtc_ctx = webrtc_streamer(
|
|
|
4 |
import io
|
5 |
import wave
|
6 |
import requests
|
7 |
+
from audio_to_text import audio_to_text
|
8 |
|
9 |
|
10 |
# Initialize Streamlit app layout
|
|
|
14 |
# Get raw audio data from the frame
|
15 |
audio_data = frame.to_ndarray().astype(np.int16)
|
16 |
|
17 |
+
# Convert audio to text
|
18 |
+
transcription = audio_to_text(audio_data)
|
19 |
+
|
20 |
+
# Display the transcription
|
21 |
+
st.write("Transcription:", transcription)
|
22 |
+
|
23 |
+
API_URL = "https://eaa0-34-74-179-199.ngrok-free.app/generate"
|
24 |
+
# Optionally, send the transcription to an API
|
25 |
+
headers = {
|
26 |
+
"Content-Type": "application/json"
|
27 |
+
}
|
28 |
+
payload = {
|
29 |
+
"prompt": transcription
|
30 |
+
}
|
31 |
+
response = requests.post(API_URL, json=payload, headers=headers)
|
32 |
+
if response.status_code == 200:
|
33 |
+
st.write("Assistant:", response.json())
|
34 |
+
else:
|
35 |
+
st.write("Error:", response.status_code, response.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
webrtc_ctx = webrtc_streamer(
|