Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
from audiorecorder import audiorecorder
|
@@ -32,9 +36,30 @@ st.title("Patent Claims Extraction")
|
|
32 |
api_key = st.text_input("Enter your OpenAI API Key:", type="password")
|
33 |
|
34 |
# Audio Recording
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
if submit_button:
|
40 |
model = whisper.load_model("base")
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
import sounddevice as sd
|
4 |
+
import numpy as np
|
5 |
+
import wave
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
from audiorecorder import audiorecorder
|
|
|
36 |
api_key = st.text_input("Enter your OpenAI API Key:", type="password")
|
37 |
|
38 |
# Audio Recording
|
39 |
+
record_audio = st.checkbox("Record Audio")
|
40 |
+
if record_audio:
|
41 |
+
audio_frames = []
|
42 |
+
|
43 |
+
def audio_callback(indata, frames, time, status):
|
44 |
+
if status:
|
45 |
+
print(status, flush=True)
|
46 |
+
if any(indata):
|
47 |
+
audio_frames.append(indata.copy())
|
48 |
+
|
49 |
+
with st.spinner("Recording..."):
|
50 |
+
with sd.InputStream(callback=audio_callback):
|
51 |
+
st.text("Recording audio. Click 'Stop Recording' when finished.")
|
52 |
+
st.button("Stop Recording")
|
53 |
+
|
54 |
+
st.success("Recording stopped")
|
55 |
+
|
56 |
+
if audio_frames:
|
57 |
+
audio_data = np.concatenate(audio_frames, axis=0)
|
58 |
+
with wave.open("recorded_audio.wav", "wb") as wf:
|
59 |
+
wf.setnchannels(1)
|
60 |
+
wf.setsampwidth(2)
|
61 |
+
wf.setframerate(44100)
|
62 |
+
wf.writeframes(audio_data.tobytes())
|
63 |
|
64 |
if submit_button:
|
65 |
model = whisper.load_model("base")
|