RajatMalviya commited on
Commit
c3a809c
·
verified ·
1 Parent(s): c64dc9f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import tempfile
3
+ import os
4
+ from transformers import pipeline
5
+
6
+ # Load the ASR model
7
+ @st.cache_resource
8
+ def load_model():
9
+ return pipeline("automatic-speech-recognition", model="ivrit-ai/whisper-large-v3-turbo")
10
+
11
+ model = load_model()
12
+
13
+ # Streamlit UI
14
+ st.title("Hebrew Speech-to-Text Transcription")
15
+
16
+ # Upload audio file
17
+ uploaded_file = st.file_uploader("Upload an audio file (WAV, MP3, OGG)", type=["wav", "mp3", "ogg"])
18
+
19
+ if uploaded_file is not None:
20
+ # Save the uploaded file to a temporary location
21
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_audio:
22
+ temp_audio.write(uploaded_file.read())
23
+ temp_audio_path = temp_audio.name
24
+
25
+ # Transcribe the audio
26
+ st.write("Transcribing...")
27
+ try:
28
+ result = model(temp_audio_path)
29
+ st.subheader("Transcription:")
30
+ st.write(result["text"])
31
+ except Exception as e:
32
+ st.error(f"Error: {str(e)}")
33
+
34
+ # Clean up the temporary file
35
+ os.remove(temp_audio_path)