|
|
|
from model import load_model, invert_audio |
|
import os |
|
|
|
preloaded = {} |
|
preloaded["model"], preloaded["processor"] = load_model() |
|
|
|
|
|
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) |
|
|
|
|
|
|
|
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" |
|
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") |