RACK808 / app.py
cmagganas's picture
Create app.py
e0cc52c
raw
history blame
1.2 kB
# functional app
from model import load_model, invert_audio
import os
preloaded = {}
preloaded["model"], preloaded["processor"] = load_model()
# Co
for input_audio_path in data_dir.glob('*.wav'):
print(os.path.basename(input_audio_path))
output_audio_path = os.path.join(output_dir, "inverted-" + os.path.basename(input_audio_path))
output_file = invert_audio(
preloaded["model"], preloaded["processor"],
input_audio_path, output_audio_path)
# HuggingFace UI
import streamlit as st
import torch
import julius
st.title("Audio Inversion with HuggingFace & Streamlit")
uploaded_file = st.file_uploader("Upload an audio file", type=["wav", "flac"])
if uploaded_file:
st.audio(uploaded_file, format="audio/wav")
with st.spinner("Inverting audio..."):
output_path = "inverted_output.wav" # Temporary output path. Consider using temp files or dynamic naming in production.
invert_audio(model, processor, uploaded_file, output_path)
st.audio(output_path, format="audio/wav")
if st.button("Download Inverted Audio"):
st.download_button("Download Inverted Audio", data=output_path, file_name="inverted_output.wav", mime="audio/wav")