Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
import torch
|
| 2 |
import torchaudio
|
| 3 |
from torchaudio.transforms import Resample
|
| 4 |
-
from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
|
| 5 |
import streamlit as st
|
| 6 |
from audio_recorder_streamlit import audio_recorder
|
|
|
|
| 7 |
|
| 8 |
def preprocess_audio(audio_bytes, sample_rate=16000):
|
| 9 |
# Load audio and convert to mono if necessary
|
|
@@ -19,9 +20,11 @@ def preprocess_audio(audio_bytes, sample_rate=16000):
|
|
| 19 |
return waveform
|
| 20 |
|
| 21 |
def transcribe_audio(audio_bytes):
|
| 22 |
-
model = Speech2TextForConditionalGeneration.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
| 23 |
-
processor = Speech2TextProcessor.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
# Preprocess audio
|
| 26 |
input_features = preprocess_audio(audio_bytes)
|
| 27 |
|
|
|
|
| 1 |
import torch
|
| 2 |
import torchaudio
|
| 3 |
from torchaudio.transforms import Resample
|
| 4 |
+
#from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
|
| 5 |
import streamlit as st
|
| 6 |
from audio_recorder_streamlit import audio_recorder
|
| 7 |
+
from transformers import AutoProcessor, AutoModelForPreTraining
|
| 8 |
|
| 9 |
def preprocess_audio(audio_bytes, sample_rate=16000):
|
| 10 |
# Load audio and convert to mono if necessary
|
|
|
|
| 20 |
return waveform
|
| 21 |
|
| 22 |
def transcribe_audio(audio_bytes):
|
| 23 |
+
#model = Speech2TextForConditionalGeneration.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
| 24 |
+
#processor = Speech2TextProcessor.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
| 25 |
+
# Load model directly
|
| 26 |
+
processor = AutoProcessor.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
| 27 |
+
model = AutoModelForPreTraining.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
| 28 |
# Preprocess audio
|
| 29 |
input_features = preprocess_audio(audio_bytes)
|
| 30 |
|