Add: Recording option for testing CoNeTTE.
Browse files- .gitignore +1 -0
- app.py +23 -1
- requirements.txt +2 -1
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
record.wav
|
app.py
CHANGED
@@ -6,6 +6,8 @@ from typing import Any
|
|
6 |
|
7 |
import streamlit as st
|
8 |
|
|
|
|
|
9 |
from conette import CoNeTTEModel, conette
|
10 |
|
11 |
|
@@ -25,10 +27,22 @@ def main() -> None:
|
|
25 |
|
26 |
st.warning("Recommanded audio: lasting from **1 to 30s**, sampled at **32 kHz**.")
|
27 |
audios = st.file_uploader(
|
28 |
-
"Upload audio files here
|
29 |
type=["wav", "flac", "mp3", "ogg", "avi"],
|
30 |
accept_multiple_files=True,
|
31 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
with st.expander("Model hyperparameters"):
|
34 |
task = st.selectbox("Task embedding input", model.tasks, 0)
|
@@ -110,6 +124,14 @@ def main() -> None:
|
|
110 |
for audio_fname, cand in zip(audio_fnames, cands):
|
111 |
st.success(f"**Output for {audio_fname}:**\n- {format_cand(cand)}")
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
if __name__ == "__main__":
|
115 |
main()
|
|
|
6 |
|
7 |
import streamlit as st
|
8 |
|
9 |
+
from audiorecorder import audiorecorder
|
10 |
+
|
11 |
from conette import CoNeTTEModel, conette
|
12 |
|
13 |
|
|
|
27 |
|
28 |
st.warning("Recommanded audio: lasting from **1 to 30s**, sampled at **32 kHz**.")
|
29 |
audios = st.file_uploader(
|
30 |
+
"**Upload audio files here:**",
|
31 |
type=["wav", "flac", "mp3", "ogg", "avi"],
|
32 |
accept_multiple_files=True,
|
33 |
)
|
34 |
+
st.write("**OR**")
|
35 |
+
record = audiorecorder(
|
36 |
+
start_prompt="Start recording", stop_prompt="Stop recording", pause_prompt=""
|
37 |
+
)
|
38 |
+
|
39 |
+
record_fpath = "record.wav"
|
40 |
+
if len(record) > 0:
|
41 |
+
record.export(record_fpath, format="wav")
|
42 |
+
st.write(
|
43 |
+
f"Record frame rate: {record.frame_rate}Hz, record duration: {record.duration_seconds:.2f}s"
|
44 |
+
)
|
45 |
+
st.audio(record.export().read()) # type: ignore
|
46 |
|
47 |
with st.expander("Model hyperparameters"):
|
48 |
task = st.selectbox("Task embedding input", model.tasks, 0)
|
|
|
124 |
for audio_fname, cand in zip(audio_fnames, cands):
|
125 |
st.success(f"**Output for {audio_fname}:**\n- {format_cand(cand)}")
|
126 |
|
127 |
+
if len(record) > 0:
|
128 |
+
outputs = model(
|
129 |
+
record_fpath,
|
130 |
+
**kwargs,
|
131 |
+
)
|
132 |
+
cand = outputs["cands"][0]
|
133 |
+
st.success(f"**Output for {'test'}:**\n- {format_cand(cand)}")
|
134 |
+
|
135 |
|
136 |
if __name__ == "__main__":
|
137 |
main()
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
conette>=0.1.3
|
|
|
|
1 |
+
conette>=0.1.3
|
2 |
+
streamlit-audiorecorder
|