pratikshahp commited on
Commit
4d2986c
·
verified ·
1 Parent(s): b521892

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -20,17 +20,16 @@ def transcribe_audio(audio_bytes):
20
  audio_tensor = torch.tensor(audio_array, dtype=torch.float64) / 32768.0
21
 
22
  # Provide inputs to the processor
23
- inputs = processor(audio=audio_tensor, sampling_rate=16000, return_tensors="pt")
24
-
25
- # Generate logits from the model
26
- logits = model(**inputs).logits
27
-
28
- # Decode the predicted IDs to get the transcription
29
- predicted_ids = torch.argmax(logits, dim=-1)
30
- transcription = processor.decode(predicted_ids[0])
31
-
32
- return transcription
33
 
 
 
34
 
35
  # Streamlit app
36
  st.title("Audio to Text Transcription..")
 
20
  audio_tensor = torch.tensor(audio_array, dtype=torch.float64) / 32768.0
21
 
22
  # Provide inputs to the processor
23
+ #inputs = processor(audio=audio_tensor, sampling_rate=16000, return_tensors="pt")
24
+ input_features = processor(audio_tensor, sampling_rate=16000, return_tensors="pt").input_features
25
+
26
+ # generate token ids
27
+ predicted_ids = model.generate(input_features)
28
+ # decode token ids to text
29
+ transcription = processor.batch_decode(predicted_ids, skip_special_tokens=False)
 
 
 
30
 
31
+ transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
32
+ return transcription
33
 
34
  # Streamlit app
35
  st.title("Audio to Text Transcription..")