Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import soundfile as sf
|
3 |
+
from transformers import pipeline
|
4 |
+
import io
|
5 |
+
|
6 |
+
# Load the model
|
7 |
+
pipe = pipeline("automatic-speech-recognition", model="facebook/seamless-m4t-v2-large")
|
8 |
+
|
9 |
+
# Streamlit title and instructions
|
10 |
+
st.title("Real-Time Speech Recognition")
|
11 |
+
st.write("Click the button below to start recording and transcribe the audio.")
|
12 |
+
|
13 |
+
# Audio recording
|
14 |
+
audio_file = st.file_uploader("Upload an audio file", type=["wav", "mp3"])
|
15 |
+
|
16 |
+
if audio_file is not None:
|
17 |
+
# Read the audio file and transcribe
|
18 |
+
audio_bytes = audio_file.read()
|
19 |
+
audio_data, samplerate = sf.read(io.BytesIO(audio_bytes))
|
20 |
+
|
21 |
+
# Run the transcription pipeline
|
22 |
+
result = pipe(audio_data)
|
23 |
+
|
24 |
+
# Display the transcription result
|
25 |
+
st.write("Transcription: ", result['text'])
|