Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
| 1 |
from collections import deque
|
| 2 |
-
|
| 3 |
import streamlit as st
|
| 4 |
import torch
|
| 5 |
from streamlit_player import st_player
|
| 6 |
from transformers import AutoModelForCTC, Wav2Vec2Processor
|
| 7 |
-
|
| 8 |
from streaming import ffmpeg_stream
|
| 9 |
|
| 10 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
@@ -27,11 +25,9 @@ def load_model(model_path="facebook/wav2vec2-large-robust-ft-swbd-300h"):
|
|
| 27 |
processor = Wav2Vec2Processor.from_pretrained(model_path)
|
| 28 |
model = AutoModelForCTC.from_pretrained(model_path).to(device)
|
| 29 |
return processor, model
|
| 30 |
-
|
| 31 |
-
|
| 32 |
processor, model = load_model()
|
| 33 |
|
| 34 |
-
|
| 35 |
def stream_text(url, chunk_duration_ms, pad_duration_ms):
|
| 36 |
sampling_rate = processor.feature_extractor.sampling_rate
|
| 37 |
|
|
@@ -63,16 +59,14 @@ def stream_text(url, chunk_duration_ms, pad_duration_ms):
|
|
| 63 |
else:
|
| 64 |
yield leftover_text
|
| 65 |
leftover_text = ""
|
| 66 |
-
|
| 67 |
yield leftover_text
|
| 68 |
|
| 69 |
-
|
| 70 |
def main():
|
| 71 |
state = st.session_state
|
| 72 |
-
st.header("
|
| 73 |
|
| 74 |
with st.form(key="inputs_form"):
|
| 75 |
-
state.youtube_url = st.text_input("YouTube URL", "https://
|
| 76 |
state.chunk_duration_ms = st.slider("Audio chunk duration (ms)", 2000, 10000, 3000, 100)
|
| 77 |
state.pad_duration_ms = st.slider("Padding duration (ms)", 100, 5000, 1000, 100)
|
| 78 |
submit_button = st.form_submit_button(label="Submit")
|
|
|
|
| 1 |
from collections import deque
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import torch
|
| 4 |
from streamlit_player import st_player
|
| 5 |
from transformers import AutoModelForCTC, Wav2Vec2Processor
|
|
|
|
| 6 |
from streaming import ffmpeg_stream
|
| 7 |
|
| 8 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
|
|
| 25 |
processor = Wav2Vec2Processor.from_pretrained(model_path)
|
| 26 |
model = AutoModelForCTC.from_pretrained(model_path).to(device)
|
| 27 |
return processor, model
|
| 28 |
+
|
|
|
|
| 29 |
processor, model = load_model()
|
| 30 |
|
|
|
|
| 31 |
def stream_text(url, chunk_duration_ms, pad_duration_ms):
|
| 32 |
sampling_rate = processor.feature_extractor.sampling_rate
|
| 33 |
|
|
|
|
| 59 |
else:
|
| 60 |
yield leftover_text
|
| 61 |
leftover_text = ""
|
|
|
|
| 62 |
yield leftover_text
|
| 63 |
|
|
|
|
| 64 |
def main():
|
| 65 |
state = st.session_state
|
| 66 |
+
st.header("Video ASR Streamlit from Youtube Link")
|
| 67 |
|
| 68 |
with st.form(key="inputs_form"):
|
| 69 |
+
state.youtube_url = st.text_input("YouTube URL", "https://youtu.be/cC1HszE5Hcw?list=PLHgX2IExbFouJoqEr8JMF5MbZSbyC91-L")
|
| 70 |
state.chunk_duration_ms = st.slider("Audio chunk duration (ms)", 2000, 10000, 3000, 100)
|
| 71 |
state.pad_duration_ms = st.slider("Padding duration (ms)", 100, 5000, 1000, 100)
|
| 72 |
submit_button = st.form_submit_button(label="Submit")
|