pratikshahp commited on
Commit
944864d
·
verified ·
1 Parent(s): 0ca51b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -14,13 +14,11 @@ def transcribe_audio(audio_bytes):
14
  model = AutoModelForSpeechSeq2Seq.from_pretrained("openai/whisper-large")
15
  audio_array = np.frombuffer(audio_bytes, dtype=np.int16)
16
  audio_tensor = torch.tensor(audio_array, dtype=torch.float64) / 32768.0
17
- input_values = processor(audio=audio_tensor, return_tensors="pt", sampling_rate=16000).input_values
18
  logits = model(input_values).logits
19
  predicted_ids = torch.argmax(logits, dim=-1)
20
  transcription = processor.decode(predicted_ids[0])
21
  return transcription
22
-
23
-
24
 
25
  # Streamlit app
26
  st.title("Audio to Text Transcription..")
 
14
  model = AutoModelForSpeechSeq2Seq.from_pretrained("openai/whisper-large")
15
  audio_array = np.frombuffer(audio_bytes, dtype=np.int16)
16
  audio_tensor = torch.tensor(audio_array, dtype=torch.float64) / 32768.0
17
+ input_values = processor.feature_extractor(audio=audio_tensor, sampling_rate=16000, return_tensors="pt").input_values
18
  logits = model(input_values).logits
19
  predicted_ids = torch.argmax(logits, dim=-1)
20
  transcription = processor.decode(predicted_ids[0])
21
  return transcription
 
 
22
 
23
  # Streamlit app
24
  st.title("Audio to Text Transcription..")