File size: 950 Bytes
c6e8353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from st_audiorec import st_audiorec
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq

processor = AutoProcessor.from_pretrained("openai/whisper-small")
model = AutoModelForSpeechSeq2Seq.from_pretrained("openai/whisper-small")

def transcribe(audio):

    text = processor.batch_decode(model.generate(processor(audio), num_beams=4), skip_special_tokens=True)
    return text

wav_audio_data = st_audiorec()

if wav_audio_data is not None:
    # st.audio(wav_audio_data, format='audio/wav')
    st.write("Transcription:")
    st.write(transcribe(wav_audio_data))

# Set up the Streamlit app
st.title("Glaswegian Transcription with Whisper")
api_key = st.sidebar.text_input("Enter your API key")

# Check if API key is provided
if api_key:
    st.write("API key:", api_key)
    # Add your code here to use the Whisper model for audio transcription
else:
    st.warning("Please enter your API key in the sidebar.")