Spaces:
Sleeping
Sleeping
asgharasad786
commited on
Upload 2 files
Browse files- app.py +33 -0
- requirements.txt +7 -0
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the speech recognition pipeline
|
5 |
+
pipe = pipeline("automatic-speech-recognition", model="AqeelShafy7/AudioSangraha-Audio_to_Text")
|
6 |
+
|
7 |
+
# Streamlit app layout
|
8 |
+
st.title("Speech to Text Transcription")
|
9 |
+
|
10 |
+
# Sidebar layout for uploading audio and processing it
|
11 |
+
st.sidebar.title("Upload Audio for Transcription")
|
12 |
+
|
13 |
+
# File uploader widget for the audio file in the sidebar
|
14 |
+
audio_file = st.sidebar.file_uploader("Upload Audio File (MP3 format)", type=["mp3"])
|
15 |
+
|
16 |
+
# Button to process the audio file
|
17 |
+
if st.sidebar.button("Process Audio"):
|
18 |
+
if audio_file is not None:
|
19 |
+
# Define a path for the uploaded file (within the app's directory)
|
20 |
+
upload_path = "uploaded_audio.mp3"
|
21 |
+
|
22 |
+
# Save the uploaded file to the defined path
|
23 |
+
with open(upload_path, "wb") as f:
|
24 |
+
f.write(audio_file.getbuffer())
|
25 |
+
|
26 |
+
# Provide the file path to the pipeline
|
27 |
+
result = pipe(upload_path)
|
28 |
+
|
29 |
+
# Display the transcription result in the main area
|
30 |
+
transcribed_text = result['text']
|
31 |
+
st.text_area("Transcribed Text", transcribed_text, height=300)
|
32 |
+
else:
|
33 |
+
st.error("Please upload an audio file to process.")
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==1.17.0
|
2 |
+
altair==4.0.0
|
3 |
+
transformers==4.38.0
|
4 |
+
torch==2.2.0
|
5 |
+
numpy==1.24.3
|
6 |
+
ffmpeg
|
7 |
+
|