Update app.py
Browse files
app.py
CHANGED
@@ -28,17 +28,15 @@ def transcribe_audio(audio_file):
|
|
28 |
|
29 |
def main():
|
30 |
st.title("Speech-to-Text Converter")
|
31 |
-
|
32 |
uploaded_file = st.file_uploader("Choose an audio file", type=["wav", "mp3", "m4a", "ogg", "flac"])
|
33 |
-
|
34 |
if uploaded_file is not None:
|
35 |
st.audio(uploaded_file)
|
36 |
-
|
37 |
if st.button("Transcribe"):
|
38 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.' + uploaded_file.name.split('.')[-1]) as tmp_file:
|
39 |
tmp_file.write(uploaded_file.getvalue())
|
40 |
tmp_file_path = tmp_file.name
|
41 |
-
|
42 |
try:
|
43 |
# Convert to WAV
|
44 |
wav_file_path = convert_to_wav(tmp_file_path)
|
@@ -48,10 +46,8 @@ def main():
|
|
48 |
|
49 |
st.write("Transcription:")
|
50 |
st.write(transcription)
|
51 |
-
|
52 |
except Exception as e:
|
53 |
st.error(f"An error occurred: {str(e)}")
|
54 |
-
|
55 |
finally:
|
56 |
# Clean up
|
57 |
os.unlink(tmp_file_path)
|
|
|
28 |
|
29 |
def main():
|
30 |
st.title("Speech-to-Text Converter")
|
|
|
31 |
uploaded_file = st.file_uploader("Choose an audio file", type=["wav", "mp3", "m4a", "ogg", "flac"])
|
32 |
+
|
33 |
if uploaded_file is not None:
|
34 |
st.audio(uploaded_file)
|
|
|
35 |
if st.button("Transcribe"):
|
36 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.' + uploaded_file.name.split('.')[-1]) as tmp_file:
|
37 |
tmp_file.write(uploaded_file.getvalue())
|
38 |
tmp_file_path = tmp_file.name
|
39 |
+
|
40 |
try:
|
41 |
# Convert to WAV
|
42 |
wav_file_path = convert_to_wav(tmp_file_path)
|
|
|
46 |
|
47 |
st.write("Transcription:")
|
48 |
st.write(transcription)
|
|
|
49 |
except Exception as e:
|
50 |
st.error(f"An error occurred: {str(e)}")
|
|
|
51 |
finally:
|
52 |
# Clean up
|
53 |
os.unlink(tmp_file_path)
|