|
import torchaudio as ta |
|
import streamlit as st |
|
|
|
from io import BytesIO |
|
from transformers import AutoProcessor, SeamlessM4TModel |
|
|
|
processor = AutoProcessor.from_pretrained("facebook/hf-seamless-m4t-medium", use_fast=False) |
|
model = SeamlessM4TModel.from_pretrained("facebook/hf-seamless-m4t-medium") |
|
|
|
|
|
st.title("Audio Player with Live Transcription") |
|
|
|
|
|
st.sidebar.header("Upload Audio Files") |
|
uploaded_files = st.sidebar.file_uploader("Choose audio files", type=["mp3", "wav"], accept_multiple_files=True) |
|
submit_button = st.sidebar.button("Submit") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if submit_button and uploaded_files: |
|
st.write("Files uploaded successfully!") |
|
|
|
for uploaded_file in uploaded_files: |
|
|
|
print(uploaded_file) |
|
st.write(f"**File name**: {uploaded_file.name}") |
|
st.audio(uploaded_file, format=uploaded_file.type) |
|
|
|
|
|
st.write("**Transcription**:") |
|
|
|
|
|
waveform, sampling_rate = ta.load(uploaded_file.getvalue()) |
|
|
|
|
|
|
|
|
|
|
|
|