Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
import torch
|
2 |
import torchaudio
|
3 |
from torchaudio.transforms import Resample
|
4 |
-
|
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,11 +19,11 @@ def preprocess_audio(audio_bytes, sample_rate=16000):
|
|
20 |
return waveform
|
21 |
|
22 |
def transcribe_audio(audio_bytes):
|
23 |
-
|
24 |
-
|
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 |
|
|
|
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 |
return waveform
|
20 |
|
21 |
def transcribe_audio(audio_bytes):
|
22 |
+
model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-librispeech-asr")
|
23 |
+
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-librispeech-asr")
|
24 |
# Load model directly
|
25 |
+
#processor = AutoProcessor.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
26 |
+
#model = AutoModelForPreTraining.from_pretrained("facebook/wav2vec2-large-100k-voxpopuli")
|
27 |
# Preprocess audio
|
28 |
input_features = preprocess_audio(audio_bytes)
|
29 |
|