Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
import torch
|
4 |
+
import io
|
5 |
+
|
6 |
+
# Load the ASR pipeline with Whisper model
|
7 |
+
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-large-v3")
|
8 |
+
|
9 |
+
def transcribe_audio(audio_file):
|
10 |
+
# Load audio file
|
11 |
+
audio_bytes = audio_file.read()
|
12 |
+
audio = io.BytesIO(audio_bytes)
|
13 |
+
|
14 |
+
# Transcribe audio
|
15 |
+
transcription = pipe(audio)
|
16 |
+
return transcription['text']
|
17 |
+
|
18 |
+
# Streamlit UI
|
19 |
+
st.title("Speech-to-Text Transcription App")
|
20 |
+
st.write("Upload an audio file to transcribe its content into text.")
|
21 |
+
|
22 |
+
uploaded_file = st.file_uploader("Choose an audio file...", type=["wav", "mp3", "flac"])
|
23 |
+
|
24 |
+
if uploaded_file is not None:
|
25 |
+
with st.spinner("Transcribing..."):
|
26 |
+
text = transcribe_audio(uploaded_file)
|
27 |
+
st.subheader("Transcription Result:")
|
28 |
+
st.write(text)
|