Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,11 +14,12 @@ 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.feature_extractor(
|
| 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..")
|
|
|
|
| 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(raw_speech=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 |
|
| 24 |
# Streamlit app
|
| 25 |
st.title("Audio to Text Transcription..")
|