Copy Boss commited on
Commit
e8f1a46
1 Parent(s): e52a330
Files changed (2) hide show
  1. app.py +5 -5
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,8 +1,7 @@
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"])
@@ -17,12 +16,13 @@ audiofile = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
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.")
 
1
  import streamlit as st
2
  import stable_whisper
3
  import json
4
+ import torch
 
5
 
6
  # Create a dropdown to select the model
7
  model_name = st.selectbox("Select a model", ["base", "small", "medium", "large", "large-v2"])
 
16
  if st.button('Transcribe'):
17
  if audiofile is not None:
18
  # Read the audio file
19
+ audio_data = torch.from_numpy(audiofile.read())
20
+ # Convert the audio data to float
21
+ audio_data = audio_data.float()
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,3 +1,4 @@
1
  streamlit
2
  stable-ts
3
- soundfile
 
 
1
  streamlit
2
  stable-ts
3
+ torch
4
+ numpy