Spaces:
Runtime error
Runtime error
Copy Boss
commited on
Commit
•
30f568b
1
Parent(s):
ffe71b0
update
Browse files- app.py +7 -2
- requirements.txt +3 -1
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
import stable_whisper
|
3 |
import json
|
|
|
|
|
4 |
|
5 |
# Create a dropdown to select the model
|
6 |
model_name = st.selectbox("Select a model", ["base", "small", "medium", "large", "large-v2"])
|
@@ -14,10 +16,13 @@ audiofile = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
|
|
14 |
# Create a button to run the prediction
|
15 |
if st.button('Transcribe'):
|
16 |
if audiofile is not None:
|
|
|
|
|
|
|
17 |
# Transcribe the audio file
|
18 |
-
result = model.transcribe(
|
19 |
# Convert the result to JSON and display it
|
20 |
result_json = json.loads(result)
|
21 |
st.json(result_json)
|
22 |
else:
|
23 |
-
st.write("Please upload an audio file.")
|
|
|
1 |
import streamlit as st
|
2 |
import stable_whisper
|
3 |
import json
|
4 |
+
import soundfile as sf
|
5 |
+
import io
|
6 |
|
7 |
# Create a dropdown to select the model
|
8 |
model_name = st.selectbox("Select a model", ["base", "small", "medium", "large", "large-v2"])
|
|
|
16 |
# Create a button to run the prediction
|
17 |
if st.button('Transcribe'):
|
18 |
if audiofile is not None:
|
19 |
+
# Read the audio file
|
20 |
+
file_bytes = audiofile.read()
|
21 |
+
audio_data, sample_rate = sf.read(io.BytesIO(file_bytes))
|
22 |
# Transcribe the audio file
|
23 |
+
result = model.transcribe(audio_data)
|
24 |
# Convert the result to JSON and display it
|
25 |
result_json = json.loads(result)
|
26 |
st.json(result_json)
|
27 |
else:
|
28 |
+
st.write("Please upload an audio file.")
|
requirements.txt
CHANGED
@@ -1,2 +1,4 @@
|
|
1 |
streamlit
|
2 |
-
stable-ts
|
|
|
|
|
|
1 |
streamlit
|
2 |
+
stable-ts
|
3 |
+
json
|
4 |
+
soundfile
|