Spaces:
Sleeping
Sleeping
File size: 4,283 Bytes
b55acf5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | import streamlit as st
import os
from pathlib import Path
import torch
import torchaudio
import helper_functions as hf
import time
def main():
st.set_page_config(page_title="What's That Tongue?", layout="centered")
st.title("What's That Tongue?")
uploaded_file = st.file_uploader(
"Upload your audio file",
type=["mp3", "wav"]
)
# Create a placeholder for processing messages
status_container = st.empty()
progress_container = st.empty()
if uploaded_file is not None:
# File Upload Section
with progress_container:
upload_progress = st.progress(0)
with status_container:
st.spinner('Uploading...')
success = hf.save_uploaded_file(uploaded_file)
upload_progress.progress(100)
with status_container:
st.success('Upload completed!')
time.sleep(1)
if success:
# Preprocessing Section
st.subheader("Audio Preprocessing")
# Clear previous progress
progress_container.empty()
status_container.empty()
# Convert to WAV
with progress_container:
wav_progress = st.progress(0)
with status_container:
st.spinner('Converting to WAV format...')
wav_success = hf.convert_to_wav()
wav_progress.progress(100)
with status_container:
st.success('WAV conversion completed!')
time.sleep(1)
if not wav_success:
st.error('WAV conversion failed.')
return
# Clear previous progress
progress_container.empty()
status_container.empty()
# Enhance Quality
with progress_container:
quality_progress = st.progress(0)
with status_container:
st.spinner('Enhancing audio quality...')
quality_success = hf.enhance_quality()
quality_progress.progress(100)
with status_container:
st.success('Quality enhancement completed!')
time.sleep(1)
if not quality_success:
st.error('Quality enhancement failed.')
return
# Clear previous progress
progress_container.empty()
status_container.empty()
# Remove Background Noise
with progress_container:
noise_progress = st.progress(0)
with status_container:
st.spinner('Removing background noise...')
noise_success = hf.separate_vocals()
noise_progress.progress(100)
with status_container:
st.success('Background noise removal completed!')
time.sleep(1)
if not noise_success:
st.error('Background noise removal failed.')
return
# Clear previous progress
progress_container.empty()
status_container.empty()
# Remove Silence
with progress_container:
silence_progress = st.progress(0)
with status_container:
st.spinner('Removing silence...')
silence_success = hf.remove_silence()
silence_progress.progress(100)
with status_container:
st.success('Silence removal completed!')
time.sleep(1)
if not silence_success:
st.error('Silence removal failed.')
return
# Clear final progress
progress_container.empty()
status_container.empty()
st.success('All preprocessing steps completed successfully!')
else:
st.error('Upload failed.')
if __name__ == "__main__":
main() |